code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
class CreateMemos < ActiveRecord::Migration
def self.up
create_table :memos do |t|
t.text :content
t.references :user, :null => false
t.timestamps
end
end
def self.down
drop_table :memos
end
end
| Ruby |
class AddFromToRequest < ActiveRecord::Migration
def self.up
change_table :requirements do |t|
t.string :from
end
end
def self.down
change_table :requirements do |t|
t.remove :from
end
end
end
| Ruby |
class CreateLogs < ActiveRecord::Migration
def self.up
create_table :logs do |t|
t.text :content
t.string :log_type
t.integer :current_issue_user_id
t.integer :ex_issue_user_id
t.references :issue
t.... | Ruby |
class CreateIssues < ActiveRecord::Migration
def self.up
create_table :issues do |t|
t.integer :issueid
t.string :priority
t.integer :P1
t.integer :P2
t.integer :R
t.integer :S
t... | Ruby |
class CreateTags < ActiveRecord::Migration
def self.up
create_table :tags do |t|
t.string :name
t.datetime :release_at
t.datetime :should_release_at
t.string :state
t.references :project
t.timestamps
... | Ruby |
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
# from the project root directory.
ENV["RAILS_ENV"] ||= 'test'
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
require 'spec/autorun'
require 'spec/rails'
Spec::Runner.configure do |config|
# If yo... | Ruby |
# Main module for authentication.
# Include this in ApplicationController to activate RoleRequirement
#
# See RoleSecurityClassMethods for some methods it provides.
module RoleRequirementSystem
def self.included(klass)
klass.send :class_inheritable_array, :role_requirements
klass.send :include, RoleS... | Ruby |
module AuthenticatedSystem
protected
# Returns true or false if the user is logged in.
# Preloads @current_user with the user model if they're logged in.
def logged_in?
!!current_user
end
# Accesses the current user from the session.
# Future calls avoid the database because ni... | Ruby |
# Hijacker class
#
# This class is used by RoleRequirementTestHelper to temporarily hijack a controller action for testing
#
# Example usage:
# hijacker = Hijacker.new(ListingsController)
# hijacker.hijack_instance_method("index", "render :text => 'hello world!'" )
# get :index # will return "hello ... | Ruby |
gem 'test-unit', '1.2.3' if RUBY_VERSION.to_f >= 1.9
# Don't load rspec if running "rake gems:*"
unless ARGV.any? {|a| a =~ /^gems/}
begin
require 'spec/rake/spectask'
rescue MissingSourceFile
module Spec
module Rake
class SpecTask
def initialize(name)
task name do
... | Ruby |
namespace :db do
namespace :fixtures do
desc "Create YAML fixture from current database. Defaults to development database. Set RAILS_ENV to override."
task :dump => :environment do
sql = "SELECT * FROM %s"
skip_tables = ["schema_info"]
ActiveRecord::Base.establish_connection(RAILS_ENV... | Ruby |
$LOAD_PATH.unshift(RAILS_ROOT + '/vendor/plugins/cucumber/lib') if File.directory?(RAILS_ROOT + '/vendor/plugins/cucumber/lib')
begin
require 'cucumber/rake/task'
Cucumber::Rake::Task.new(:features) do |t|
t.fork = true
t.cucumber_opts = %w{--format pretty}
end
task :features => 'db:test:prep... | Ruby |
module AuthenticatedTestHelper
# Sets the current user in the session from the user fixtures.
def login_as(user)
@request.session[:user_id] = user ? (user.is_a?(User) ? user.id : users(user).id) : nil
end
def authorize_as(user)
@request.env["HTTP_AUTHORIZATION"] = user ? ActionController::HttpAu... | Ruby |
# Include this is test_helper.rb to enable test-case helper support for RoleRequirement via:
# include RoleRequirementTestHelper
#
# RoleRequirementTestHelper uses the power of ruby to temporarily "hijack" your target action. (don't worry, it puts things back the way it was after it runs)
# This means that the o... | Ruby |
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
class ActiveSupport::TestCase
# Transactional fixtures accelerate your tests by wrapping each test method
# in a transaction that's rolled back on completion. This ensures that the
# ... | Ruby |
class CreateUsers < ActiveRecord::Migration
def up
create_table :users do |t|
t.string :profile_id
t.string :email
t.string :refresh_token
end
add_index :users, :profile_id
end
def down
drop_table :users
end
end
| Ruby |
# Copyright (C) 2012 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | Ruby |
source :gemcutter
gem 'sinatra', :require => 'sinatra/base'
gem 'thin', '~> 1.3'
gem 'pg'
gem 'sinatra-activerecord'
gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client'
group :development do
gem 'rake'
gem 'sqlite3-ruby'
end
| Ruby |
require 'sinatra.rb'
# Sinatra defines #set at the top level as a way to set application configuration
set :run, false
set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development)
require './main'
run Sinatra::Application | Ruby |
require 'sinatra/activerecord/rake'
require './main' | Ruby |
# Require any additional compass plugins here.
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "theme/css"
sass_dir = "theme/scss"
images_dir = "images"
javascripts_dir = "js"
# You can select your preferred output style here (can be overridden via the command line):
output_style = :co... | Ruby |
class CreateUsers < ActiveRecord::Migration
def up
create_table :users do |t|
t.string :profile_id
t.string :email
t.string :refresh_token
end
add_index :users, :profile_id
end
def down
drop_table :users
end
end
| Ruby |
# Copyright (C) 2012 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | Ruby |
source :gemcutter
gem 'sinatra', :require => 'sinatra/base'
gem 'thin', '~> 1.3'
gem 'pg'
gem 'sinatra-activerecord'
gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client'
group :development do
gem 'rake'
gem 'sqlite3-ruby'
end
| Ruby |
require 'sinatra.rb'
# Sinatra defines #set at the top level as a way to set application configuration
set :run, false
set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development)
require './main'
run Sinatra::Application | Ruby |
require 'sinatra/activerecord/rake'
require './main' | Ruby |
class RubyLibraryExample
def get_server_language
'ruby'
end
# Basic communication
def passing
end
def failing(message)
raise message
end
def logging(message, level='INFO')
puts "*#{level}* #{message}"
end
def returning
'returned string'
end
# Logging
def one_message_w... | Ruby |
# Copyright 2008-2009 Nokia Siemens Networks Oyj
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | Ruby |
#!/usr/bin/env ruby
class ExampleRemoteLibrary
def count_items_in_directory(path)
Dir.entries(path).find_all{|i| not i.match('^\.')}.length
end
def strings_should_be_equal(str1, str2)
puts "Comparing '#{str1}' to '#{str2}'"
if str1 != str2
raise RuntimeError, "Given strings are not equal"
... | Ruby |
class CreateUsers < ActiveRecord::Migration
def up
create_table :users do |t|
t.string :profile_id
t.string :email
t.string :refresh_token
end
add_index :users, :profile_id
end
def down
drop_table :users
end
end
| Ruby |
# Copyright (C) 2012 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writ... | Ruby |
source :gemcutter
gem 'sinatra', :require => 'sinatra/base'
gem 'thin', '~> 1.3'
gem 'pg'
gem 'sinatra-activerecord'
gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client'
group :development do
gem 'rake'
gem 'sqlite3-ruby'
end
| Ruby |
require 'sinatra.rb'
# Sinatra defines #set at the top level as a way to set application configuration
set :run, false
set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development)
require './main'
run Sinatra::Application | Ruby |
require 'sinatra/activerecord/rake'
require './main' | Ruby |
require 'rake/clean'
DOT_NET_PATH = "#{ENV["SystemRoot"]}\\Microsoft.NET\\Framework\\v3.5"
NUNIT_EXE = "tools/Nunit/nunit-console.exe"
OUTPUT_PATH = "output"
CONFIG = "Debug"
CLEAN.include(OUTPUT_PATH)
directory "#{OUTPUT_PATH}/test"
task :default => :build
task :build => [:clean, :compile, :test, :deplo... | Ruby |
asset_cache_buster :none
| Ruby |
#
# This file is only needed for Compass/Sass integration. If you are not using
# Compass, you may safely ignore or delete this file.
#
# If you'd like to learn more about Sass and Compass, see the sass/README.txt
# file for more information.
#
# Change this to :production when ready to deploy the CSS to the live ser... | Ruby |
description "Unit tests for the Zen Grids system."
stylesheet 'sass/function-zen-direction-flip.scss', :media => 'all', :to => 'function-zen-direction-flip.scss'
stylesheet 'sass/function-zen-grid-item-width.scss', :media => 'all', :to => 'function-zen-grid-item-width.scss'
stylesheet 'sass/function-zen-half-gutter.s... | Ruby |
description "The Zen Grids system."
stylesheet '_init.scss', :media => 'all'
stylesheet '_layout.scss', :media => 'all'
stylesheet '_modules.scss', :media => 'all'
stylesheet '_visually-hidden.scss', :media => 'all'
stylesheet 'styles.scss', :media => 'all'
html ... | Ruby |
require 'compass'
extension_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
Compass::Frameworks.register('zen-grids', :path => extension_path)
| Ruby |
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = 'zen-grids'
s.summary = %q{A Compass plugin for Zen Grids, a fluid responsive grid system}
s.description = %q{Zen Grids is an intuitive, flexible grid system that leverages the natural source order of your content to make it easier to c... | Ruby |
#
# This file is only needed for Compass/Sass integration. If you are not using
# Compass, you may safely ignore or delete this file.
#
# If you'd like to learn more about Sass and Compass, see the sass/README.txt
# file for more information.
#
# Change this to :production when ready to deploy the CSS to the live ser... | Ruby |
description "Unit tests for the Zen Grids system."
stylesheet 'sass/function-zen-direction-flip.scss', :media => 'all', :to => 'function-zen-direction-flip.scss'
stylesheet 'sass/function-zen-grid-item-width.scss', :media => 'all', :to => 'function-zen-grid-item-width.scss'
stylesheet 'sass/function-zen-half-gutter.s... | Ruby |
description "The Zen Grids system."
stylesheet '_init.scss', :media => 'all'
stylesheet '_layout.scss', :media => 'all'
stylesheet '_modules.scss', :media => 'all'
stylesheet '_visually-hidden.scss', :media => 'all'
stylesheet 'styles.scss', :media => 'all'
html ... | Ruby |
require 'compass'
extension_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
Compass::Frameworks.register('zen-grids', :path => extension_path)
| Ruby |
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = 'zen-grids'
s.summary = %q{A Compass plugin for Zen Grids, a fluid responsive grid system}
s.description = %q{Zen Grids is an intuitive, flexible grid system that leverages the natural source order of your content to make it easier to c... | Ruby |
#
# This file is only needed for Compass/Sass integration. If you are not using
# Compass, you may safely ignore or delete this file.
#
# If you'd like to learn more about Sass and Compass, see the sass/README.txt
# file for more information.
#
# Change this to :production when ready to deploy the CSS to the live ser... | Ruby |
description "Unit tests for the Zen Grids system."
stylesheet 'sass/function-zen-direction-flip.scss', :media => 'all', :to => 'function-zen-direction-flip.scss'
stylesheet 'sass/function-zen-grid-item-width.scss', :media => 'all', :to => 'function-zen-grid-item-width.scss'
stylesheet 'sass/function-zen-half-gutter.s... | Ruby |
description "The Zen Grids system."
stylesheet 'common.scss', :media => 'all'
stylesheet 'layout.scss', :media => 'all'
stylesheet 'styles.scss', :media => 'all'
html 'example.html'
help %Q{
Zen Grids is an intuitive, flexible grid system that leverages the natural source order of your content to make it easier to c... | Ruby |
require 'compass'
extension_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
Compass::Frameworks.register('zen-grids', :path => extension_path)
| Ruby |
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = 'zen-grids'
s.summary = %q{A Compass plugin for Zen Grids, a fluid responsive grid system}
s.description = %q{Zen Grids is an intuitive, flexible grid system that leverages the natural source order of your content to make it easier to c... | Ruby |
# Copyright 2008-2009 Nokia Siemens Networks Oyj
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or... | Ruby |
#!/usr/bin/env ruby
class ExampleRemoteLibrary
def count_items_in_directory(path)
Dir.entries(path).find_all{|i| not i.match('^\.')}.length
end
def strings_should_be_equal(str1, str2)
puts "Comparing '#{str1}' to '#{str2}'"
if str1 != str2
raise RuntimeError, "Given strings are not equal"
... | Ruby |
class RubyLibraryExample
def get_server_language
'ruby'
end
# Basic communication
def passing
end
def failing(message)
raise message
end
def logging(message, level='INFO')
puts "*#{level}* #{message}"
end
def returning
'returned string'
end
# Logging
def one_message_w... | Ruby |
# Copyright 2009 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | Ruby |
# Settings specified here will take precedence over those in config/environment.rb
# The production environment is meant for finished, "live" apps.
# Code is not reloaded between requests
config.cache_classes = true
# Use a different logger for distributed setups
# config.logger = SyslogLogger.new
# Full err... | Ruby |
# Settings specified here will take precedence over those in config/environment.rb
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don't have to restart the webserver when you make code changes.
config.ca... | Ruby |
# Settings specified here will take precedence over those in config/environment.rb
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between... | Ruby |
# Be sure to restart your web server when you modify this file.
# Uncomment below to force Rails into production mode when
# you don't control web/app server and can't set it the proper way
ENV['RAILS_ENV'] ||= 'production'
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(Fi... | Ruby |
# Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb
unless defined?(RAILS_ROOT)
root_path = File.join(File.dirname(__FILE__), '..')
unless RUBY_PLATFORM =~ /mswin32/
require 'pathname'
root_path = Pathname.new(root_path).cleanpath(true).to_s
end
RAILS_R... | Ruby |
ActionController::Routing::Routes.draw do |map|
# Add your own custom routes here.
# The priority is based upon order of creation: first created -> highest priority.
# Here's a sample route:
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
# Keep in mind you can assign values other... | Ruby |
module SysadminHelper
end
| Ruby |
module PermissionHelper
end
| Ruby |
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
def error_messages_for(object_name, options = {})
options = options.symbolize_keys
object = instance_variable_get("@#{object_name}")
unless object.errors.empty?
error_lis = []
object.errors... | Ruby |
module EntryHelper
end
| Ruby |
module AjaxHelper
end
| Ruby |
module QueryHelper
end
| Ruby |
module CommonActionHelper
end
| Ruby |
module ProductHelper
end
| Ruby |
module WelcomeHelper
end
| Ruby |
module MessageHelper
end
| Ruby |
module AdminorgHelper
end
| Ruby |
module OtherOrgHelper
end
| Ruby |
module IndexHelper
end
| Ruby |
module StoreHelper
end
| Ruby |
module SaleHelper
end
| Ruby |
class Message < ActiveRecord::Base
belongs_to :employee
end
| Ruby |
class Code < ActiveRecord::Base
belongs_to :product
belongs_to :agent
end
| Ruby |
class Store < ActiveRecord::Base
has_many :storeProducts
validates_uniqueness_of :name,:message=>'该仓库已经存在'
end
| Ruby |
class AgentFamilyMember < ActiveRecord::Base
belongs_to :agent
end
| Ruby |
class SalePaperItem < ActiveRecord::Base
belongs_to :salePaper
belongs_to :product
belongs_to :productTransaction
has_many :returnPaperItems
end
| Ruby |
class Employee < ActiveRecord::Base
file_column :photo
has_one :account
has_many :agents
has_many :salePapers
has_many :returnPapers
has_many :storeTransactionItems
has_many :messages
end | Ruby |
class Right < ActiveRecord::Base
has_and_belongs_to_many :roles
validates_presence_of :name,:message=>'没有填写频道名称'
end
| Ruby |
require 'digest/sha1'
class Account < ActiveRecord::Base
belongs_to :employee
belongs_to :role
# Please change the salt to something else,
# Every application should use a different one
@@salt = 'change-me'
cattr_accessor :salt
# Authenticate a user.
#
# Example:
# @account = Ac... | Ruby |
class RightRole < ActiveRecord::Base
set_table_name "rights_roles"
belongs_to :right
belongs_to :role
end
| Ruby |
class ConfigVariable < ActiveRecord::Base
end
| Ruby |
class StoreTransaction < ActiveRecord::Base
belongs_to :from,:class_name=>"StoreProduct",:foreign_key => "from_id"
belongs_to :to,:class_name=>"StoreProduct",:foreign_key => "to_id"
belongs_to :employee
belongs_to :product
end
| Ruby |
class Entry < ActiveRecord::Base
file_column :image
end
| Ruby |
class Department < ActiveRecord::Base
has_many :roles,:order=>'name'
validates_presence_of :name,:message=>'没有填写部门名称'
validates_uniqueness_of :name,:message=>'该部门已经存在'
end
| Ruby |
class Product < ActiveRecord::Base
has_many :codes
has_many :problemProducts
has_many :productPictures
has_many :productTransactionItems
has_many :storeProducts
has_many :returnPaperItems
end
| Ruby |
class Role < ActiveRecord::Base
has_and_belongs_to_many :rights,:order=>'module,mgroup,id'
has_many :accounts
belongs_to :department
end
| Ruby |
class Agent < ActiveRecord::Base
belongs_to :employee
has_many :salePapers
has_many :agent_family_member
has_many :codes
end
| Ruby |
class StoreTransactionItem < ActiveRecord::Base
belongs_to :storeProduct
belongs_to :employee
end
| Ruby |
class AddressSalePaper
attr_reader :storeProductId, :productId, :value
def initialize(storeProductId, productId, value)
@storeProductId = storeProductId
@productId = productId
@value = value
end
end
| Ruby |
class ProductTransactionItem < ActiveRecord::Base
belongs_to :product
end
| Ruby |
class ProblemProduct < ActiveRecord::Base
belongs_to :product
end
| Ruby |
class ProductPicture < ActiveRecord::Base
file_column :picture
belongs_to :product
end
| Ruby |
class SalePaper < ActiveRecord::Base
belongs_to :agent
belongs_to :employee
has_many :return_papers
has_many :salePaperItems
end
| Ruby |
class StoreProduct < ActiveRecord::Base
belongs_to :product
belongs_to :store
has_many :storeTractionItems
end
| Ruby |
class ReturnPaperItem < ActiveRecord::Base
#belongs_to :returnPaper
belongs_to :product
belongs_to :productTransactionItem
belongs_to :sale_paper_item
belongs_to :salePaper
end
| Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.