code
stringlengths
1
1.73M
language
stringclasses
1 value
class CreateUsers < ActiveRecord::Migration def self.up create_table :users do |t| t.column 'username', :string t.column 'crypted_password', :string t.column 'first_name', :string t.column 'last_name', :string t.column 'email', :string t.column 'description', :string t.co...
Ruby
class CreateCourses < ActiveRecord::Migration def self.up create_table :courses do |t| t.column 'full_name', :string, :null => false, :limit => 100 t.column 'short_name', :string, :null => false, :limit => 10 t.column 'description', :text t.column 'started_at', :datetime ...
Ruby
ENV["RAILS_ENV"] = "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'test_help' class Test::Unit::TestCase # Transactional fixtures accelerate your tests by wrapping each test method # in a transaction that's rolled back on completion. This ensures that the # test datab...
Ruby
#!/usr/bin/ruby1.8 require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT) # If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like: # "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispatcher" -- otherwise performance is severely impaired...
Ruby
#!/usr/bin/ruby1.8 # # You may specify the path to the FastCGI crash log (a log of unhandled # exceptions which forced the FastCGI instance to exit, great for debugging) # and the number of requests to process before running garbage collection. # # By default, the FastCGI crash log is RAILS_ROOT/log/fastcgi.crash.log #...
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/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
#!/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 $LOAD_PATH.unshift File.dirname(__FILE__) + '/../../rspec/lib' # For svn $LOAD_PATH.unshift File.dirname(__FILE__) + '/../vendor/plugins/rspec/lib' # For rspec installed as plugin require 'rubygems' require 'drb/drb' require 'rbconfig' require 'spec' # This is based on Florian Weber's TDDMate modu...
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 $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../vendor/plugins/rspec/lib")) require 'spec' ::Spec::Runner::CommandLine.run(ARGV, STDERR, STDOUT, true, true)
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 $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../vendor/plugins/rspec/lib")) require 'spec' ::Spec::Runner::CommandLine.run(ARGV, STDERR, STDOUT, true, true)
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 $LOAD_PATH.unshift File.dirname(__FILE__) + '/../../rspec/lib' # For svn $LOAD_PATH.unshift File.dirname(__FILE__) + '/../vendor/plugins/rspec/lib' # For rspec installed as plugin require 'rubygems' require 'drb/drb' require 'rbconfig' require 'spec' # This is based on Florian Weber's TDDMate modu...
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
# This file is copied to ~/spec when you run 'ruby script/generate rspec' # from the project root directory. ENV["RAILS_ENV"] ||= "test" require File.expand_path(File.dirname(__FILE__) + "/../config/environment") require 'spec/rails' Spec::Runner.configure do |config| config.use_transactional_fixtures = true confi...
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper def login_info if session[:user_id] "You are logged in as #{session[:user_id].full_name}" else "You are not logged in" end end def login_or_logout if session[:user_id] ...
Ruby
module LoginHelper end
Ruby
module UsersHelper end
Ruby
module CoursesHelper end
Ruby
module HomeHelper end
Ruby
class Course < ActiveRecord::Base validates_presence_of :full_name, :short_name, :message => 'is required' validates_length_of :full_name, :minimum => 3, :message => 'must have at least %d characters' validates_length_of :full_name, :maximum => 100, :message => 'must have at most %d characters' validates_length...
Ruby
require 'digest/sha1' class User < ActiveRecord::Base attr_accessor :password validates_presence_of :username, :first_name, :last_name, :email, :message => 'is required' validates_presence_of :password, :if => :password_required? validates_length_of :first_name, :last_name, :minimum => 2, :message =>...
Ruby
class LoginController < ApplicationController before_filter :authorize, :except => :login def login if request.get? session[:user_id] = nil @user = User.new else @user= User.new(params[:user]) logged_in_user = @user.try_to_login if logged_in_user session[:user_id] = lo...
Ruby
class HomeController < ApplicationController layout 'home' def index end end
Ruby
class UsersController < ApplicationController layout 'home' before_filter :authorize def index list render :action => 'list' end # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to => {...
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 # Pick a unique cookie name to distinguish our session data from others' session :session_key => '_astra_sess...
Ruby
class CoursesController < ApplicationController layout 'home' before_filter :authorize def index list render :action => 'list' end # GETs should be safe (see http://www.w3.org/2001/tag/doc/whenToUseGet.html) verify :method => :post, :only => [ :destroy, :create, :update ], :redirect_to =>...
Ruby
ActionController::Routing::Routes.draw do |map| # The priority is based upon order of creation: first created -> highest priority. # Sample of regular route: # map.connect 'products/:id', :controller => 'catalog', :action => 'view' # Keep in mind you can assign values other than :controller and :action # ...
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 # 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 Format EMAIL = /(\A(\s*)\Z)|(\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z)/i end
Ruby
class RemoveServiceContainerIdInServiceChecks < ActiveRecord::Migration def self.up remove_column :service_checks, :service_container_id end def self.down add_column :service_checks, :service_container_id, :integer end end
Ruby
class AddRowAndPosToAsset < ActiveRecord::Migration def self.up add_column :assets, :row, :string add_column :assets, :pos, :integer end def self.down remove_column :assets, :pos remove_column :assets, :row end end
Ruby
class StorageAdds < ActiveRecord::Migration def self.up add_column :disk_models, :drivetype, :string add_column :disk_details, :scsiid, :string end def self.down remove_column :disk_models, :drivetype remove_column :disk_details, :scsiid end end
Ruby
class CreateNagiosServiceEscalations < ActiveRecord::Migration def self.up create_table :nagios_service_escalations do |t| t.integer :nagios_service_detail_id t.integer :nagios_service_escalation_template_id t.timestamps end end def self.down drop_table :nagios_service_escalations ...
Ruby
class AddFieldsToServiceCheckers < ActiveRecord::Migration def self.up add_column :service_checkers, :home, :text add_column :service_checkers, :command, :text end def self.down remove_column :service_checkers, :home remove_column :service_checkers, :command end end
Ruby
class CreateVlans < ActiveRecord::Migration def self.up create_table :vlans do |t| t.string :name t.integer :vlan_number t.timestamps end end def self.down drop_table :vlans end end
Ruby
class AddAddionalVlanAndDetail < ActiveRecord::Migration def self.up # Vlan and Vlan Detail data v = Vlan.find_or_create_by_name("Public") v.vlan_number = 100 v.save! c = Colo.find_by_name('rmd') VlanDetail.create!(:colo => c, :vlan => v, :subnet => '216.129.122.0/25') c = Colo.find_b...
Ruby
class AddVlanDetailIdToInterface < ActiveRecord::Migration def self.up add_column :interfaces, :vlan_detail_id, :integer end def self.down remove_column :interfaces, :vlan_detail_id end end
Ruby
class AddLoadOidAndSnmpCommToPduModel < ActiveRecord::Migration def self.up add_column :pdu_models, :oid_load, :string add_column :pdu_models, :snmp_read, :string end def self.down remove_column :pdu_models, :oid_load remove_column :pdu_models, :snmp_read end end
Ruby
class SwitchCpuModelWithDetails < ActiveRecord::Migration def self.up rename_table :cpu_details, :cpu_tmp rename_table :cpu_models, :cpu_details rename_table :cpu_tmp, :cpu_models end def self.down rename_table :cpu_models, :cpu_tmp rename_table :cpu_details, :cpu_models rename_table :cpu_tmp, :cpu_d...
Ruby
class CreateNagiosHostGroups < ActiveRecord::Migration def self.up create_table :nagios_host_groups do |t| t.string :name t.text :hosts t.timestamps end end def self.down drop_table :nagios_host_groups end end
Ruby
class RenameTypeToCheckerType < ActiveRecord::Migration def self.up rename_column :service_checkers, :type, :checker_type end def self.down rename_column :service_checkers, :checker_type, :type end end
Ruby
class CreateDnsMxRecords < ActiveRecord::Migration def self.up create_table :dns_mx_records do |t| t.string :name t.integer :dns_zone_id t.integer :priority t.timestamps end end def self.down drop_table :dns_mx_records end end
Ruby
class ChangeDiskDetailCount < ActiveRecord::Migration def self.up change_column :disk_details, :count, :integer, :default => 1 end def self.down change_column :disk_details, :count, :integer end end
Ruby
class AddFieldsToServiceChecks < ActiveRecord::Migration def self.up add_column :service_checks, :command, :text end def self.down remove_column :service_checks, :command end end
Ruby
class AddUnitToStorage < ActiveRecord::Migration def self.up add_column :storages, :unit, :integer end def self.down remove_column :storages, :unit end end
Ruby
class AddRackColumn < ActiveRecord::Migration def self.up add_column :assets, :rack, :string end def self.down remove_column :assets, :rack end end
Ruby
class RenameInterfacePrimaryToRealIp < ActiveRecord::Migration def self.up rename_column :interfaces, :primary, :real_ip end def self.down rename_column :interfaces, :real_ip, :primary end end
Ruby
class CreateServerModels < ActiveRecord::Migration def self.up create_table :server_models do |t| t.string :manufacture t.string :model t.timestamps end end def self.down drop_table :server_models end end
Ruby
class AddNameIndexToAsset < ActiveRecord::Migration def self.up add_index :assets, :name end def self.down remove_index :assets, :name end end
Ruby
class AddSlotToMemoryDetails < ActiveRecord::Migration def self.up add_column :memory_details, :slot, :integer end def self.down remove_column :memory_details, :slot end end
Ruby
class CreateServiceContainerDetails < ActiveRecord::Migration def self.up create_table :service_container_details do |t| t.integer :nagios_host_group_id t.integer :service_container_id t.timestamps end end def self.down drop_table :service_container_details end end
Ruby
class CreateDiskDetails < ActiveRecord::Migration def self.up create_table :disk_details do |t| t.integer :asset_id t.integer :disk_id t.timestamps end end def self.down drop_table :disk_details end end
Ruby
class RenameContainerToServiceContainer < ActiveRecord::Migration def self.up rename_column :service_checks, :container_id, :service_container_id end def self.down rename_column :service_checks, :service_container_id, :container_id end end
Ruby
class AddUnitToVariousModels < ActiveRecord::Migration def self.up add_column :server_models, :unit, :integer add_column :network_models, :unit, :integer add_column :pdu_models, :unit, :integer end def self.down remove_column :pdu_models, :unit remove_column :network_models, :unit remove_...
Ruby
class AddOcsHistoryToAssets < ActiveRecord::Migration def self.up add_column :assets, :ocs_history, :text end def self.down remove_column :assets, :ocs_history end end
Ruby
class RenameTypeCtype < ActiveRecord::Migration def self.up rename_column :cpu_models, :type, :ctype end def self.down rename_column :cpu_models, :ctype, :type end end
Ruby
class AddAutofixToServiceContainers < ActiveRecord::Migration def self.up add_column :service_containers, :autofix, :text end def self.down remove_column :service_containers, :autofix end end
Ruby
class CreateStates < ActiveRecord::Migration def self.up create_table :states do |t| t.string :name t.timestamps end end def self.down drop_table :states end end
Ruby
class CreatePduDetails < ActiveRecord::Migration def self.up create_table :pdu_details do |t| t.string :part_number t.string :manufacture t.integer :receptible t.string :voltage t.string :ampere t.string :wattage t.timestamps end end def self.down drop_table...
Ruby
class CreateNetworkModels < ActiveRecord::Migration def self.up create_table :network_models do |t| t.string :name t.timestamps end end def self.down drop_table :network_models end end
Ruby
class RenameIpAddressToIp < ActiveRecord::Migration def self.up rename_column :interfaces, :ip_address, :ip end def self.down rename_column :interfaces, :ip, :ip_address end end
Ruby
class RenameVipIdtoVipAssetId < ActiveRecord::Migration def self.up rename_column :vip_servers, :vip_id, :vip_asset_id end def self.down rename_column :vip_servers, :vip_asset_id, :vip_id end end
Ruby
class CreateServers < ActiveRecord::Migration def self.up create_table :servers do |t| t.integer :asset_id t.timestamps end end def self.down drop_table :servers end end
Ruby
class RenameServiceCheckersToServiceChecker < ActiveRecord::Migration def self.up rename_column :service_checks, :service_checkers_id, :service_checker_id end def self.down rename_column :service_checks, :service_checker_id, :service_checkers_id end end
Ruby
class IncreaseServiceCheckerDefinitionSizeAgain < ActiveRecord::Migration def self.up change_column :service_checkers, :definition, :string, :limit => 2048 end def self.down raise ActiveRecord::IrreversibleMigration end end
Ruby
class CreateInterfaces < ActiveRecord::Migration def self.up create_table :interfaces do |t| t.string :name t.boolean :primary t.text :description t.string :ip_address t.integer :asset_id t.timestamps end end def self.down drop_table :interfaces end end
Ruby
class UndoLastChange < ActiveRecord::Migration def self.up rename_column :cpu_details, :cpu_model_id, :cpu_id end def self.down rename_column :cpu_details, :cpu_id, :cpu_model_id end end
Ruby
class RenameCpuId < ActiveRecord::Migration def self.up rename_column :cpu_details, :cpu_id, :cpu_model_id end def self.down rename_column :cpu_details, :cpu_model_id, :cpu_id end end
Ruby
class CreateMemories < ActiveRecord::Migration def self.up create_table :memories do |t| t.integer :asset_id t.integer :memory_id t.timestamps end end def self.down drop_table :memories end end
Ruby
class CreatePdus < ActiveRecord::Migration def self.up create_table :pdus do |t| t.integer :consumption t.string :ip t.integer :pdu_detail_id t.timestamps end end def self.down drop_table :pdus end end
Ruby
class CreateServiceCheckDetails < ActiveRecord::Migration def self.up create_table :service_check_details do |t| t.integer :container_id t.integer :service_check_id t.timestamps end end def self.down drop_table :service_check_details end end
Ruby
class RenameCpus < ActiveRecord::Migration def self.up rename_table :cpus, :cpu_models end def self.down rename_table :cpu_models, :cpus end end
Ruby
class CreateDnsZones < ActiveRecord::Migration def self.up create_table :dns_zones do |t| t.string :name t.string :soa t.string :a t.integer :inherit t.integer :ttl t.integer :refresh t.integer :retry t.integer :expire t.integer :minimum t.timestamps ...
Ruby