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/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/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/request'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/generate'
Ruby
module WelcomeHelper end
Ruby
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper require 'recaptcha' include ReCaptcha::ViewHelper end
Ruby
module EntriesHelper end
Ruby
module PasswordHelper end
Ruby
module Admin::OptionsHelper end
Ruby
module Admin::LoughsHelper end
Ruby
module Admin::BaseHelper end
Ruby
module Admin::UsersHelper end
Ruby
module Admin::DashboardHelper end
Ruby
module Admin::ArticlesHelper end
Ruby
module XmlHelper end
Ruby
module RedirectHelper end
Ruby
module RegisterHelper end
Ruby
module SignHelper end
Ruby
class PasswordMailer < ActionMailer::Base def recovery(password_recovery, email) @subject = 'Password Recovery - babaru.net' @recipients = email @from = '' @sent_on = Time.now @headers = {} @body[:password_recovery] = password_recovery end end
Ruby
module ConfigManager def self.append_features(base) super base.extend(ClassMethods) end module ClassMethods def fields @fields ||= Hash.new { Item.new } end def setting(name, type=:object, default=nil) item = Item.new item.name, item.ruby_type, item.default = name.to_s, typ...
Ruby
class Lough < ActiveRecord::Base include ConfigManager belongs_to :user has_many :articles validates_presence_of :screen_name validates_uniqueness_of :screen_name serialize :settings, Hash # Description setting :lough_name, :string, '' setting :about_owner, :string, '' setti...
Ruby
class PasswordRecovery < ActiveRecord::Base belongs_to :user def recovery_url "http://babaru.net/password/recover/#{read_attribute('token')}" end protected before_create :create_token def create_token write_attribute('token', UUID.new) end end
Ruby
require 'digest/sha1' class User < ActiveRecord::Base has_one :lough has_many :articles has_many :password_recoveries # validations validates_presence_of :email, :login_name validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i validates_uniqueness_of :email validates_un...
Ruby
class AccountMailer < ActionMailer::Base def registration_confirm(user) @subject = 'Babaru.net Registration Successful' @recipients = user.email @from = 'automan@babaru.net' @sent_on = Time.now @headers = {} @body[:user] = user end end
Ruby
class Article < ActiveRecord::Base belongs_to :user belongs_to :lough cattr_reader :per_page @@per_page = 10 validates_presence_of :title, :lough_id, :user_id before_save :set_body_html protected def set_body_html write_attribute('body_html',read_attribute('body')) end end
Ruby
class RedirectController < ApplicationController def redirect @r = Redirect.find_by_from_path('from/admin/articles') end end
Ruby
class WelcomeController < ApplicationController def index @loughs = Lough.find(:all) end end
Ruby
class Admin::ArticlesController < Admin::BaseController verify :method => :post, :only => [:create, :update, :destroy], :redirect_to => {:action => 'list'} def index list render :action => 'list' end def list @articles = Article.paginate_all_by_lough_id(current_lough.id, ...
Ruby
class Admin::DashboardController < Admin::BaseController def index end end
Ruby
class Admin::UsersController < Admin::BaseController def edit end def update @user = User.find(params[:id]) if @user.update_attributes(params[:user].symbolize_keys) flash[:notice] = 'Success' redirect_to admin_url else render :action => 'edit' end end end
Ruby
class Admin::BaseController < ApplicationController layout 'administration' before_filter :login_required attr_reader :tiny_mce_used end
Ruby
class Admin::LoughsController < Admin::BaseController def new @lough = Lough.new end def create @lough = current_user.create_lough(params[:lough].symbolize_keys) if @lough.save flash[:notice] = 'Create lough successfully.' redirect_to lough_index_url(:screen_name => @lough.screen_name) ...
Ruby
class Admin::OptionsController < Admin::BaseController def index edit render :action => 'edit' end def edit @lough = @current_lough end def update @lough = Lough.find(params[:id]) if @lough.update_attributes(params[:lough].symbolize_keys) flash[:notice] = "Success" redire...
Ruby
class EntriesController < ApplicationController before_filter :check_current_lough layout 'entries' def index list render :action => 'list' end def show if params[:id] @article = Article.find(params[:id]) end end def list @articles = Article.paginate_all_by_lough_id(@cu...
Ruby
class XmlController < ApplicationController def rss @articles = Article.find(:all, :order => 'published_at DESC', :limit => 25) end end
Ruby
class RegisterController < ApplicationController layout 'account' verify :method => :post, :only => [:create_user, :save_addition_info, :create_lough], :redirect_to => {:action => :new_user} attr_reader :title def index new_user render :action => 'new_user' end def new_user @title...
Ruby
# Filters added to this controller apply to all controllers in the application. # Likewise, all the methods added will be available for all controllers. require 'recaptcha' class ApplicationController < ActionController::Base include LoginSystem include ReCaptcha::AppHelper # Pick a unique cookie name to disting...
Ruby
require 'digest/sha1' class PasswordController < ApplicationController layout 'account' verify :method => :post, :only => [:update_password], :redirect_to => {:action => 'recover_password'} verify :method => :post, :only => [:send_recovery], :redirect_to => {:action => 'fotget'}...
Ruby
class SignController < ApplicationController verify :method => :post, :only => [:create_user, :sign_in_from_welcome], :redirect_to => {:action => :sign_in} layout 'account' def sign_in @title = 'Login' if request.post? @recap, @user = sign_in_babaru(:need_recaptcha => true) i...
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): # Inflector.inflections do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person', 'people' # i...
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
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! # 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
# 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.0...
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
# # = uuid.rb - UUID generator # # Author:: Assaf Arkin assaf@labnotes.org # Documentation:: http://trac.labnotes.org/cgi-bin/trac.cgi/wiki/Ruby/UuidGenerator # Copyright:: Copyright (c) 2005,2007 Assaf Arkin # License:: MIT and/or Creative Commons Attribution-ShareAlike require 'thread' require 'yaml' require 'sing...
Ruby
# bare_migration.rb # Scott Bronson # 26 Jan 2006 # # This module provides bare ActiveRecord::Base objects for migration # scripts. # # Most migration scripts use model classes to move data. This is # fine when the schema you're migrating from is compatible with your # current models. It's disastrous when your models...
Ruby
module LoginSystem protected def authorize?(user) if user # Check current user is owner of this lough or not. return current_lough && current_lough.id == user.lough.id end return false end # A filter that any login required controller should be called. def l...
Ruby
#Copyright (c) 2007 McClain Looney # #Permission is hereby granted, free of charge, to any person obtaining a copy #of this software and associated documentation files (the "Software"), to deal #in the Software without restriction, including without limitation the rights #to use, copy, modify, merge, publish, distribut...
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). ActiveRecord::Base.transaction do # Categories # Control categories control_categories = [ ["Access Contr...
Ruby
class AddPersonLanguage < ActiveRecord::Migration # Add a 'language_id' association from Person to the Option table # Local models so that migration is safe class Option < ActiveRecord::Base attr_accessible :role, :title end def up add_column :people, :language_id, :integer Option.reset_column_...
Ruby
class AddDocumentOptionColumns < ActiveRecord::Migration def up change_table :documents do |t| t.text :description t.references :type t.references :kind t.references :year t.references :language end end def down change_table :documents do |t| t.remove :description ...
Ruby
class AddKindToPrograms < ActiveRecord::Migration def change add_column :programs, :kind, :string end end
Ruby
class RemoveControlIdFromRequests < ActiveRecord::Migration def up # replace all controls with adequate control assessments Request.all.each do |request| if request.control_id.present? control_assessment = ControlAssessment.where(:control_id => request.control_id, :pbc_list_id => request.pbc_lis...
Ruby
class FixRelationshipDescription < ActiveRecord::Migration def up rename_column :relationship_types, :forward_short_description, :forward_phrase rename_column :relationship_types, :backward_short_description, :backward_phrase end def down rename_column :relationship_types, :forward_phrase, :forward_s...
Ruby
class CreateProjects < ActiveRecord::Migration def change create_table :projects do |t| t.string :slug t.string :title t.text :description t.string :url t.references :modified_by t.datetime :start_date t.datetime :stop_date t.timestamps end end end
Ruby
class LinkAccountsAndPeople < ActiveRecord::Migration # This migration does a few different things: # Adds an association between accounts and people # Renames the username attribute to email in people # Links accounts to people via e-mail, creating people # as necessary to map to accounts. # Local models ...
Ruby
class AddNotesToSystems < ActiveRecord::Migration def change add_column :systems, :notes, :text end end
Ruby
class CreateControlRisks < ActiveRecord::Migration def change create_table :control_risks do |t| t.references :control, :null => false t.references :risk, :null => false t.references :modified_by t.timestamps end end end
Ruby
class ChangeStatusValues < ActiveRecord::Migration # "Draft" remains "Draft" in the new arrangement. REQUEST_STATUS_MIGRATIONS = [ ["Waiting Compliance", "Requested"], ["Waiting Auditors", "Responded (by Compliance)"], ["Completed", "Accepted (by Auditor)"] ] def up REQUEST_STATUS_M...
Ruby
class AddPopulationSampleFieldsToResponses < ActiveRecord::Migration def change add_column :responses, :population_document_id, :integer add_column :responses, :population, :integer add_column :responses, :sample_worksheet_document_id, :integer add_column :responses, :samples, :integer add_column ...
Ruby
class AddProgramIdToCycles < ActiveRecord::Migration def change add_column :cycles, :program_id, :integer end end
Ruby
class ChangePolymorphicTypesFromProgramToDirective < ActiveRecord::Migration RELATIONSHIP_TYPE_NAME_CHANGES = [ [:program_applies_to_data_asset, :directive_applies_to_data_asset], [:program_applies_to_facility, :directive_applies_to_facility], [:program_applies_to_market, :directive_applies_to_marke...
Ruby
class EnsureRequestTypeIdIsNotNil < ActiveRecord::Migration def up Request.all.reject(&:type_name).each{ |r| r.update_attribute(:type_id, 1) } end def down end end
Ruby
class CreateBaseRelationshipTypes < ActiveRecord::Migration class RelationshipType < ActiveRecord::Base self.primary_key = 'relationship_type' end def up RelationshipType.create({:relationship_type => 'within_scope_of', :description => 'The source is within the scope of the ...
Ruby
class AddReportDueAtToAuditCycle < ActiveRecord::Migration def change add_column :cycles, :report_due_at, :date end end
Ruby
class MoveImportHelpPaths < ActiveRecord::Migration def up help = Help.where(:slug => 'import').first help.update_attribute(:slug, 'systems_import') if help help = Help.where(:slug => 'import_controls').first help.update_attribute(:slug, 'controls_import') if help end def down end end
Ruby
class AddCompanyControlsProgram < ActiveRecord::Migration def up transaction do p = Program.where(:kind => "Company Controls").first if p.nil? p = Program.create(:kind => "Company Controls", :title => "Company Controls") end Directive.where(:kind => "Company Controls").each do |d|...
Ruby
class CreateResponses < ActiveRecord::Migration def change create_table :responses do |t| t.references :request t.references :system t.string :status t.references :modified_by t.timestamps end end end
Ruby
class SetDefaultKindForPrograms < ActiveRecord::Migration def up transaction do Program.all.each do |program| program.kind = "Directive" if program.kind.blank? program.save! end end end def down end end
Ruby
class AddProductStartStopDates < ActiveRecord::Migration def up change_table :products do |t| t.datetime :start_date t.datetime :stop_date end end def down change_table :products do |t| t.remove :start_date t.remove :stop_date end end end
Ruby
class UniqueSlug < ActiveRecord::Migration def up add_index :sections, :slug, :unique => true add_index :controls, :slug, :unique => true add_index :biz_processes, :slug, :unique => true add_index :systems, :slug, :unique => true add_index :programs, :slug, :unique => true end def down re...
Ruby
class FixNilRequestStatuses < ActiveRecord::Migration def up Request.where(:status => nil).all.each do |req| req.update_attribute(:status, 'Draft') end end def down end end
Ruby
class AddNewRisksFields < ActiveRecord::Migration def change change_table :risks do |t| t.text :likelihood t.text :threat_vector t.text :trigger t.text :preconditions t.text :financial_impact t.text :reputational_impact t.text :operational_impact t.integer :likeli...
Ruby