code
stringlengths
1
1.73M
language
stringclasses
1 value
#!/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/breakpointer'
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/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/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
#!/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/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/performance/benchmarker'
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/benchmarker'
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/generate'
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end
Ruby
module EventsHelper end
Ruby
module PeopleHelper end
Ruby
module SessionsHelper end
Ruby
module PlacesHelper end
Ruby
class Place < ActiveRecord::Base has_many :memberships, :dependent => true has_many :people, :through => :memberships acts_as_mappable acts_as_ferret :fields => [:org, :locality, :postal_code, :region] before_validation_on_create :geocode_address private def geocode_address geo = GeoKit::...
Ruby
require 'digest/sha1' class Person < ActiveRecord::Base # Virtual attribute for the unencrypted password attr_accessor :password validates_presence_of :login, :email, :if => :not_openid? validates_presence_of :given_name, :family_name validates_presence_of :password, :if => :p...
Ruby
class Event < ActiveRecord::Base end
Ruby
class PeoplePlaces < ActiveRecord::Base belongs_to :person belongs_to :place end
Ruby
class EventsController < ApplicationController # GET /events # GET /events.xml def index # @events = Event.find(:all) respond_to do |format| format.html # index.rhtml format.xml { render :xml => @events.to_xml } end end # GET /events/1 # GET /events/1.xml def show # @event =...
Ruby
class PlacesController < ApplicationController # TODO: require admin login for edit, update (for moderation purposes) # include microformat helper - http://blog.labnotes.org/2006/08/25/microformats-helper-for-ruby-on-rails/ helper :microformat # GET / def homepage @places = Place.find(:all) m...
Ruby
# This controller handles the login/logout function of the site. class SessionController < ApplicationController def new end def create if using_open_id? || !params[:wordpress].blank? || !params[:livejournal].blank? || !params[:aim_screenname].blank? params[:openid_url] = "http://#{params[:wordpress]...
Ruby
# 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 htpasswd :user => ADMIN_USERNAME, :pass => ADMIN_PASSWORD if RAILS_ENV == 'staging' include Authentic...
Ruby
# TODO: replace authentication with Acts as Authentication + OpenID # http://www.bencurtis.com/archives/2007/03/rails-openid-and-acts-as-authenticated/ require_gem 'ruby-openid' class OpenidsController < ApplicationController # GET # show a form requesting the user's OpenID def new end # GET # begin the...
Ruby
class PeopleController < ApplicationController before_filter :restrict_access_to_owner, :only => [:edit, :update, :activate] def create @person = Person.new(params[:person]) @person.save! self.current_person = @person redirect_back_or_default('/') flash[:notice] = "Thanks for signing up!" r...
Ruby
ActionController::Routing::Routes.draw do |map| # homepage map.connect '', :controller => "places", :action => "homepage" map.resources :places, :collection => {:search => :get} map.resources :people, :collection => {:search => :get} map.resources :events, :collection => {:search => ...
Ruby
Capistrano::Configuration.instance(:must_exist).load do namespace :accelerator do namespace :smf do desc "Adds a SMF for the application (mongrel)" task :create, :roles => :app do puts "set variables" service_name = application working_directory = current_path ...
Ruby
require 'erb' require 'config/accelerator/accelerator_tasks' set :application, "coworkination" set :repository, "" set :user, 'admin' # this is the ssh user set :deploy_to, "/home/#{user}/rails/apps/#{application}" # i like this location because the home directory is on the SAN and you can increase it's allocation ea...
Ruby
# Don't change this file. Configuration is done in config/environment.rb and config/environments/*.rb unless defined?(RAILS_ROOT) root_path = File.join(File.dirname(__FILE__), '..') unless RUBY_PLATFORM =~ /(:?mswin|mingw)/ require 'pathname' root_path = Pathname.new(root_path).cleanpath(true).to_s end ...
Ruby
# Be sure to restart your web server when you modify this file. # Uncomment below to force Rails into production mode when # you don't control web/app server and can't set it the proper way # ENV['RAILS_ENV'] ||= 'production' # Specifies gem version of Rails to use when vendor/rails is not present RAILS_GEM_VERSION ...
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 # 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
# 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
module AuthenticatedSystem protected # Returns true or false if the user is logged in. # Preloads @current_person with the user model if they're logged in. def logged_in? current_person != :false end # Accesses the current person from the session. Set it to :false if login fails # ...
Ruby
module AuthenticatedTestHelper # Sets the current person in the session from the person fixtures. def login_as(person) @request.session[:person] = person ? people(person).id : nil end def authorize_as(user) @request.env["HTTP_AUTHORIZATION"] = user ? "Basic #{Base64.encode64("#{users(user).login}:test"...
Ruby
## ## General rules for the SilverStripe CMS as a whole. They mostly have to do with the LeftAndMain ## interface # Match general CMS tabs, ModelAdmin needs another system Given /I click on the "([^\"]*)" tab/ do |tab| found = nil links = @salad.browser.links() links.each {|link| if /^tab-.+/.match(link.id) then...
Ruby
## FIXTURE GENERATON Given /^the site can be edited by the "([^\"]*)" group$/i do |arg1| pending end Given /^the "([^\"]*)" page can be edited by the "([^\"]*)" group$/i do |arg1, arg2| pending end Given /a "(.*)" page called "(.*)" as a child of "(.*)"/i do |type, title, parent| Given "I click the \"#{paren...
Ruby
# Log in Given /log in as (.*)$/ do |user| Given "I fill out the log in form with user \"#{user}\" and password \"password\"" And 'I see "You\'re logged in as"' end Given /log into the CMS as (.*)/ do |user| Given "I log in as #{user}" And "I visit admin/" And "I load the root node" end Given /log out$/ do ...
Ruby
# Steps definitions for security # Fixture instantiation Given /a "(.*)" group/ do |group| Given 'I visit admin/security' And 'I click the "Security Groups" link' And 'I click the "Create" button' And "I put \"#{group}\" in the \"Title\" field" And 'I click the "Save" button' end Given /a user called "(.*)...
Ruby
## ## Step definitions for testing the front-end site ## Given /I go to the draft site/ do pending Given 'I click the "viewStageSite" link' # |''element''|//a[@id="viewStageSite"]|''exists''| # |''checking timeout''|@{fast_checking_timeout}| # |''optionally''|''element''|//a[@id="viewStageSite"][@style=""]|''e...
Ruby
def loadFixture(fileName) if $baseURL and $browser then $browser.goto $baseURL + "dev/tests/sessionloadyml?fixture=" + fileName + "&flush=1" else fail("No \$baseUrl or \$browser found") end end def startSession # Reset database if $baseURL and $browser then $browser.goto $baseURL + 'dev/tests/endsession' e...
Ruby
# # To change this template, choose Tools | Templates # and open the template in the editor. require 'rubygems' require 'rake' require 'rake/clean' require 'rake/gempackagetask' require 'rake/rdoctask' require 'rake/testtask' spec = Gem::Specification.new do |s| s.name = 'mars_voyages' s.version = '0.0.1' s....
Ruby
class SimpleTime def initialize(hour=0, minute=0) @hour = hour.to_i+(minute.to_i/60) @minute = minute.to_i%60 end def hour return @hour.to_i end def hour=(hour) @hour = hour end def minute return @minute.to_i end def minute=(minute) @minute = minute end ...
Ruby
class MarsException < Exception end class AdameusException < MarsException def to_s return super + " (AdameusException)" end end
Ruby
class Booking def initialize(booking_code, date, departure, duration, flightnr, category, gender, first_name, surname, price) @booking_code = booking_code @connection = Connection.new(flightnr, departure, duration, date) @category = category @gender = gender @first_name = first_name.strip ...
Ruby
class Airport def initialize(code, city, country) @code = code @city = city @country = country end def code return @code end def city return @city end def country return @coutnry end def equal?(airport) return @code === airport.code end def to_s n...
Ruby
require 'net/telnet' require 'date' load 'airport.rb' load 'booking.rb' load 'pricing.rb' load 'connection.rb' load 'simple_time.rb' load 'multi_hop_flight.rb' load 'multi_hop_connection.rb' load 'exceptions.rb' class Executor def self.run(command) host = Net::Telnet.new('Host' => 'localhost', 'Port' => 12111...
Ruby
class Pricing def initialize(seats, price) @seats = seats.to_i @price = price.to_i end def seats return @seats end def price return @price end end
Ruby
load 'executor.rb' class MarsVoyages #Print out the version of Adameus def version cur_version = Executor.version puts 'Version: ' + cur_version.to_s return cur_version.to_f end #Print out all the airlines def airlines puts 'Airlines:' airlines_map = Executor.airlines airlines_map...
Ruby
class MultiHopFlight def initialize(hops=[]) @hops = hops end def add_hop(airport) @hops << airport end # @return True if this multihop flight visits the given airport def visits?(airport) return @hops.include?(airport) end def from return @hops.first end # @return The destination ...
Ruby
class Connection def initialize(flightnr, departure, duration,day) @flightnr = flightnr @departure = departure @duration = duration @day = day end def flightnr return @flightnr end def departure return @departure end def duration return @duration end # @return...
Ruby
load 'mars_voyages.rb' mv = MarsVoyages.new if ARGV[0] != nil if File.exist?(ARGV[0]) i = 1 File.read(ARGV[0]).each_line do |line| if line.length > 1 begin mv.instance_eval(line, ARGV[0]) rescue MarsException => e puts "Error occured on line " + i.to_s + ": " + e...
Ruby
class MultiHopConnection def initialize(multi_hop_flight) @m_flight = multi_hop_flight @m_connections = [] end def add_connection(connection) @m_connections << connection end def m_flight return @m_flight end # @return a clone of the list with the connections def connections return...
Ruby
#!/usr/bin/ruby if ARGV.length < 2 puts "Usage: ruby sign_update.rb update_archive private_key" exit end puts `openssl dgst -sha1 -binary < "#{ARGV[0]}" | openssl dgst -dss1 -sign "#{ARGV[1]}" | openssl enc -base64`
Ruby
#!/usr/bin/ruby ["dsaparam.pem", "dsa_priv.pem", "dsa_pub.pem"].each do |file| if File.exist? file puts "There's already a #{file} here! Move it aside or be more careful!" end end `openssl dsaparam 2048 < /dev/urandom > dsaparam.pem` `openssl gendsa dsaparam.pem -out dsa_priv.pem` `openssl dsa -in dsa_priv.pem ...
Ruby
#!/usr/bin/ruby if ARGV.length < 2 puts "Usage: ruby sign_update.rb update_archive private_key" exit end puts `openssl dgst -sha1 -binary < "#{ARGV[0]}" | openssl dgst -dss1 -sign "#{ARGV[1]}" | openssl enc -base64`
Ruby
#!/usr/bin/ruby ["dsaparam.pem", "dsa_priv.pem", "dsa_pub.pem"].each do |file| if File.exist? file puts "There's already a #{file} here! Move it aside or be more careful!" end end `openssl dsaparam 2048 < /dev/urandom > dsaparam.pem` `openssl gendsa dsaparam.pem -out dsa_priv.pem` `openssl dsa -in dsa_priv.pem ...
Ruby
class CreateUsers < ActiveRecord::Migration def up create_table :users do |t| t.string :profile_id t.string :email t.string :refresh_token end add_index :users, :profile_id end def down drop_table :users end end
Ruby
# Copyright (C) 2012 Google Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writ...
Ruby
source :gemcutter gem 'sinatra', :require => 'sinatra/base' gem 'thin', '~> 1.3' gem 'pg' gem 'sinatra-activerecord' gem 'google-api-client', '>= 0.4.4', :require => 'google/api_client' group :development do gem 'rake' gem 'sqlite3-ruby' end
Ruby
require 'sinatra.rb' # Sinatra defines #set at the top level as a way to set application configuration set :run, false set :env, (ENV['RACK_ENV'] ? ENV['RACK_ENV'].to_sym : :development) require './main' run Sinatra::Application
Ruby
require 'sinatra/activerecord/rake' require './main'
Ruby
require 'sinatra' require 'fileutils' enable :sessions PATH_TO_RAILS_DB_DIR=File.join('', 'home', 'jc155857', 'Documents', 'SVN', 'cp2013-zoo-monitoring-software', 'Web-CP2013-Zoo', 'db') #PATH_TO_RAILS_DB_DIR=File.join('', 'Users', 'robert', 'Documents', 'SVN', 'cp2013-zoo-monitoring-software', 'Web-CP2013-Zoo', 'db...
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
# 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. WebCp2013Zoo::Application.config.session_store :cookie_store, key: '_Web-CP2013-Zoo_session' # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information # (create the session table w...
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
WebCp2013Zoo::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 config.a...
Ruby
WebCp2013Zoo::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 the w...
Ruby
WebCp2013Zoo::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 the te...
Ruby
# Load the rails application require File.expand_path('../application', __FILE__) # Initialize the rails application WebCp2013Zoo::Application.initialize!
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
WebCp2013Zoo::Application.routes.draw do resources :employees do resources :messages end resources :animals resources :home, only: [:index] resources :zoo_setup_ui, only: [:index] resources :cages do resources :entrances do resources :doors do end end end # The priority is...
Ruby
module AdminHelper end
Ruby
module ApplicationHelper end
Ruby
module EnclosuresHelper end
Ruby
module EntrancesHelper end
Ruby
module DoorsHelper end
Ruby
module HomeHelper end
Ruby
module MessagesHelper end
Ruby