code
stringlengths
1
1.73M
language
stringclasses
1 value
module BackgrounDRb class Trigger attr_accessor :start_time, :end_time, :repeat_interval def initialize(opts={}) @start_time = opts[:start] @end_time = opts[:end] @repeat_interval = opts[:repeat_interval] end def fire_time_after(time) @start_time = time if not @start_time ...
Ruby
module BackgrounDRb class Scheduler @@event = Struct.new(:job, :trigger, :earliest, :last) attr_accessor :exit_on_idle attr_reader :jobs def self.event @@event end def initialize(exit_on_idle = true) @exit_on_idle = exit_on_idle @jobs = Array.new end def schedul...
Ruby
module BackgrounDRb module Worker class RailsBase < Base include DRbUndumped require BACKGROUNDRB_ROOT + '/config/boot.rb' require 'active_record' require 'active_support' def initialize(args=nil, jobkey=nil) BACKGROUNDRB_ROOT.untaint db_config_data = IO.read("#{BACK...
Ruby
module BackgrounDRb class ThreadPool attr_reader :pool def initialize(size) @pool = [] @size = size @mutex = Mutex.new @cv = ConditionVariable.new end def ex @mutex.synchronize { yield } end def empty_pool! ex { @cv.wait(@mutex) until @pool.empty? } ...
Ruby
require 'drb' require 'digest/md5' require 'thread' require 'singleton' require 'backgroundrb/thread_pool' require 'backgroundrb/worker' require 'backgroundrb/scheduler' require 'backgroundrb/trigger' require 'backgroundrb/cron_trigger' require 'backgroundrb/results' require 'rubygems' require 'slave' require 'yaml' ...
Ruby
require 'backgroundrb' require 'irb' require 'irb/completion' # TODO: make the middleman methods available to the IRB shell module IRB # :nodoc: def IRB.backgroundrb_console_start(middleman) IRB.setup(nil) irb = Irb.new(IRB::WorkSpace.new(middleman)) @CONF[:MAIN_CONTEXT] = irb.context trap("SIGINT")...
Ruby
module BackgrounDRb class CronTrigger attr_reader :sec, :min, :hour, :day, :month, :wday, :year, :cron_expr def initialize(expr) self.cron_expr = expr end def cron_expr=(expr) @cron_expr = expr self.sec, self.min, self.hour, self.day, self.month, self.wday, self.year = @cron_expr....
Ruby
module BackgrounDRb # The BackgrounDRb results module is used in two places. In the # regular worker to store and retrieve results from the results # worker. It is also used by the WorkerProxy when a worker is no # longer around and you want to access results through the MiddleMan. # # A limitation with th...
Ruby
# Install hook code here
Ruby
require 'pathname' BACKGROUNDRB_ROOT = Pathname.new(RAILS_ROOT).realpath.to_s require 'backgroundrb' # Set up a MiddleMan for the BackgrounDRb server configured for this # particular instance of Rails. class BackgrounDRb::MiddleManRailsProxy def self.init config = { :config => "#{BACKGROUNDRB_ROOT}/config/backgr...
Ruby
require 'erb' module BackgrounDRb VERSION = "0.2.1" end # The configuration class is shared between server and the DRb clients # (Rails MiddleMan, console and the MiddleManDRbObject). Defaults set in # this class is in turn overridden by options from the configuration # file, which in turn can be overridden by comm...
Ruby
require File.dirname(__FILE__) + '/../server/lib/backgroundrb/backgroundrb_worker' require File.dirname(__FILE__) + '/../server/lib/backgroundrb/middleman' require File.dirname(__FILE__) + '/../server/lib/backgroundrb/thread_pool' require File.dirname(__FILE__) + '/../server/lib/backgroundrb/scheduler' require File.dir...
Ruby
require 'sinatra/activerecord/rake' require './main'
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
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
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 'backup_fu'
Ruby
require 'fileutils' $:.unshift(File.dirname(__FILE__) + '/../lib') require 'backup_fu' $backup_fu_path = File.join(File.dirname(__FILE__), '..') desc "Dumps the database and backs it up remotely to Amazon S3. (task added by: backup_fu)" task :backup do b = BackupFu.new b.backup end namespace :backup_fu do d...
Ruby
require 'yaml' require 'active_support' require 'aws/s3' class BackupFuConfigError < StandardError; end class S3ConnectError < StandardError; end class BackupFu def initialize db_conf = YAML.load_file(File.join(RAILS_ROOT, 'config', 'database.yml')) @db_conf = db_conf[RAILS_ENV].symbolize_keys @fu_c...
Ruby
ActionController::Base.send :before_filter, :propogate_current_user require 'badges' ActionController::Base.send :include, Badges::AuthorizeHandler # in edge rails 2.+, this adds the erb pages under the plugin to the view path ActionController::Base.append_view_path(File.join( File.dirname(__FILE__), 'views')) Acti...
Ruby
require 'rake' require 'rake/testtask' require 'rake/rdoctask' desc 'Default: run unit tests.' task :default => :test desc 'Test the badges plugin.' Rake::TestTask.new(:test) do |t| t.libs << 'lib' t.pattern = 'test/**/*_test.rb' t.verbose = true end desc 'Generate documentation for the badges plugin.' Rake::R...
Ruby
module Badges class InstallManager class << self def install setup migrate :up rescue Object => exception puts "Badges plugin install error:\n#{exception.message}\n" + exception.backtrace.join("\n\t") raise $! end def uninstall setup ...
Ruby
RAILS_ROOT=File.expand_path(File.join(File.dirname(__FILE__), '..','..','..')) load "#{File.dirname(__FILE__)}/install_manager.rb" Badges::InstallManager.uninstall
Ruby
RAILS_ROOT=File.expand_path(File.join(File.dirname(__FILE__), '..','..','..')) load "#{File.dirname(__FILE__)}/install_manager.rb" Badges::InstallManager.install
Ruby
class CreateRoles < ActiveRecord::Migration def self.up create_table :badges_roles, :force => true do |t| t.column :name, :string, :limit => 50 t.column :created_at, :datetime t.column :updated_at, :datetime end create_table :badges_user_roles, :force =...
Ruby
class CreateDefaultData < ActiveRecord::Migration def self.up Badges::Role.create(:name=>Badges::Config.default_user_role.to_s) Badges::Role.create(:name=>Badges::Config.default_admin_role.to_s) Badges::Privilege.create(:name=>"manage authorization") Badges::Privilege.create(:name=>"manage privileg...
Ruby
class CreatePrivileges < ActiveRecord::Migration def self.up create_table :badges_privileges, :force => true do |t| t.column :name, :string, :limit => 50 t.column :name, :string, :limit => 50 t.column :created_at, :datetime t.column :updated_at, ...
Ruby
# taken from comatose, thanks! class ActionController::Routing::RouteSet::Mapper def badges_admin(path='badges', options={}) define_named_routes(path, 'badges', 'admin', options) end protected def define_named_routes(path, mod, controller, options) opts = {:controller=>"#{mod}/#{controller}"}.merg...
Ruby
module Kernel def singleton_class class << self; self; end end end
Ruby
module Badges module AdminHelper end end
Ruby
module Badges def self.thread_current_user Thread.current['current_user'] || nil end def self.thread_current_user=(user) Thread.current['current_user'] = user end end
Ruby
module Badges class Privilege < ActiveRecord::Base set_table_name "badges_privileges" validates_uniqueness_of :name, :case_sensitive => false has_many :role_privileges has_many :roles, :through=>:role_privileges after_create :add_to_default_admin_role def add_to_default_admin_role ...
Ruby
module Badges class UserRole < ActiveRecord::Base set_table_name "badges_user_roles" belongs_to :authorizable, :polymorphic => true belongs_to :role, :class_name=>"Badges::Role", :foreign_key=>'role_id' class <<self def associate_user_class(user_class) belongs_to :user, :class_name=>us...
Ruby
module Badges class RolePrivilege < ActiveRecord::Base set_table_name "badges_role_privileges" belongs_to :role, :class_name=>'Badges::Role' belongs_to :privilege, :class_name=>'Badges::Privilege' validates_uniqueness_of :privilege_id, :scope=>:role_id end end
Ruby
module Badges class AdminController < ActionController::Base layout 'badges/admin' # display the list of all roles and permissions def index @roles = Badges::Role.find(:all) @privileges = Badges::Privilege.find(:all) @privilege_roles = {} @privileges.each { |p| @privilege_roles[p...
Ruby
module Badges class Config cattr_accessor :unauthorized_message, :unauthorized_controller_method, :unauthorized_url, :create_when_missing, :default_user_role, :default_admin_role, :authentication_...
Ruby
module Badges module Authorizable def self.included(base) # :nodoc: base.extend ClassMethods end module ClassMethods def badges_authorizable_object has_many :user_roles, :as=>:authorizable, :class_name=>"Badges::UserRole" has_many :users, :through=>:user_roles i...
Ruby
module Badges class Role < ActiveRecord::Base set_table_name "badges_roles" validates_uniqueness_of :name, :case_sensitive => false has_many :user_roles, :class_name=>'Badges::UserRole' has_many :role_privileges, :class_name=>'Badges::RolePrivilege' has_many :privileges, :through=>:role_priv...
Ruby
module Badges module Authorized def self.included(base) # :nodoc: base.extend ClassMethods end module ClassMethods def badges_authorized_user # include this to get access to the current_user in model instances include Badges::ModelAuthorization::InstanceMethods ...
Ruby
module Badges module ModelAuthorization def self.included(base) base.extend(ClassMethods) end module ClassMethods @@authorization_checker=nil # privilege_required 'some privilege name' => [:all, :save, :create, :update, :destroy, :find] # privilege_req...
Ruby
module Badges module AuthorizeHandler def self.included(base) base.extend(ClassMethods) if base.respond_to?(:helper_method) base.send :helper_method, :has_privilege? base.send :helper_method, :if_privilege end end module ClassMethods # privilege_required 'mana...
Ruby
require 'badges/core' require 'badges/config' require 'badges/authorizable' require 'badges/authorized' require 'badges/model_authorization' require 'badges/authorize_handler' require 'badges/privilege' require 'badges/role' require 'badges/role_privilege' require 'badges/user_role' require 'extensions/routing' requir...
Ruby
module Badges class TestUser < ActiveRecord::Base set_table_name "badges_test_users" badges_authorized_user end class TestProject < ActiveRecord::Base set_table_name "badges_test_projects" badges_authorizable_object end end
Ruby
ActiveRecord::Schema.define(:version => 0) do create_table :badges_test_users, :force => true do |t| t.column :username, :string end create_table :badges_test_projects, :force => true do |t| t.column :name, :string end end
Ruby
$:.unshift(File.dirname(__FILE__) + '/../lib') ENV["RAILS_ENV"] = "test" require 'test/unit' require File.expand_path(File.join(File.dirname(__FILE__), '../../../../config/environment.rb')) require 'test_help' require 'rubygems' require 'active_record/fixtures' # load up the test db schema and model require (File.di...
Ruby
require 'v1/rest.rb' class Rest #~ alias :Rest.getOldResource :Rest.getResource #~ def self.getResource request, resource_name = '' #~ self.getOldResource request, resource_name #~ m = request.match(/^([A-Z]+?) \/#{resource_name}(.*) HTTP\/1.1$/) #~ if m then #~ rest = RESTResource.new #~ rest.name ...
Ruby
## # @version 2 class BinaryTreeNodeValue include Comparable attr_reader :ngrille, :points, :depth attr_writer :ngrille, :points, :depth def <=> other if @ngrille == other.ngrille then if @depth == other.depth then if @points == other.points then return 0 elsif @points > other.points then ...
Ruby
module BinaryTreeHelper private def add_or_create_node(field, value) if instance_variable_get(field).nil? instance_variable_set(field, BinaryTreeNode.new(value)) return true else return instance_variable_get(field).add(value) end end #~ def is_nil_or_not? (field, value) #~ return false if instanc...
Ruby
#!/usr/bin/ruby def load_rubycode 1.upto(10) do |i| if File.exist? "v#{i}" then Dir.foreach("v#{i}/").sort.each do |f| if f =~ /\.rb$/ then require "v#{i}/#{f}" end end else break end end end load_rubycode BacteriaWebGUI.instance.run
Ruby
# binarytree.rb # # $Revision: 1.5 $ by $Author: anupamsg $ # $Name: $ # # = binarytree.rb - Binary Tree implementation # # Provides a generic tree data structure with ability to # store keyed node elements in the tree. The implementation # mixes in the Enumerable module. # # Author:: Anupam Sengupta (anupamsg@gmail.c...
Ruby
require 'singleton' class Point attr_reader :x, :y attr_writer :x, :y def initialize x, y @x = x @y = y end def manhattan point (point.x - @x) ** 2 + (point.y - @y) ** 2 end end class RCase include Singleton end class CaseVide < RCase end class CaseTrou < RCase end class CaseVerte < RCase end cl...
Ruby
class RESTResource attr_reader :name, :params attr_writer :method, :name, :params def initialize @params = Hash.new end def isGET? @method == 'GET' end def isPUT? @method == 'PUT' end def isDELETE? @method == 'DELETE' end def [] k @params[k] end def []= k, v @params[k] = v end e...
Ruby
require 'yaml' ## # @version 1 def deep_copy obj YAML::load(YAML::dump(obj)) end ## # @version 1 module MinMax def chercher depth, maxDepth minMaxAlt = (depth % 2 == 1) if (depth == maxDepth) then points = calcPoints(minMaxAlt, grille) chemin = Array.new else eachCoup(minMaxAlt) do |coup| co...
Ruby
#!/usr/bin/ruby def load_rubycode 1.upto(10) do |i| if File.exist? "v#{i}" then Dir.foreach("v#{i}/").sort.each do |f| if f =~ /\.rb$/ then require "v#{i}/#{f}" end end else break end end end load_rubycode BacteriaWebGUI.instance.run
Ruby
def toto 0.upto(10) do |i| 11.upto(20) do |j| yield "#{i}-#{j}" end end end toto do |str| puts str break end
Ruby
class Node attr_reader :left, :right, :value attr_writer :left, :right, :value def initialize @left = nil @right = nil @value = nil end end class BinaryTree attr_reader :root attr_writer :root def initialize() @root = Node.new end def preOrder(node) p node.value if n...
Ruby
# tree.rb # # $Revision: 1.29 $ by $Author: anupamsg $ # $Name: $ # # = tree.rb - Generic Multi-way Tree implementation # # Provides a generic tree data structure with ability to # store keyed node elements in the tree. The implementation # mixes in the Enumerable module. # # Author:: Anupam Sengupta (anupamsg@gmail.c...
Ruby
require "socket" Thread.abort_on_exception = true Thread.new do begin loop do STDOUT.flush end rescue end end gs = TCPserver.open(8080) addr = gs.addr addr.shift # removes "AF_INET" printf("server is on %s\n", addr.join(":")) begin trap("SIGINT") { gs.close exit 0 } ...
Ruby
require "socket" Thread.abort_on_exception = true gs = TCPserver.open(8080) addr = gs.addr addr.shift # removes "AF_INET" printf("server is on %s\n", addr.join(":")) begin trap("SIGINT") { gs.close exit 0 } def receive_request soc, request req = request.match(/^GET (.*) HTTP\/1.1/)[1...
Ruby
puts "test"
Ruby
puts "test"
Ruby
require 'v1/rest.rb' class Rest #~ alias :Rest.getOldResource :Rest.getResource #~ def self.getResource request, resource_name = '' #~ self.getOldResource request, resource_name #~ m = request.match(/^([A-Z]+?) \/#{resource_name}(.*) HTTP\/1.1$/) #~ if m then #~ rest = RESTResource.new #~ rest.name ...
Ruby
class BinaryTreeNodeValue include Comparable attr_reader :ngrille, :points, :depth attr_writer :ngrille, :points, :depth def <=> other if @ngrille == other.ngrille then if @depth == other.depth then if @points == other.points then return 0 elsif @points > other.points then return 1 end...
Ruby
module BinaryTreeHelper private def add_or_create_node(field, value) if instance_variable_get(field).nil? instance_variable_set(field, BinaryTreeNode.new(value)) return true else return instance_variable_get(field).add(value) end end #~ def is_nil_or_not? (field, value) #~ return false if instanc...
Ruby
#!/usr/bin/ruby def load_rubycode 1.upto(10) do |i| if File.exist? "v#{i}" then Dir.foreach("v#{i}/").sort.each do |f| if f =~ /\.rb$/ then require "v#{i}/#{f}" end end else break end end end load_rubycode BacteriaWebGUI.instance.run
Ruby
# binarytree.rb # # $Revision: 1.5 $ by $Author: anupamsg $ # $Name: $ # # = binarytree.rb - Binary Tree implementation # # Provides a generic tree data structure with ability to # store keyed node elements in the tree. The implementation # mixes in the Enumerable module. # # Author:: Anupam Sengupta (anupamsg@gmail.c...
Ruby
require 'singleton' class Point attr_reader :x, :y attr_writer :x, :y def initialize x, y @x = x @y = y end def manhattan point (point.x - @x) ** 2 + (point.y - @y) ** 2 end end class RCase include Singleton end class CaseVide < RCase end class CaseTrou < RCase end class CaseVerte < RCase end cl...
Ruby
class RESTResource attr_reader :name, :params attr_writer :method, :name, :params def initialize @params = Hash.new end def isGET? @method == 'GET' end def isPUT? @method == 'PUT' end def isDELETE? @method == 'DELETE' end def [] k @params[k] end def []= k, v @params[k] = v end e...
Ruby
require 'yaml' def deep_copy obj YAML::load(YAML::dump(obj)) end module MinMax def chercher depth, maxDepth minMaxAlt = (depth % 2 == 1) if (depth == maxDepth) then points = calcPoints(minMaxAlt, grille) chemin = Array.new else eachCoup(minMaxAlt) do |coup| context = copy context.jouerCoup...
Ruby
#!/usr/bin/ruby def load_rubycode 1.upto(10) do |i| if File.exist? "v#{i}" then Dir.foreach("v#{i}/").sort.each do |f| if f =~ /\.rb$/ then require "v#{i}/#{f}" end end else break end end end load_rubycode BacteriaWebGUI.instance.run
Ruby
def toto 0.upto(10) do |i| 11.upto(20) do |j| yield "#{i}-#{j}" end end end toto do |str| puts str break end
Ruby
class Node attr_reader :left, :right, :value attr_writer :left, :right, :value def initialize @left = nil @right = nil @value = nil end end class BinaryTree attr_reader :root attr_writer :root def initialize() @root = Node.new end def preOrder(node) p node.value if n...
Ruby
# tree.rb # # $Revision: 1.29 $ by $Author: anupamsg $ # $Name: $ # # = tree.rb - Generic Multi-way Tree implementation # # Provides a generic tree data structure with ability to # store keyed node elements in the tree. The implementation # mixes in the Enumerable module. # # Author:: Anupam Sengupta (anupamsg@gmail.c...
Ruby
#!/usr/local/bin/ruby require 'webrick' require 'WEBrickSession' include WEBrick class BackEndServlet < HTTPServlet::AbstractServlet #~ def gen_session_id #~ return 'toto' #~ end def do_GET(req, res) session = Session.new(req, res) p session #~ p req.cookies #~ unless req.cookies.any? {|e| e.name ==...
Ruby
#!/usr/local/bin/ruby require 'webrick' require 'WEBrickSession' include WEBrick class BackEndServlet < HTTPServlet::AbstractServlet #~ def gen_session_id #~ return 'toto' #~ end def do_GET(req, res) session = Session.new(req, res) p session #~ p req.cookies #~ unless req.cookies.any? {|e| e.name ==...
Ruby
# webrick/session.rb -- Session manager like CGI::Session # Lisence:: Ruby's require 'digest/md5' require 'tmpdir' require 'webrick/cookie' module WEBrick class Session public NoSession = Class.new(StandardError) attr_reader(:session_id, :new_session) def self.callback(dbman) Proc.new do ...
Ruby
module ThreadSessionClientModule def create soc soc.write "301 SESSION CREATE\n" response = soc.gets if m = response.matches(/^302 SESSION CREATED (.+)$/) then return m[1] end return nil end def restore soc, id soc.write "302 SESSION RESTORE #{id}\n" response = soc.gets if m = response...
Ruby
class RESTResource attr_reader :name, :params attr_writer :method, :name, :params def initialize @params = Hash.new end def isGET? @method == 'GET' end def isPUT? @method == 'PUT' end def isDELETE? @method == 'DELETE' end def [] k @params[k] end def []= k, v @params[k] = v end e...
Ruby
require 'yaml' ## # @version 1 def deep_copy obj YAML::load(YAML::dump(obj)) end ## # @version 1 module MinMax def chercher depth, maxDepth minMaxAlt = (depth % 2 == 1) if (depth == maxDepth) then points = calcPoints(minMaxAlt, grille) chemin = Array.new else eachCoup(minMaxAlt) do |coup| co...
Ruby
require 'singleton' class Point attr_reader :x, :y attr_writer :x, :y def initialize x, y @x = x @y = y end def manhattan point (point.x - @x) ** 2 + (point.y - @y) ** 2 end end class RCase include Singleton end class CaseVide < RCase end class CaseTrou < RCase end class CaseVerte < RCase end cl...
Ruby
module ThreadSessionModule def initialize @sessions = {} @counter = 0 end def receive_request soc, req if req =~ /^301 SESSION CREATE$/ then token = make_token.to_s soc.write "201 SESSION CREATED #{token}\n" @sessions[token] = {} Thread.current["session"] = @sessions[token] Thread.current...
Ruby
require 'sinatra/activerecord/rake' require './main'
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
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
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 any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "stylesheets" sass_dir = "sass" images_dir = "images" javascripts_dir = "javascripts" # You can select your preferred output style here (can be overridden via the command line): # output_styl...
Ruby
class Logins < ActiveRecord::Migration def self.up create_table :logins do |table| table.column :login, :string table.column :email, :string table.column :crypted_password, :string, :limit => 40 table.column :salt, :stri...
Ruby
class Items < ActiveRecord::Migration def self.up create_table :items do |table| table.column :title, :string table.column :description, :string table.column :notes, :string table.column :done, :boolean table.column :story_points, :integer ...
Ruby
class Bugs < ActiveRecord::Migration def self.up create_table :bugs do |table| table.column :title, :string table.column :created, :date table.column :fixed, :date table.column :notes, :string table.column :developer_id, :integer end end def self.down ...
Ruby
class Sprints < ActiveRecord::Migration def self.up create_table :sprints do |table| table.column :title, :string table.column :start, :date table.column :end, :date end end def self.down drop_table :sprints end end
Ruby
class Developers < ActiveRecord::Migration def self.up create_table :developers do |table| table.column :name, :string end end def self.down drop_table :developers end end
Ruby
class Tasks < ActiveRecord::Migration def self.up create_table :tasks do |table| table.column :title, :string table.column :description, :string table.column :completed, :date table.column :effort, :integer table.column :item_id, :integer ...
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
#!/sw/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
#!/sw/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/breakpointer'
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