code
stringlengths
1
1.73M
language
stringclasses
1 value
#!/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/console'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../config/boot' require 'commands/process/reaper'
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/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
#!/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 CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.string :user_name t.string :user_email t.string :user_password t.boolean :user_admin, :default => false t.text :profile, :text t.timestamps end end def self.down drop_table :users end end
Ruby
class AddSaltToManager < ActiveRecord::Migration def self.up rename_column :managers, :m_password, :encrypted_password add_column :managers, :salt, :string end def self.down remove_column :managers, :salt rename_column :managers, :encrypted_password, :m_password end end
Ruby
class CreateTeams < ActiveRecord::Migration def self.up create_table :teams do |t| t.string :name t.integer :number t.string :position t.integer :goals t.integer :assists t.integer :points t.timestamps end end def self.down drop_table :teams end end
Ruby
class CreateSchedules < ActiveRecord::Migration def self.up create_table :schedules do |t| t.date :game_date t.string :game_type t.string :opponent t.timestamps end end def self.down drop_table :schedules end end
Ruby
class AddSaltToUsers < ActiveRecord::Migration def self.up rename_column :users, :user_password, :encrypted_password add_column :users, :salt, :string end def self.down remove_column :users, :salt rename_column :users, :encrypted_password, :user_password end end
Ruby
class CreateTickets < ActiveRecord::Migration def self.up create_table :tickets do |t| t.float :ticket_price t.float :ticket_amount t.integer :ticket_section t.integer :ticket_row t.integer :ticket_seat t.integer :game_id t.integer :user_id t.timestamps end add_index :tickets, :game_id add_ind...
Ruby
class CreateManagers < ActiveRecord::Migration def self.up create_table :managers do |t| t.string :m_name t.string :m_password t.text :m_profile, :text t.boolean :m_admin, :default => true t.timestamps end end def self.down drop_table :managers end end
Ruby
class CreateNews < ActiveRecord::Migration def self.up create_table :news do |t| t.string :title t.text :Contents t.timestamps end end def self.down drop_table :news end end
Ruby
class CreateEvents < ActiveRecord::Migration def self.up create_table :events do |t| t.date :event_date t.string :event_location t.text :event_details t.timestamps end end def self.down drop_table :events end end
Ruby
#!/usr/bin/ruby1.8 #!/usr/local/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/dispatcher" -- otherwise performan...
Ruby
#!/usr/bin/ruby1.8 #!/usr/local/bin/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/...
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
# This runs the experiments as jobs on Dumbledore. The output of this # program is CSV values in the following format: # # num_procs, num_threads, a_rows, a_cols, b_cols, base_case_size, runtime require 'fileutils' require 'csv' EXPERIMENTS_DIR = "experiments" N = 70 MAX_NODES = 6 MAX_THREAD_POW = 3 a_rows = N a...
Ruby
# This runs main. require 'fileutils' output = "main_output.txt" File.unlink(output) if File.exist?(output) rval = %x{qsub main_test.sh -o #{output} } puts "running main_test.sh" while !File.exist?(output) sleep(0.1) end text = File.open(output, "r") { |f| f.read } puts text File.unlink(output)
Ruby
#!/usr/bin/env ruby def usage $stderr.puts "USAGE: #{File.basename($0)} <file> <size>" $stderr.puts "-"*40 $stderr.puts " file The file to pad with zero bytes" $stderr.puts " size The total size in bytes to pad file to*" $stderr.puts $stderr.puts "(*) If file is already size or more byte...
Ruby
#!/usr/bin/env ruby # This program scans a set of data from a MAG stripe and looks for pieces of # a provided serial number in the contents. # Additionally, it searches for the existance of a monetary value stored in # the data. def usage $stderr.puts "USAGE: #{File.basename($0)} <card file> <sn>" $stderr....
Ruby
#!/usr/bin/env ruby def usage $stderr.puts "USAGE: #{File.basename($0)} <serial numbers file>" $stderr.puts "-"*40 $stderr.puts " serial number file File with card to serial number map" $stderr.puts exit 42 end snfile = ARGV.shift || usage begin fdata = File.new(snfile, "rb") rescue $s...
Ruby
#!/usr/bin/env ruby # This program scans a set of data from a MAG stripe and looks for pieces of # a provided serial number in the contents. # Additionally, it searches for the existance of a monetary value stored in # the data. def usage $stderr.puts "USAGE: #{File.basename($0)} <card file> <sn>" $stderr....
Ruby
#!/usr/bin/env ruby def usage $stderr.puts "USAGE: #{File.basename($0)} <file> <size>" $stderr.puts "-"*40 $stderr.puts " file The file to pad with zero bytes" $stderr.puts " size The total size in bytes to pad file to*" $stderr.puts $stderr.puts "(*) If file is already size or more byte...
Ruby
#!/usr/bin/env ruby def usage $stderr.puts "USAGE: #{File.basename($0)} <serial numbers file>" $stderr.puts "-"*40 $stderr.puts " serial number file File with card to serial number map" $stderr.puts exit 42 end snfile = ARGV.shift || usage begin fdata = File.new(snfile, "rb") rescue $s...
Ruby
#!/usr/bin/env ruby def is_upper c c >= 65 && c <= 90 end def is_lower c c >= 97 && c <= 122 end def is_punct c [32, 33, 34, 39, 46, 63].include? c end def valid_string s, lax if lax return s =~ /^[[:print:]]+$/ else s.length.times do |i| return false unless (is_upper...
Ruby
#!/usr/bin/env ruby def is_upper c c >= 65 && c <= 90 end def is_lower c c >= 97 && c <= 122 end def is_punct c [32, 33, 34, 39, 46, 63].include? c end def valid_string s, lax if lax return s =~ /^[[:print:]]+$/ else s.length.times do |i| return false unless (is_upper...
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
# Use this hook to configure devise mailer, warden hooks and so forth. # Many of these configuration options can be set straight in your model. Devise.setup do |config| # ==> Mailer Configuration # Configure the e-mail address which will be shown in Devise::Mailer, # note that it will be overwritten if you use yo...
Ruby
class ActiveRecord::Base attr_accessible attr_accessor :accessible private def mass_assignment_authorizer(role = :default) if accessible == :all self.class.protected_attributes else super + (accessible || []) end end end
Ruby
# Use this setup block to configure all options available in SimpleForm. SimpleForm.setup do |config| # Wrappers are used by the form builder to generate a # complete input. You can remove any component from the # wrapper, change the order or even add your own to the # stack. The options given below are used to...
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
# Be sure to restart your server when you modify this file. # Your secret key for verifying the integrity of signed cookies. # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attac...
Ruby
# Be sure to restart your server when you modify this file. # # This file contains settings for ActionController::ParamsWrapper which # is enabled by default. # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do wrap_parameters ...
Ruby
# Be sure to restart your server when you modify this file. Cs638OrgOrganizer::Application.config.session_store :cookie_store, key: '_cs638_org_organizer_session' # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information # (create the sessi...
Ruby
# Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } # You can also remove all the silencers if you're trying to debug a probl...
Ruby
Cs638OrgOrganizer::Application.configure do # Settings specified here will take precedence over those in config/application.rb # Code is not reloaded between requests config.cache_classes = true # Full error reports are disabled and caching is turned on config.consider_all_requests_local = false con...
Ruby
Cs638OrgOrganizer::Application.configure do # Settings specified here will take precedence over those in config/application.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 ...
Ruby
Cs638OrgOrganizer::Application.configure do # Settings specified here will take precedence over those in config/application.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 t...
Ruby
# Load the rails application require File.expand_path('../application', __FILE__) # Initialize the rails application Cs638OrgOrganizer::Application.initialize! ActionMailer::Base.smtp_settings = { :address => "smtp.gmail.com", :port => 25, :user_name => "cs638khk", :password => "KHKorgFTW", :authenticat...
Ruby
require 'rubygems' # Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])
Ruby
require File.expand_path('../boot', __FILE__) require 'rails/all' if defined?(Bundler) # If you precompile assets before deploying to production, use this line Bundler.require(*Rails.groups(:assets => %w(development test))) # If you want your assets lazily compiled in production, use this line # Bundler.requi...
Ruby
Cs638OrgOrganizer::Application.routes.draw do resources :inventoryitems devise_for :users resources :events resources :duties match 'duties/assign/:id' => 'duties#assign', :as => :assign_duty match 'duties/assignment/:id' => 'duties#assignment', :as => :assignment_duty resources :positions match '...
Ruby
module ApplicationHelper def sortable(column, title = nil) title ||=column.titleize direction = column == sort_column && sort_direction == "asc" ? "desc" : "asc" link_to title, params.merge(:sort =>column, :direction => direction, :page => nil) end end
Ruby
module EventsHelper end
Ruby
module UsersHelper def resource_name :user end def resource @resource ||= User.new end def devise_mapping @devise_mapping ||= Devise.mappings[:user] end end
Ruby
module DutiesHelper end
Ruby
module Admin::UsersHelper end
Ruby
module Admin::PositionsHelper end
Ruby
module PositionsHelper end
Ruby
module InventoryitemsHelper end
Ruby
class Event <ActiveRecord::Base #belongs_to :user # has_and_belongs_to_many :users validates :title, :description, :location, :presence=> true validates :formality_lvl, :start_date, :end_date, :presence=> true validates :start_date, :date => { :after => DateTime.now - 1.minute } validates :end_date, :...
Ruby
class Duty < ActiveRecord::Base belongs_to :user belongs_to :assigned_user, :class_name => "User", :foreign_key => 'assigner_id' # user who created the duty has_and_belongs_to_many :users validates :title, :penalty, :presence=> true; validates :deadline, :date => { :after => DateTime.now - 1.day } attr_...
Ruby
class Position < ActiveRecord::Base #has_many :users, :through => :position_assignments attr_accessible :title, :description, :addEvents, :addDuties, :addItems, :user_ids has_and_belongs_to_many :users validates :title, :presence => true end
Ruby
class User < ActiveRecord::Base # Include default devise modules. Others available are: # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable # Setup accessible (or protect...
Ruby
class Inventoryitem < ActiveRecord::Base validates :name, :cost, :count, :presence=> true; validates :cost, :count, :numericality => true; validates :cost, :format => { :with => /^\d+\.?\d?\d?$/ } validates :count, :format => { :with => /^\d+$/ } attr_accessible :cost, :count, :name def self.search(...
Ruby
class DutiesController < ApplicationController #before_filter :authenticate_user! # GET /duties # GET /duties.json def index @status = ["Active", "Failed", "Complete"] @search = Duty.search(params[:search]) @duties = @search.all() respond_to do |format| format.html # index.html.erb ...
Ruby
class InventoryitemsController < ApplicationController # GET /inventoryitems # GET /inventoryitems.json helper_method :sort_column, :sort_direction def index @inventoryitems = Inventoryitem.search(params[:search]).order(sort_column + " " + sort_direction).paginate(:per_page => 10, :page => params[:page]) ...
Ruby
class Admin::HomeController < ApplicationController before_filter :authenticate_user! before_filter do redirect_to events_path unless current_user && current_user.admin? end # GET /admin.json def index respond_to do |format| format.html # index.html.erb format.json { render json: :admin } ...
Ruby
class Admin::PositionsController < ApplicationController before_filter :authenticate_user! before_filter do redirect_to events_path unless current_user && current_user.admin? end # GET /positions # GET /positions.json def index @positions = Position.all respond_to do |format| format.html...
Ruby
class Admin::UsersController < ApplicationController before_filter :authenticate_user! before_filter do redirect_to events_path unless current_user && current_user.admin? end # GET /users # GET /users.json def index @users = User.order("last_name").all respond_to do |format| format.html # inde...
Ruby
class EventsController < ApplicationController #before_filter :authenticate_user! #specify which calendar to use @@cal_id = "cs638khk@gmail.com" #actual #@@cal_id = "tc3e71d7t5jm9a2q52j9tqepqo@group.calendar.google.com" #dev # create session with Google @@service = GCal4Ruby::Service.new @...
Ruby
class ApplicationController < ActionController::Base protect_from_forgery before_filter :authenticate_user! Time.zone = "America/Chicago" end
Ruby
class UsersController < ApplicationController before_filter :authenticate_user! # GET /users # GET /users.json def index @users = User.order("last_name").all respond_to do |format| format.html # index.html.erb format.json { render json: @users } end end # GET /users/1 # GET /user...
Ruby
class UserConfirmation < ActionMailer::Base default :from => "cs638khk@gmail.com" def registration_email(user, password) @user = user @url = "http://orgorganizer638.herokuapp.com/users/sign_in" @password = password mail(:to => user.email, :subject => "Invited to join our OrgOrganizer") do |format...
Ruby
class DutyAssignment < ActionMailer::Base default :from => "cs638khk@gmail.com" def assignment_email(user, assigned_by, duty) @user = user @assigned_by = assigned_by @duty = duty @url = "http://orgorganizer638.herokuapp.com/duties" mail(:to => user.email, :subject => "ORGORGANIZER: A New Duty...
Ruby
#!/usr/bin/env rake # 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.expand_path('../config/application', __FILE__) Cs638OrgOrganizer::Application.load_tasks
Ruby
#!/usr/bin/env ruby # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. APP_PATH = File.expand_path('../../config/application', __FILE__) require File.expand_path('../../config/boot', __FILE__) require 'rails/commands'
Ruby
source 'https://rubygems.org' gem 'rails', '3.2.2' # Bundle edge Rails instead: # gem 'rails', :git => 'git://github.com/rails/rails.git' gem 'pg' gem 'thin' gem 'foreman' gem 'gcal4ruby' gem 'capybara' gem 'simple_form' gem 'best_in_place' gem 'will_paginate' gem 'date_validator' gem 'meta_search' group :test, :dev...
Ruby
class CreateDuties < ActiveRecord::Migration def change create_table :duties do |t| t.string :title t.text :description t.timestamps end end def down drop_table :duties end end
Ruby
class AddPermissionsToPositions < ActiveRecord::Migration def change add_column :positions, :addEvents, :boolean, :default => false add_column :positions, :addDuties, :boolean, :default => false add_column :positions, :addItems, :boolean, :defualt => false end end
Ruby
class CreateUsersDutiesJoin < ActiveRecord::Migration def up create_table :duties_users, :id => false do |t| # t.integer "user_id" # t.integer "duty_id" t.column :duty_id, :integer t.column :user_id, :integer end # add_index :duties_users, ["user_id", "duty_id"] end def down ...
Ruby
class AddStatusToDuties < ActiveRecord::Migration def change add_column :duties, :status, :integer end def down remove_column :duties, :status end end
Ruby
class CreatePositionsUsersJoin < ActiveRecord::Migration def up create_table 'positions_users', :id => false do |t| t.column :position_id , :integer t.column :user_id, :integer end end def down drop_table :positions_users end end
Ruby
class CreateInventoryitems < ActiveRecord::Migration def change create_table :inventoryitems do |t| t.string :name t.decimal :cost t.integer :count t.timestamps end end end
Ruby
class AddAdminToUsers < ActiveRecord::Migration def change add_column :users, :admin, :boolean end def down remove_column :users, :admin end end
Ruby
class AddDeviseToUsers < ActiveRecord::Migration def self.up change_table(:users) do |t| ## Database authenticatable t.string :encrypted_password, :null => false, :default => '', :limit => 128 ## Recoverable t.string :reset_password_token t.datetime :reset_password_sent_at ...
Ruby
class CreateEvents < ActiveRecord::Migration def change create_table :events do |t| t.string :title t.text :description t.timestamps end end def down drop_table :events end end
Ruby
class AddAssignedUserIdToDuties < ActiveRecord::Migration def change add_column :duties, :assigner_id, :integer #id of the officer that assigned the duty end def down remove_column :duties, :assigner_id end end
Ruby
class AddEventIdToEvents < ActiveRecord::Migration def change add_column :events, :event_id, :string end def down remove_column :events, :event_id end end
Ruby
class CreateUsers < ActiveRecord::Migration def change create_table :users do |t| t.string :first_name t.string :last_name t.string :password t.string :email t.timestamps end end def down drop_table :users end end
Ruby
class AddFieldsToEvents < ActiveRecord::Migration def change add_column :events, :start_date, :datetime add_column :events, :end_date, :datetime add_column :events, :formality_lvl, :string add_column :events, :owner, :integer add_column :events, :location, :string end def down remo...
Ruby
class AddFieldsToDuties < ActiveRecord::Migration def change add_column :duties, :deadline, :date add_column :duties, :user_id, :integer add_column :duties, :penalty, :string add_column :duties, :confirmation, :boolean add_index :duties, :user_id end def down remove_index :duti...
Ruby
class CreatePositions < ActiveRecord::Migration def change create_table :positions do |t| t.string :title t.string :description t.timestamps end end def down drop_table :positions end end
Ruby
# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel...
Ruby
# This file is copied to spec/ when you run 'rails generate rspec:install' require 'cover_me' ENV["RAILS_ENV"] ||= 'development' require File.expand_path("../../config/environment", __FILE__) require 'rspec/rails' require 'rspec/autorun' require 'capybara/rspec' # Requires supporting ruby files with custom matchers and...
Ruby
RSpec.configure do |config| config.include Devise::TestHelpers, :type => :controller end
Ruby
module ControllerMacros def login_user before(:each) do @request.env["devise.mapping"] = Devise.mappings[:user] user = FactoryGirl.create(:user) sign_in user end end end
Ruby
FactoryGirl.define do factory :user, class: User do sequence(:email) { |n| "foo#{n}@foobar.com" } password "foobar" first_name "Bob" last_name "Dabolina" admin true end factory :event, class: Event do title "my Event" description "fun things" start_date DateTime.now e...
Ruby
namespace :cover_me do desc "Generates and opens code coverage report." task :report do require 'cover_me' CoverMe.complete! end end task :test do Rake::Task['cover_me:report'].invoke end task :spec do Rake::Task['cover_me:report'].invoke end
Ruby
# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run Cs638OrgOrganizer::Application
Ruby
require_relative '../../app/controllers/users_controller.rb' #require_relative '../app/models/postion.rb' #require_relative '../app/models/duty.rb' #require_relative '../app/models/event.rb' #this website seems to know whats up: #http://blog.flame.org/2009/11/19/how-i-test-ruby-on-rails-with-rspec-and-cucumber.html ...
Ruby