code
stringlengths
1
1.73M
language
stringclasses
1 value
#!/usr/bin/ruby require 'erb' require 'fileutils' require File.join(File.dirname(__FILE__),'lib/import_helper') JUDGE_ENVIRONMENTS = [:grading, :exam] ENV_INFO = { :grading => { :ev_dir => 'ev', :raw_prefix => '', }, :exam => { :ev_dir => 'ev-exam', :raw_prefix => 'ex.', } } def input_filena...
Ruby
#!/usr/bin/ruby # new_problem: # * creates a directory for a problem in the current directory, # * create standard testcase config file require 'erb' def process_options(options) i = 2 while i<ARGV.length if ARGV[i]=='-t' options[:time_limit] = ARGV[i+1].to_i if ARGV.length>i+1 i += 1 end ...
Ruby
#!/usr/bin/ruby def log(str='') if ENV['TALKATIVE']!=nil puts str end if ENV['GRADER_LOGGING']!=nil log_fname = ENV['GRADER_LOGGING'] fp = File.open(log_fname,"a") fp.puts("judge: #{Time.new.strftime("%H:%M")} #{str}") fp.close end end problem_home = ENV['PROBLEM_HOME'] def execute(comman...
Ruby
#!/usr/bin/ruby CORRECT_MARK = 'P' INCORRECT_MARK = '-' TIMEOUT_MARK = 'T' RUN_ERROR_MARK = 'x' def log(str='') if ENV['TALKATIVE']!=nil puts str end if ENV['GRADER_LOGGING']!=nil log_fname = ENV['GRADER_LOGGING'] fp = File.open(log_fname,"a") fp.puts("grade: #{Time.new.strftime("%H:%M")} #{str}...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby def log(str='') if ENV['TALKATIVE']!=nil puts str end if ENV['GRADER_LOGGING']!=nil log_fname = ENV['GRADER_LOGGING'] fp = File.open(log_fname,"a") fp.puts("run: #{Time.new.strftime("%H:%M")} #{str}") fp.close end end def extract_time(t) # puts "TIME: #{t}" if (result=...
Ruby
#!/usr/bin/ruby def log(str='') if ENV['TALKATIVE']!=nil puts str end if ENV['GRADER_LOGGING']!=nil log_fname = ENV['GRADER_LOGGING'] fp = File.open(log_fname,"a") fp.puts("judge: #{Time.new.strftime("%H:%M")} #{str}") fp.close end end problem_home = ENV['PROBLEM_HOME'] def execute(comman...
Ruby
#!/usr/bin/ruby CORRECT_MARK = 'P' INCORRECT_MARK = '-' TIMEOUT_MARK = 'T' RUN_ERROR_MARK = 'x' def log(str='') if ENV['TALKATIVE']!=nil puts str end if ENV['GRADER_LOGGING']!=nil log_fname = ENV['GRADER_LOGGING'] fp = File.open(log_fname,"a") fp.puts("grade: #{Time.new.strftime("%H:%M")} #{str}...
Ruby
#!/usr/bin/ruby def log(str='') if ENV['TALKATIVE']!=nil puts str end if ENV['GRADER_LOGGING']!=nil log_fname = ENV['GRADER_LOGGING'] fp = File.open(log_fname,"a") fp.puts("run: #{Time.new.strftime("%H:%M")} #{str}") fp.close end end def extract_time(t) # puts "TIME: #{t}" if (result=...
Ruby
class DSLNode def DSLNode.scalar_attr(*names) names.each do |name| define_method name do |*a| if a.length == 0 instance_variable_get( "@#{name}" ) else instance_variable_set( "@#{name}", a[0] ) end end end end def DSLNode.array_attr(*names) ...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby # # This is a check script wrapper. It read all required information # and call a real check script call REAL_CHECK_SCRIPT in directory # [problem_home]/script # REAL_CHECK_SCRIPT = "<%= script_name %>" # The REAL_CHECK_SCRIPT is called with: # # (script) <lang> <test-num> <in-file> <out-file> <ans...
Ruby
#!/usr/bin/ruby # # This is a check script wrapper. It read all required information # and call a real check script call REAL_CHECK_SCRIPT in directory # [problem_home]/script # REAL_CHECK_SCRIPT = "<%= script_name %>" # The REAL_CHECK_SCRIPT is called with: # # (script) <lang> <test-num> <in-file> <out-file> <ans...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/env ruby ENVIRONMENT_DIRS = ['ev', 'ev-exam'] def config Grader::Configuration.get_instance end def rename_problem(old_problem_name, new_problem_name) if valid_problem_name(new_problem_name) puts "Bad new problem name: #{new_problem_name}" return end problem = Problem.find_by_name(old_pr...
Ruby
#!/usr/bin/ruby def stop_grader(id) if id==:all File.open(File.dirname(__FILE__) + "/stop.all",'w').close else File.open(File.dirname(__FILE__) + "/stop.#{id}",'w').close end end def check_stopfile FileTest.exist?(File.dirname(__FILE__) + "/stop.all") or FileTest.exist?(File.dirname(__FILE__) + "/...
Ruby
# # A runner drives the engine into various tasks. # module Grader class Runner def initialize(engine, grader_process=nil) @engine = engine @grader_process = grader_process end def grade_oldest_task task = Task.get_inqueue_and_change_status(Task::STATUS_GRADING) if task!=nil ...
Ruby
module Grader # This singleton class holds basic configurations for grader. When # running in each mode, grader uses resources from different # directories and outputs differently. Usually the attributes name # are descriptive; below we explain more on each attributes. class Configuration # Rails' envi...
Ruby
def filter_filename_for_testrun(testrun, filename_list, raw_prefix='') l = [] regex = Regexp.new("^(#{Regexp.escape(raw_prefix)}#{testrun}[a-z]*|#{testrun}-.*)$") filename_list.each do |filename| if regex.match(filename) l << filename end end l end def build_testrun_info(num_testruns, input_fi...
Ruby
module Grader class SubmissionRoomMaker def initialize @config = Grader::Configuration.get_instance end def produce_grading_room(submission) user = submission.user problem = submission.problem grading_room = "#{@config.user_result_dir}/" + "#{user.login}/#{problem.na...
Ruby
module Grader class Initializer def self.run(&block) config = Grader::Configuration.get_instance yield config end end end
Ruby
require File.join(File.dirname(__FILE__), 'configuration') require File.join(File.dirname(__FILE__), 'initializer') require File.join(File.dirname(__FILE__), 'submission_helper') require File.join(File.dirname(__FILE__), 'test_request_helper') require File.join(File.dirname(__FILE__), 'engine') require File.join(Fil...
Ruby
# # This part contains various test_request helpers for interfacing # with Grader::Engine. There are TestRequestRoomMaker and # TestRequestReporter. module Grader # # A TestRequestRoomMaker is a helper object for Engine # - finds grading room: in user_result_dir/(user)/test_request/ ... # - prepare problem c...
Ruby
require 'fileutils' require 'ftools' require File.join(File.dirname(__FILE__),'dir_init') module Grader # # A grader engine grades a submission, against anything: a test # data, or a user submitted test data. It uses two helpers objects: # room_maker and reporter. # class Engine attr_writer :roo...
Ruby
require 'ftools' # DirInit::Manager handles directory initialization and clean-up when # there are many concurrent processes that wants to modify the # directory in the same way. # # An example usage is when each process wants to copy some temporary # files to the directory and delete these files after finishing its #...
Ruby
#!/usr/bin/ruby def talk(str) if TALKATIVE puts str end end def execute(command, error_message="") if not system(command) puts "ERROR: #{error_message}" exit(127) end end def save_source(submission,dir,fname) f = File.open("#{dir}/#{fname}","w") f.write(submission.source) f.close end def c...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
module GraderEngineHelperMethods def clear_sandbox config = Grader::Configuration.get_instance clear_cmd = "rm -rf #{config.test_sandbox_dir}/*" system(clear_cmd) end def init_sandbox config = Grader::Configuration.get_instance clear_sandbox Dir.mkdir config.user_result_dir cp_cmd = ...
Ruby
# This test helper loads the grader's environment and rails environment GRADER_ENV = 'test' require File.join(File.dirname(__FILE__),'../config/environment') # this shall be removed soon RAILS_ENV = Grader::Configuration.get_instance.rails_env require RAILS_ROOT + '/config/environment' # make sure not to access re...
Ruby
# This test helper loads the grader's environment and rails environment GRADER_ENV = 'test' require File.join(File.dirname(__FILE__),'../config/environment') # this shall be removed soon RAILS_ENV = Grader::Configuration.get_instance.rails_env require RAILS_ROOT + '/config/environment' # make sure not to access re...
Ruby
#!/usr/bin/ruby # new_problem: # * creates a directory for a problem in the current directory, # * create standard testcase config file require 'erb' def process_options(options) i = 2 while i<ARGV.length if ARGV[i]=='-t' options[:time_limit] = ARGV[i+1].to_i if ARGV.length>i+1 i += 1 end ...
Ruby
#!/usr/bin/ruby def talk(str) if TALKATIVE puts str end end def execute(command, error_message="") if not system(command) puts "ERROR: #{error_message}" exit(127) end end def save_source(submission,dir,fname) f = File.open("#{dir}/#{fname}","w") f.write(submission.source) f.close end def c...
Ruby
#!/usr/bin/ruby def stop_grader(id) if id==:all File.open(File.dirname(__FILE__) + "/stop.all",'w').close else File.open(File.dirname(__FILE__) + "/stop.#{id}",'w').close end end def check_stopfile FileTest.exist?(File.dirname(__FILE__) + "/stop.all") or FileTest.exist?(File.dirname(__FILE__) + "/...
Ruby
#!/usr/bin/ruby # import_problem: # * creates a directory for a problem in the current directory, # * copy testdata in the old format and create standard testcase config file require 'erb' require 'fileutils' def input_filename(dir,i) "#{dir}/input-#{i}.txt" end def answer_filename(dir,i) "#{dir}/answer-#{i}....
Ruby
#!/usr/bin/ruby # import_problem: # * creates a directory for a problem in the current directory, # * copy testdata in the old format and create standard testcase config file require 'erb' require 'fileutils' def input_filename(dir,i) "#{dir}/input-#{i}.txt" end def answer_filename(dir,i) "#{dir}/answer-#{i}....
Ruby
#!/usr/bin/ruby # new_problem: # * creates a directory for a problem in the current directory, # * create standard testcase config file require 'erb' def process_options(options) i = 2 while i<ARGV.length if ARGV[i]=='-t' options[:time_limit] = ARGV[i+1].to_i if ARGV.length>i+1 i += 1 end ...
Ruby
#!/usr/bin/ruby def log(str='') if ENV['TALKATIVE']!=nil puts str end if ENV['GRADER_LOGGING']!=nil log_fname = ENV['GRADER_LOGGING'] fp = File.open(log_fname,"a") fp.puts("judge: #{Time.new.strftime("%H:%M")} #{str}") fp.close end end problem_home = ENV['PROBLEM_HOME'] def execute(comman...
Ruby
#!/usr/bin/ruby CORRECT_MARK = 'P' INCORRECT_MARK = '-' TIMEOUT_MARK = 'T' RUN_ERROR_MARK = 'x' def log(str='') if ENV['TALKATIVE']!=nil puts str end if ENV['GRADER_LOGGING']!=nil log_fname = ENV['GRADER_LOGGING'] fp = File.open(log_fname,"a") fp.puts("grade: #{Time.new.strftime("%H:%M")} #{str}...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby def log(str='') if ENV['TALKATIVE']!=nil puts str end if ENV['GRADER_LOGGING']!=nil log_fname = ENV['GRADER_LOGGING'] fp = File.open(log_fname,"a") fp.puts("run: #{Time.new.strftime("%H:%M")} #{str}") fp.close end end def extract_time(t) if (result=/^(.*)r(.*)u(.*)s/.matc...
Ruby
#!/usr/bin/ruby def log(str='') if ENV['TALKATIVE']!=nil puts str end if ENV['GRADER_LOGGING']!=nil log_fname = ENV['GRADER_LOGGING'] fp = File.open(log_fname,"a") fp.puts("judge: #{Time.new.strftime("%H:%M")} #{str}") fp.close end end problem_home = ENV['PROBLEM_HOME'] def execute(comman...
Ruby
#!/usr/bin/ruby CORRECT_MARK = 'P' INCORRECT_MARK = '-' TIMEOUT_MARK = 'T' RUN_ERROR_MARK = 'x' def log(str='') if ENV['TALKATIVE']!=nil puts str end if ENV['GRADER_LOGGING']!=nil log_fname = ENV['GRADER_LOGGING'] fp = File.open(log_fname,"a") fp.puts("grade: #{Time.new.strftime("%H:%M")} #{str}...
Ruby
#!/usr/bin/ruby def log(str='') if ENV['TALKATIVE']!=nil puts str end if ENV['GRADER_LOGGING']!=nil log_fname = ENV['GRADER_LOGGING'] fp = File.open(log_fname,"a") fp.puts("run: #{Time.new.strftime("%H:%M")} #{str}") fp.close end end def extract_time(t) if (result=/^(.*)r(.*)u(.*)s/.matc...
Ruby
class DSLNode def DSLNode.scalar_attr(*names) names.each do |name| define_method name do |*a| if a.length == 0 instance_variable_get( "@#{name}" ) else instance_variable_set( "@#{name}", a[0] ) end end end end def DSLNode.array_attr(*names) ...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby # # This is a check script wrapper. It read all required information # and call a real check script call REAL_CHECK_SCRIPT in directory # [problem_home]/script # REAL_CHECK_SCRIPT = "<%= script_name %>" # The REAL_CHECK_SCRIPT is called with: # # (script) <lang> <test-num> <in-file> <out-file> <ans...
Ruby
#!/usr/bin/ruby # # This is a check script wrapper. It read all required information # and call a real check script call REAL_CHECK_SCRIPT in directory # [problem_home]/script # REAL_CHECK_SCRIPT = "<%= script_name %>" # The REAL_CHECK_SCRIPT is called with: # # (script) <lang> <test-num> <in-file> <out-file> <ans...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby problem_home = ENV['PROBLEM_HOME'] require "#{problem_home}/script/test_dsl.rb" if ARGV.length < 2 puts "Usage: check <language> <test-number> [<output-file>]" exit(0) end language = ARGV[0] test_num = ARGV[1].to_i if ARGV.length >= 3 output_file_name = ARGV[2] else output_file_name = "output...
Ruby
#!/usr/bin/ruby def stop_grader(id) if id==:all File.open(File.dirname(__FILE__) + "/stop.all",'w').close else File.open(File.dirname(__FILE__) + "/stop.#{id}",'w').close end end def check_stopfile FileTest.exist?(File.dirname(__FILE__) + "/stop.all") or FileTest.exist?(File.dirname(__FILE__) + "/...
Ruby
# # A runner drives the engine into various tasks. # module Grader class Runner def initialize(engine, grader_process=nil) @engine = engine @grader_process = grader_process end def grade_oldest_task task = Task.get_inqueue_and_change_status(Task::STATUS_GRADING) if task!=nil ...
Ruby
module Grader # This singleton class holds basic configurations for grader. When # running in each mode, grader uses resources from different # directories and outputs differently. Usually the attributes name # are descriptive; below we explain more on each attributes. class Configuration # Rails' envi...
Ruby
module Grader class SubmissionRoomMaker def initialize @config = Grader::Configuration.get_instance end def produce_grading_room(submission) user = submission.user problem = submission.problem grading_room = "#{@config.user_result_dir}/" + "#{user.login}/#{problem.na...
Ruby
module Grader class Initializer def self.run(&block) config = Grader::Configuration.get_instance yield config end end end
Ruby
require File.join(File.dirname(__FILE__), 'configuration') require File.join(File.dirname(__FILE__), 'initializer') require File.join(File.dirname(__FILE__), 'submission_helper') require File.join(File.dirname(__FILE__), 'test_request_helper') require File.join(File.dirname(__FILE__), 'engine') require File.join(Fil...
Ruby
# # This part contains various test_request helpers for interfacing # with Grader::Engine. There are TestRequestRoomMaker and # TestRequestReporter. module Grader # # A TestRequestRoomMaker is a helper object for Engine # - finds grading room: in user_result_dir/(user)/test_request/ ... # - prepare problem c...
Ruby
require 'fileutils' module Grader # # A grader engine grades a submission, against anything: a test # data, or a user submitted test data. It uses two helpers objects: # room_maker and reporter. # class Engine attr_writer :room_maker attr_writer :reporter def initialize(room_maker=nil, ...
Ruby
class CreateCountries < ActiveRecord::Migration def self.up create_table :countries do |t| t.column :name, :string t.column :login, :string t.column :password, :string t.column :email, :string t.timestamps end end def self.down drop_table :countries end end
Ruby
class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.column :site_id, :integer t.column :name, :string t.timestamps end end def self.down drop_table :users end end
Ruby
class DenormalizeCountryToUser < ActiveRecord::Migration def self.up add_column "users", "country_id", :integer User.reset_column_information User.find(:all).each do |user| if user.site!=nil user.country_id = user.site.country_id user.save end end end def self.down ...
Ruby
class AddPasswordToUsers < ActiveRecord::Migration def self.up add_column "users", "password", :string end def self.down remove_column "users", "password" end end
Ruby
class AddUniqueIndexToUserLogin < ActiveRecord::Migration def self.up add_index "users", "login", :unique => true end def self.down remove_index "users", "login" end end
Ruby
class AddLoginToUser < ActiveRecord::Migration def self.up add_column "users", "login", :string end def self.down remove_column "users", "login" end end
Ruby
class CreateSites < ActiveRecord::Migration def self.up create_table :sites do |t| t.column :country_id, :integer t.column :name, :string t.column :login, :string t.column :password, :string t.timestamps end end def self.down drop_table :sites end end
Ruby
class CreateSessions < ActiveRecord::Migration def self.up create_table :sessions do |t| t.string :session_id, :null => false t.text :data t.timestamps end add_index :sessions, :session_id add_index :sessions, :updated_at end def self.down drop_table :sessions end end
Ruby
ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'test_help' class Test::Unit::TestCase # Transactional fixtures accelerate your tests by wrapping each test method # in a transaction that's rolled back on completion. This ensures that the # test datab...
Ruby
#!/usr/bin/ruby1.8 require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired...
Ruby
#!/usr/bin/ruby1.8 # # You may specify the path to the FastCGI crash log (a log of unhandled # exceptions which forced the FastCGI instance to exit, great for debugging) # and the number of requests to process before running garbage collection. # # By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log #...
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/runner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/runner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/generate'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/destroy'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/plugin'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/dbconsole'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/server'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/dbconsole'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/console'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/plugin'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/spawner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/spawner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/inspector'
Ruby