code
stringlengths
1
1.73M
language
stringclasses
1 value
#!/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
#!/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/reaper'
Ruby
#!/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/destroy'
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/server'
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/plugin'
Ruby
class AddSignupCompleteToUsers < ActiveRecord::Migration def self.up add_column :users, :signup_complete, :boolean, :default => false, :null => false User.reset_column_information User.update_all("signup_complete='1'") end def self.down remove_column :users, :signup_complete end end
Ruby
class CreateEvents < ActiveRecord::Migration def self.up add_column :users, :manager, :boolean, :default => false create_table :events do |t| t.column :name, :string t.column :description, :text t.column :start_date, :date t.column :end_date, :date end end def self.down d...
Ruby
class CreateComments < ActiveRecord::Migration def self.up create_table :comments do |t| t.integer :user_id t.integer :event_id t.text :content t.timestamps end end def self.down drop_table :comments end end
Ruby
class AddAddressAndRequiredVolunteersToEvents < ActiveRecord::Migration def self.up add_column :events, :required_volunteers, :integer add_column :events, :address, :text add_column :events, :post_code, :string add_column :events, :map_coordinates, :string add_column :events, :contact_name, :strin...
Ruby
class CreateCallForWorkers < ActiveRecord::Migration def self.up create_table :call_for_workers do |t| t.text :message t.timestamps end create_table :call_for_workers_events, :id => false do |t| t.integer :event_id t.integer :call_for_worker_id end add_index :call...
Ruby
class AddLevelToAvailability < ActiveRecord::Migration def self.up add_column :availabilities, :level, :integer end def self.down remove_column :availabilities, :level end end
Ruby
class AddStateToEvents < ActiveRecord::Migration def self.up add_column :events, :state, :string, :default => 'new' end def self.down remove_column :events, :state end end
Ruby
class AddUserAttributes < ActiveRecord::Migration NEW_COLUMNS = { :first_name => :string, :last_name => :string, :address => :text, :home_phone => :string, :mobile_phone => :string, :allergies => :string, :can_drive => :boolean } def self.up NEW_COLUMNS.each do |column, type| ...
Ruby
class AddRemainingUserAttributes < ActiveRecord::Migration NEW_COLUMNS = { :post_town => :string, :post_code => :string, :has_own_car => :boolean, :dietary_needs => :string, # The following should only be editable by a manager :branch_joining_date => :date, :current_status => :string, ...
Ruby
class CreateAvailabilities < ActiveRecord::Migration def self.up create_table :availabilities do |t| t.integer :user_id t.integer :event_id end add_index :availabilities, :event_id add_index :availabilities, :user_id Availability.reset_column_information Attendance.find(:...
Ruby
class AddEventsPerYearToUser < ActiveRecord::Migration def self.up add_column :users, :events_per_year, :integer, :default => 0 end def self.down remove_column :users, :events_per_year end end
Ruby
class CreateUsers < ActiveRecord::Migration def self.up create_table "users", :force => true do |t| t.column :login, :string t.column :email, :string t.column :crypted_password, :string, :limit => 40 t.column :salt, :str...
Ruby
class AddManagerIdToCallForWorkers < ActiveRecord::Migration def self.up add_column :call_for_workers, :user_id, :integer end def self.down remove_column :call_for_workers, :user_id end end
Ruby
class CreateAttendances < ActiveRecord::Migration def self.up create_table :attendances do |t| t.column :event_id, :integer t.column :user_id, :integer t.column :state, :string end add_index :attendances, :event_id add_index :attendances, :user_id end def self.down remo...
Ruby
class CreateDeliverySuccesses < ActiveRecord::Migration def self.up create_table :delivery_successes do |t| t.integer :user_id t.integer :call_for_worker_id t.string :email t.timestamps end end def self.down drop_table :delivery_successes end end
Ruby
class CreateDeliveryErrors < ActiveRecord::Migration def self.up create_table :delivery_errors do |t| t.integer :call_for_worker_id t.integer :user_id t.string :email t.string :message t.timestamps end end def self.down drop_table :delivery_errors end end
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 != :false && current_user.signup_complete? end # Accesses the current user from the session. def curr...
Ruby
module AuthenticatedTestHelper # Sets the current user in the session from the user fixtures. def login_as(user) @request.session[:user] = user ? users(user).id : nil end def content_type(type) @request.env['Content-Type'] = type end def accept(accept) @request.env["HTTP_ACCEPT"] = accept en...
Ruby
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby 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/dispat...
Ruby
#!/usr/bin/env ruby 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 impaire...
Ruby
#!/usr/bin/env ruby # # 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
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby 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/dispat...
Ruby
#!/usr/bin/env ruby 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 impaire...
Ruby
#!/usr/bin/env ruby # # 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
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
class FilterGenerator attr_reader :foldersToBeKept @foldersToBeKept def initialize(file=".") @foldersToBeKept = Array.new @file = file self.generateFilter end def generateFilter if File.file?(@file) File.open(@file,"r") {|file| while line = file.gets @foldersToBeKep...
Ruby
require "application.rb" task :default do application = Application.new dirname = ENV["dirname"] time=ENV["time"] application.run(dirname,time) end
Ruby
require "find" require "fileutils" require "date_input_parser.rb" class FileDeleter def initialize(dirname,filter=FilterGenerator.new) @filter = filter @startDir = dirname @fileWithModifiedTimeCache = {} generateAbsolutePathFilters end def isModifiedBefore?(fileOrDirName, time) temp_time_a...
Ruby
require "file_deleter.rb" require "filter_generator.rb" class Application def run(dirname, time) filter = FilterGenerator.new("foldersToBeKept.txt") fileDeleter = FileDeleter.new(dirname,filter) fileDeleter.deleteFileAndDirModifiedBeforeSpecifiedDate(time) end end
Ruby
require "rubygems" require "active_support" class DateInputParser WEEK = "w" MONTH="m" DAY="d" def getAbsoluteTime(time) dateToBeChecked = getDateToBeChecked(time) absoluteTime = dateToBeChecked.year.to_s+"-"+dateToBeChecked.month.to_s+"-"+dateToBeChecked.day.to_s absoluteTime end def get...
Ruby
task :default do require 'rake/runtest' Rake.run_tests '**/test*.rb' end
Ruby
$:.unshift File.join(File.dirname(__FILE__),"..","lib") require "test/unit" require "filter_generator.rb" require "create_tree.rb" class FilterGeneratorTest < Test::Unit::TestCase def setup @configFile = "../lib/foldersToBeKept.txt" if !File.exists?(@configFile) File.new(@configFile) end end ...
Ruby
$:.unshift File.join(File.dirname(__FILE__),"..","lib") require "test/unit" require "rubygems" require "active_support" require "date_input_parser.rb" class TestDateInputParser < Test::Unit::TestCase @dateInputParser def setup @dateInputParser = DateInputParser.new end def test_back_time_by_months ...
Ruby
$:.unshift File.join(File.dirname(__FILE__),"..","lib") require "test/unit" require "find" require "fileutils" require "create_tree.rb" require "file_deleter.rb" require "filter_generator.rb" require "pathname.rb" class TestFileDeleter < Test::Unit::TestCase def setup @topdir = "topdir" @checktime = "2008-...
Ruby
$:.unshift File.join(File.dirname(__FILE__),"..","lib") require "test/unit" require "find" require "fileutils" require "create_tree.rb" require "file_deleter.rb" require "filter_generator.rb" require "pathname.rb" class TestFileDeleter < Test::Unit::TestCase def setup @topdir = "topdir" @checktime = "20...
Ruby
class CreateTree def create_tree(directories, parent = "..") directories.each_pair do|dir, files| path = File.join(parent,dir) Dir.mkdir path unless File.exist? path files.each do|filename| if filename.respond_to? :each_pair #is a subdirectory create_tree(filename, path) ...
Ruby
#!/usr/bin/env ruby require 'optparse' require 'ostruct' class ArgvOptionsParser def self.parse(args) options = OpenStruct.new options.classname = [] options.filenames = [] options.namespace = "" options.path = "" options.add_copyright = true opts = OptionParser.new do |op...
Ruby
#!/usr/bin/env ruby require 'optparse' require 'ostruct' class ArgvOptionsParser def self.parse(args) options = OpenStruct.new options.classname = [] options.filenames = [] options.namespace = "" options.path = "" options.add_copyright = true opts = OptionParser.new do |op...
Ruby
#Dummy class so the plugin code at the end of sms_notifier doesn't #complain # class CruiseControl class Log end end class Project def self.plugin (foo) end end
Ruby
require 'net/smtp' class SmsNotifier attr_accessor :recipients def initialize(project = nil) @recipients = [] end def build_finished(build) return if @recipients.empty? or not build.failed? notify "#{build.project.name} build #{build.label} failed", build.project.name end def build_fixed(bu...
Ruby
task :default => [:test] task :cruise => [:test] task :test do |t| test_files = FileList['*test*'] test_files.each do |file| if !system("ruby #{file}") exit 1 end end end
Ruby
require 'test/unit' require 'cruise_stubs' require 'sms_notifier' require 'rubygems' require 'net/smtp' require 'mocha' require 'action_mailer' class Test_Sms < Test::Unit::TestCase def setup smtp_settings = {:address =>"smtp.gmail.com", :port => 587, :domain...
Ruby
require 'test/unit' require 'cruise_stubs' require 'sms_notifier' require 'rubygems' require 'net/smtp' require 'mocha' class TestSmsNotifier < Test::Unit::TestCase def test_sms_notifier_doesnt_notify_on_build_failure #simulate the cruise_config.rb initializing recipients sms_notifier = SmsNotifier.new ...
Ruby
#!/usr/bin/ruby ################################################################################ ## File: clrm-package.rb ## Author: Henry Feild ## Date: 19-Feb-2013 Usage = " Usage: clrm-package.rb [options] Where: <core module file 1>[, <core module file 2>, ...] One or more JavaScript files wh...
Ruby
#!/usr/bin/ruby ################################################################################ ## File: configure.rb ## Author: Henry Feild ## Date: 27-Oct-2011 usage = " Usage: configure.rb [options] Copies the contents of the given input directory and replaces the variable names specified in the configura...
Ruby
#!/usr/bin/ruby ####################################################################### ## File: crowdlog2html.rb ## Date: 24-Jul-2011 usage = " Usage: crowdlog2html.rb <crowdlog> [<crowdlog 2> ... ] <crowdlog> should be a valid CrowdLog file, which means it has one JSON object per line. Each JSON object is eit...
Ruby
#!/usr/bin/ruby ################################################################################ ## File: clrm-package.rb ## Author: Henry Feild ## Date: 19-Feb-2013 Usage = " Usage: clrm-package.rb [options] Where: <core module file 1>[, <core module file 2>, ...] One or more JavaScript files wh...
Ruby
# Be sure to restart your server when you modify this file. # Add new inflection rules using the following format # (all these examples are active by default): # ActiveSupport::Inflector.inflections do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person',...
Ruby
# These settings change the behavior of Rails 2 apps and will be defaults # for Rails 3. You can remove this initializer when Rails 3 is released. if defined?(ActiveRecord) # Include Active Record class name as root for JSON serialized output. ActiveRecord::Base.include_root_in_json = true # Store the full clas...
Ruby
# Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf # Mime::Type.register_alias "text/html", :iphone
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 error repor...
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 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' # Specifies gem version of Rails to use when vendor/rails is not present RAILS_GEM_VERSION = '2.1...
Ruby
# Don't change this file! # Configure your app in config/environment.rb and config/environments/*.rb RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) module Rails class << self def boot! unless booted? preinitialize pick_boot.run end end def booted? ...
Ruby
ActionController::Routing::Routes.draw do |map| # The priority is based upon order of creation: first created -> highest priority. map.resources :pings do |ping| ping.resources :keyvalues end map.resources :messages map.resources :phones map.resources :placemarks # Sample of regular route: # ma...
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end
Ruby
module PingsHelper end
Ruby
module PlacemarksHelper end
Ruby
module MapHelper end
Ruby
module MessagesHelper end
Ruby
module KeyvaluesHelper end
Ruby
class Message < ActiveRecord::Base set_table_name "frontline_messages" set_inheritance_column :ruby_type set_primary_key "tid" acts_as_mappable belongs_to :ping, :foreign_key => :tid # def before_save # self.dateTimeP = "now" # end # getter for the "type" column def message_type self[:...
Ruby
class CrsForm < ActiveRecord::Base belongs_to :phone acts_as_mappable :latcolumnname => :latitude, :lngcolumnname => :longitude def message message = self.read_attribute("message") if message.nil? message = self.read_attribute("content").gsub("msg ","").gsub("Msg ","").gsub("message ","").gsub("M...
Ruby
class Tile < ActiveRecord::Base def size end end
Ruby
class MessageParts < ActiveRecord::Base belongs_to :phone acts_as_mappable :latcolumnname => :latitude, :lngcolumnname => :longitude #### GEOCODING FIELDS ##### def message message = self.read_attribute("message") if message.nil? message = self.read_attribute("content").gsub("msg ","").gsub("Msg...
Ruby
class Ping < ActiveRecord::Base belongs_to :phone acts_as_mappable :latcolumnname => :latitude, :lngcolumnname => :longitude # validates_presence_of :phone_id has_many :keyvalues def message message = self.read_attribute("message") if message.nil? message = self.read_attribute("content").gsub...
Ruby
class Keyvalue < ActiveRecord::Base end
Ruby
class Tweet < ActiveResource::Base # umm: # ActiveResource::Base.logger = RAILS_DEFAULT_LOGGER self.site = "http://twitter.com" self.user = "crsrapid" self.password = "crs123" # self.user = "mapthegame" # self.password = "poopies" # validates_uniqueness_of : # Get the latest 20 public statuses ...
Ruby
class Phone < ActiveRecord::Base has_many :pings def last_ping Ping.find_by_phone_id self.id, :order => "id DESC" end end
Ruby
class Placemark < ActiveRecord::Base end
Ruby
class PingsController < ApplicationController # GET /pings # GET /pings.xml def index @pings = Ping.find(:all, :limit => 50, :order => "id DESC") respond_to do |format| format.html # index.html.erb format.kml { render :template => "map/map.kml.erb", :layout => false } format.xml ...
Ruby
class CrsController < ApplicationController def index process_messages @pings = Ping.find :all, :conditions => {:ping_type => 3}, :limit => 30, :order => "id DESC" @submissions = CrsForm.find :all respond_to do |format| format.html { render :template => "crs/crs.html.erb", :layout => false } ...
Ruby
class MapController < ApplicationController def index @pings = Ping.find :all, :conditions => {:ping_type => 1}, :limit => 30, :order => "id DESC" respond_to do |format| format.html { render :template => "map/index", :layout => false } format.kml { render :template => "map/map.kml.erb", :layout =...
Ruby
class PlacemarksController < ApplicationController # GET /placemarks # GET /placemarks.xml def index @placemarks = Placemark.find(:all) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @placemarks } end end # GET /placemarks/1 # GET /placemarks/1.xml...
Ruby
class PhonesController < ApplicationController # GET /phones # GET /phones.xml def index @phones = Phone.find(:all) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @phones } end end # GET /phones/1 # GET /phones/1.xml def show @phone = Phone.fi...
Ruby
class MessagesController < ApplicationController # GET /messages # GET /messages.xml def index @messages = Message.find(:all) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @messages } end end # GET /messages/1 # GET /messages/1.xml def ...
Ruby
# Some change has been made by Vipin. # Filters added to this controller apply to all controllers in the application. # Likewise, all the methods added will be available for all controllers. class ApplicationController < ActionController::Base helper :all # include all helpers, all the time # See ActionControlle...
Ruby
class KeyvaluesController < ApplicationController def index @ping = Ping.find(params[:ping_id]) @keyvalues = @ping.keyvalues end def show @ping = Ping.find(params[:ping_id]) @keyvalue = @ping.keyvalues.find(params[:id]) end def new @ping = Ping.find(params[:ping_id]) @keyvalue = @pin...
Ruby
# Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require(File.join(File.dirname(__FILE__), 'config', 'boot')) require 'rake' require 'rake/testtask' require 'rake/rdoctask' require 'tasks/rails'
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/runner'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/benchmarker'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/request'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/profiler'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/performance/request'
Ruby