code
stringlengths
1
1.73M
language
stringclasses
1 value
CmsRails::Application.routes.draw do resources :programs, :as => 'flow_programs', :only => [:index, :show, :new, :edit, :create, :update, :destroy] do member do get 'tooltip' get 'delete' get 'sections' get 'controls' end end resources :directives, :as => 'flow_directives', :only...
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 'yaml' CMS_CONFIG = { "SECRET_TOKEN" => "0123456789abcdefChangethistosomethingsecret", "COMPANY" => "Company, Inc.", "COMPANY_LOGO" => nil, "COMPANY_LOGO_TEXT" => nil, "ABOUT_LINK" => "https://code.google.com/p/compliance-management/", "SECTION_IMPORT_...
Ruby
# Monkey patch to avoid riddle trying to exec stuff ENV['SPHINX_VERSION'] = '2.0.4' require 'riddle' module Riddle class Controller def sphinx_version ENV['SPHINX_VERSION'] end end end # Load the rails application require File.expand_path('../application', __FILE__) # Initialize the rails applicatio...
Ruby
# Disable Rake-environment-task framework detection by uncommenting/setting to false # Warbler.framework_detection = false # Warbler web application assembly configuration file Warbler::Config.new do |config| # Features: additional options controlling how the jar is built. # Currently the following features are su...
Ruby
CmsRails::Application.configure do # Settings specified here will take precedence over those in config/application.rb # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true # Full error reports are disabled and caching is turned o...
Ruby
CmsRails::Application.configure do # Settings specified here will take precedence over those in config/application.rb config.cache_classes = true config.action_controller.perform_caching = false # Log error messages when you accidentally call methods on nil. config.whiny_nils = true # Show full error rep...
Ruby
CmsRails::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 web ...
Ruby
CmsRails::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 test...
Ruby
# This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run CmsRails::Application
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.expand_path('../config/application', __FILE__) require 'rake' CmsRails::Application.load_tasks if Rails.env.development? || Rails.env.test? requ...
Ruby
require 'gdata' module Gdoc DOCLIST_SCOPE = 'https://docs.google.com/feeds/' DOCLIST_DOWNLOD_SCOPE = 'https://docs.googleusercontent.com/' CONTACTS_SCOPE = 'https://www.google.com/m8/feeds/' SPREADSHEETS_SCOPE = 'https://spreadsheets.google.com/feeds/' DEFAULT_FEED = DOCLIST_SCOPE + 'default/private/full' ...
Ruby
# Monkey patch Prawn to fix 'incompatible character encodings' error in JRuby: # https://github.com/prawnpdf/prawn/issues/283 require 'prawn' module Prawn module Core def self.utf8_to_utf16(str) str end end end
Ruby
# Importer contains classes and methods to import data from various formats # into the system. module Importer class ImportError < StandardError end end
Ruby
require 'open-uri' require 'csv' module Importer class Regulation def initialize end def run_file(filename) open(filename, 'r:utf-8') do |file| run_csv(file.read) end end def run_csv(csv_string) directive = nil headers_seen = false CSV.parse(csv_string) ...
Ruby
require 'open-uri' require 'csv' module Importer # Importer for specialized CSV document format # # Expected columns are: # 0-4: Company control index, unused, title, description-part-1, description-part-2 # 5-6: Directive 1: description, slug(s) # 7-8: Directive 2: description, slug(s) # 9-10...
Ruby
namespace :demo do desc "Load demo seed data" task :seed => :environment do |t, args| demo_seed_file = File.join(Rails.root, 'db', 'demo_seeds', 'demo_seeds.rb') load(demo_seed_file) end task :setup => [:environment, :"db:seed", :"demo:seed"] task :reset, [ :subdir ] => [:environment, :"db:reset", :s...
Ruby
namespace :export do desc "Export help data to YAML file" task :help, [:filename] => [:environment] do |t, args| puts "Exporting help data to #{args[:filename]}" File.open(args[:filename], 'w') do |file| YAML::dump(Help.all, file) end end end
Ruby
namespace :import do desc "Import various documents into CMS" task :consolidated, [:filename] => [:environment] do |t, args| puts "Import consolidated format from #{args[:filename]}" require 'importer/consolidated' ActiveRecord::Base.transaction do importer = Importer::Consolidated.new imp...
Ruby
# Copyright (C) 2009 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
#!/usr/bin/env ruby # Tool for creating a new unit test case. require 'erb' def main if ARGV.size != 1 usage() exit 1 end class_name = ARGV[0] if class_name !~ /^[a-z0-9]+$/i print "'#{class_name}' doesn't look like a valid class name.\n" exit 1 end header = find_header(class_name) if header.nil? p...
Ruby
#!/usr/bin/env ruby # Tool for creating a new unit test case. require 'erb' def main if ARGV.size != 1 usage() exit 1 end class_name = ARGV[0] if class_name !~ /^[a-z0-9]+$/i print "'#{class_name}' doesn't look like a valid class name.\n" exit 1 end header = find_header(class_name) if header.nil? p...
Ruby
environment = :production project_type = :stand_alone http_path = "/" css_dir = "../styles" sass_dir = "." images_dir = "images" sass_options = { :line_numbers => false, :debug_info => false } # output_style = :compressed # output_style = :compact output_style = :expanded
Ruby
require 'webrick' include WEBrick s = HTTPServer.new( :Port => 2010, :DocumentRoot => Dir::pwd ) s.mount('/sh/scripts', WEBrick::HTTPServlet::FileHandler, '../scripts') s.mount('/sh/styles', WEBrick::HTTPServlet::FileHandler, '../styles') trap('INT') { s.stop } s.start
Ruby
css_dir = "." sass_dir = "." images_dir = "." fonts_dir = "fonts" relative_assets = true output_style = :compact line_comments = false preferred_syntax = :scss
Ruby
module Jekyll module BugFilter def bugify(input) upstream_map = { "Bootstrap" => "https://github.com/twbs/bootstrap/issues/", "IE" => ["https://connect.microsoft.com/IE/feedback/details/", "IE bug"], "Mozilla" => ["https://bugzilla.mozilla.org/show_bug.cgi?id=", "Mozilla bug"], ...
Ruby
require 'yaml' module Bridge class Generator < Jekyll::Generator def generate(site) site.data["configBridge"] = YAML.load_file("./grunt/configBridge.json") end end end
Ruby
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "theme/css" sass_dir = "theme/scss" images_dir = "images" javascripts_dir = "js" # You can select your preferred output style here (can be overridden via the command line): output_style = :co...
Ruby
# Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "theme/css" sass_dir = "theme/scss" images_dir = "images" javascripts_dir = "js" # You can select your preferred output style here (can be overridden via the command line): output_style = :co...
Ruby
#!/usr/bin/env ruby # Tool for creating a new unit test case. require 'erb' def main if ARGV.size != 1 usage() exit 1 end class_name = ARGV[0] if class_name !~ /^[a-z0-9]+$/i print "'#{class_name}' doesn't look like a valid class name.\n" exit 1 end header = find_header(class_name) if header.nil? p...
Ruby
#!/usr/bin/env ruby # Tool for creating a new unit test case. require 'erb' def main if ARGV.size != 1 usage() exit 1 end class_name = ARGV[0] if class_name !~ /^[a-z0-9]+$/i print "'#{class_name}' doesn't look like a valid class name.\n" exit 1 end header = find_header(class_name) if header.nil? p...
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. # 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. ActiveReco...
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 cookie session data integrity. # If you change this key, all old sessions 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 attacks. Act...
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 do debug a probl...
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 # Full error reports are disabled and caching is turned on config.action_controller.consider_all_reque...
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 # Specifies gem version of Rails to use when vendor/rails is not present RAILS_GEM_VERSION = '2.3.2' unless defined? RAILS_GEM_VERSION # Bootstrap the Rails environment, frameworks, and default configuration require File.join(File.dirname(__FILE__), 'boot') ...
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. # 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
# Methods added to this helper will be available to all templates in the application. module ApplicationHelper end
Ruby
class TimeEntry < Entry has_one :time_value, :autosave => true def data if self.time_value != nil self.time_value.data else nil end end def data=(value) if self.time_value != nil self.time_value.data = value else self.time_value = TimeValue.new(:d...
Ruby
class TimeField < Field def new_entry et = TimeEntry.new et.field = self et end end
Ruby
class TimeValue < ActiveRecord::Base belongs_to :time_entry end
Ruby
class NumberEntry < Entry has_one :number_value, :autosave => true def data if self.number_value.data != nil self.number_value.data else nil end end def data=(value) if self.number_value != nil self.number_value.data = value else self.number_value =...
Ruby
class NumberField < Field def new_entry et = NumberEntry.new et.field = self et end end
Ruby
class NumberValue < ActiveRecord::Base belongs_to :entry end
Ruby
class Field < ActiveRecord::Base has_and_belongs_to_many :trackers has_many :entries validates_uniqueness_of :name def get_entry!(ticket) ets = Entry.find(:all, :conditions => [ "ticket_id = ? AND field_id = ?", ticket.id, self.id ] ) #et = self.entries.find(:ticket => ticket) if...
Ruby
class Entry < ActiveRecord::Base belongs_to :ticket belongs_to :field end
Ruby
class StringValue < ActiveRecord::Base belongs_to :string_entry end
Ruby
class StringField < Field def new_entry et = StringEntry.new et.field = self et end end
Ruby
class StringEntry < Entry has_one :string_value, :autosave => true def data if self.string_value != nil self.string_value.data else nil end end def data=(value) if self.string_value != nil self.string_value.data = value else self.string_value = St...
Ruby
class Right < ActiveRecord::Base end
Ruby
class Membership < ActiveRecord::Base belongs_to :users belongs_to :groups end
Ruby
class User < ActiveRecord::Base has_many :memberships has_many :groups, :through => :memberships has_many :tasks end
Ruby
class Group < ActiveRecord::Base has_many :memberships has_many :users, :through => :memberships # acts_as_tree :order => :name end
Ruby
class Role < ActiveRecord::Base belongs_to :tracker has_many :entries end
Ruby
class Protectable < ActiveRecord::Base end
Ruby
class Activity < ActiveRecord::Base belongs_to :tracker has_many :tasks def evaluate_tasks_for(ticket) if (ticket.tracker == self.tracker) # find _tasks in :tasks <= task.ticket == ticket # if _tasks == nil # create a task for ticket # end end end end
Ruby
class Tracker < ActiveRecord::Base has_and_belongs_to_many :fields has_many :activities has_many :tickets def new_ticket Ticket.new :tracker => self end end
Ruby
class Expression < ActiveRecord::Base end
Ruby
class Ticket < ActiveRecord::Base belongs_to :tracker has_many :entries, :autosave => true has_many :entry_fields, :through => :entries, :source => :field has_many :tasks def fields # self.tracker.fields + self.entry_fields field_ids = Array.new self.tracker.fields.each do |field| ...
Ruby
class Task < ActiveRecord::Base belongs_to :ticket belongs_to :activity belongs_to :user #current owner end
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 helper :all # include all helpers, all the time protect_from_forgery # See ActionController::RequestForgeryPr...
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/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/plugin'
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' $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" require 'commands/about'
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/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/console'
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' $LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info" require 'commands/about'
Ruby
#!/usr/bin/env ruby require File.dirname(__FILE__) + '/../config/boot' require 'commands/plugin'
Ruby
class CreateEntries < ActiveRecord::Migration def self.up create_table :entries do |t| t.integer :ticket_id t.integer :field_id t.string :type #t.string :string_value #t.datetime :time_value #link to values in xxx_value t.timestamps ...
Ruby
class CreateTrackers < ActiveRecord::Migration def self.up create_table :trackers do |t| t.string :name t.string :label t.timestamps end end def self.down drop_table :trackers end end
Ruby
class CreateRights < ActiveRecord::Migration def self.up create_table :rights do |t| #grant access on t.integer :protectable_id #to t.integer :role_id t.integer :group_id t.integer :user_id #with coindition t.boolean :delegatable t.boolean :t...
Ruby
class CreateExpressions < ActiveRecord::Migration def self.up create_table :expressions do |t| t.timestamps end end def self.down drop_table :expressions end end
Ruby
class CreateFieldsTrackers < ActiveRecord::Migration def self.up create_table :fields_trackers, :id => false do |t| t.integer :tracker_id t.integer :field_id end end def self.down drop_table :fields_trackers end end
Ruby
class CreateMemberships < ActiveRecord::Migration def self.up create_table :memberships do |t| t.integer :group_id t.integer :user_id t.boolean :is_manager t.timestamps end end def self.down drop_table :memberships end end
Ruby
class CreateGroups < ActiveRecord::Migration def self.up create_table :groups do |t| t.integer :parent_id t.string :name t.timestamps end end def self.down drop_table :groups end end
Ruby
class CreateTasks < ActiveRecord::Migration def self.up create_table :tasks do |t| t.integer :ticket_id t.integer :activity_id t.integer :user_id t.integer :state #completed=0, current=1, pending=2 t.datetime :view_time t.timestamps end end def self.down drop_tab...
Ruby
class CreateActivities < ActiveRecord::Migration def self.up create_table :activities do |t| t.string :name t.string :label t.integer :tracker_id #when #pre-condition: in-links from other actions # pre_activities #postcondition: validation, comletion of this ac...
Ruby
class CreateTimeValues < ActiveRecord::Migration def self.up create_table :time_values do |t| t.integer :time_entry_id t.datetime :data t.timestamps end end def self.down drop_table :time_values end end
Ruby
class CreateNumberValues < ActiveRecord::Migration def self.up create_table :number_values do |t| t.integer :number_entry_id t.decimal :data t.timestamps end end def self.down drop_table :number_values end end
Ruby
class CreateStringValues < ActiveRecord::Migration def self.up create_table :string_values do |t| t.integer :string_entry_id t.string :data t.timestamps end end def self.down drop_table :string_values end end
Ruby
class CreateFields < ActiveRecord::Migration def self.up create_table :fields do |t| t.string :name t.string :label t.string :type #t.string :rules #t.string :default #t.boolean :optional t.timestamps end end def self.down drop_table :fi...
Ruby