code
stringlengths
1
1.73M
language
stringclasses
1 value
# Author:: Daniel Ring (mailto:danring+cms@google.com) # Copyright:: Google Inc. 2012 # License:: Apache 2.0 class CategoriesController < BaseObjectsController # access_control :acl do # allow :superuser # end layout 'dashboard' no_base_action :tooltip def index @categories = Category if params[...
Ruby
class BaseMappingsController < ApplicationController include ApplicationHelper def create if params[:items].present? errors, objects = {}, {} ActiveRecord::Base.transaction do params[:items].keys.each do |id| item_errors, item_object = create_or_update_object(params[:items][id]) ...
Ruby
class HelpController < ApplicationController layout 'help' # access_control :acl do # allow logged_in # end # Render the requested partial under 'help' def edit slug = params[:help]['slug'] @help = Help.find_by_slug(slug) || Help.new(:slug => slug) @help.title = params[:help]['title'] ...
Ruby
# Handle projects class ProjectsController < BusinessObjectsController access_control :acl do # FIXME: Implement real authorization allow :superuser actions :new, :create do allow :create, :create_project end actions :edit, :update do allow :update, :update_project, :of => :project...
Ruby
class RiskRiskyAttributesController < BaseMappingsController # access_control :acl do # allow :superuser # end before_filter :check_risk_authorization def index @objects = RiskRiskyAttribute if params[:risk_id].present? @objects = @objects.where(:risk_id => params[:risk_id]) end if p...
Ruby
class ProgramDirectivesController < BaseMappingsController # access_control :acl do # allow :superuser # end def index @objects = ProgramDirective if params[:program_id].present? @objects = @objects.where(:program_id => params[:program_id]) if params[:directive_meta_kind].present? @...
Ruby
# Handle Requests class RequestsController < BaseObjectsController # access_control :acl do # # FIXME: Implement real authorization # # allow :superuser # # actions :index do # allow :read, :read_request # end # # actions :new, :create do # allow :create, :create_request # end # # actio...
Ruby
# Author:: Miron Cuperman (mailto:miron+cms@google.com) # Copyright:: Google Inc. 2012 # License:: Apache 2.0 class CyclesController < BaseObjectsController # access_control :acl do # allow :superuser # # actions :new, :create do # allow :create, :create_cycle # end # # actions :show, :tooltip do # ...
Ruby
# Author:: Miron Cuperman (mailto:miron+cms@google.com) # Copyright:: Google Inc. 2012 # License:: Apache 2.0 # Handle Controls class ControlsController < BaseObjectsController include ControlsHelper include AuthorizationHelper before_filter :load_control, :only => [:sections, ...
Ruby
# Author:: Miron Cuperman (mailto:miron+cms@google.com) # Copyright:: Google Inc. 2012 # License:: Apache 2.0 # Handle markets class MarketsController < BusinessObjectsController # access_control :acl do # # FIXME: Implement real authorization # # allow :superuser # # actions :new, :create do # allow :...
Ruby
class RelationshipsController < BaseMappingsController # access_control :acl do # allow :superuser # allow :read, :read_relationship, :to => [:related_objects] # end def index wants_risk = false if is_risky_type?(params[:object_type]) || is_risky_type?(params[:related_model]) wants_risk = true...
Ruby
class BusinessObjectsController < BaseObjectsController include BusinessObjectsHelper end
Ruby
class MappingController < ApplicationController include ControlsHelper layout 'dashboard' respond_to :html, :json cache_sweeper :section_sweeper, :only => [:map_rcontrol, :map_ccontrol, :update] cache_sweeper :control_sweeper, :only => [:map_rcontrol, :map_ccontrol] def show @program = Program.find(p...
Ruby
# Handle unincorporated design views here class DesignController < ApplicationController include ApplicationHelper layout 'dashboard' before_filter :require_design_feature # Render the requested partial under 'design/templates' def templates template_name = params[:name] respond_to do |format| ...
Ruby
# Author:: Miron Cuperman (mailto:miron+cms@google.com) # Copyright:: Google Inc. 2012 # License:: Apache 2.0 # Programs overview class ProgramsDashController < ApplicationController include DashboardHelper # access_control :acl do # allow logged_in # end layout 'dashboard' def index @programs = allo...
Ruby
class PopulationSamplesController < BaseObjectsController # access_control :acl do # allow :superuser # end layout 'dashboard' no_base_action :index, :show, :tooltip private def object_path flow_pbc_list_path(@population_sample.response.request.pbc_list_id) end def post_destroy_path ...
Ruby
class UserSessionsController < ApplicationController skip_before_filter :require_user, :except => :destroy #before_filter :require_no_user, :only => [:new, :create] #before_filter :require_user, :only => :destroy layout 'welcome' access_control :acl do allow all end def login if current_us...
Ruby
# Author:: Miron Cuperman (mailto:miron+cms@google.com) # Copyright:: Google Inc. 2012 # License:: Apache 2.0 # Handle facilities class FacilitiesController < BusinessObjectsController # access_control :acl do # # FIXME: Implement real authorization # # allow :superuser # # actions :new, :create do # a...
Ruby
class ControlRisksController < BaseMappingsController # access_control :acl do # allow :superuser # end def index @objects = ControlRisk if params[:risk_id].present? @objects = @objects.where(:risk_id => params[:risk_id]) end if params[:control_id].present? @objects = @objects.where...
Ruby
# Author:: Miron Cuperman (mailto:miron+cms@google.com) # Copyright:: Google Inc. 2012 # License:: Apache 2.0 require 'csv' # HandleSystems class SystemsController < BaseObjectsController # access_control :acl do # allow :superuser # # actions :new, :create, :import do # allow :create, :create_system # ...
Ruby
# Author:: Miron Cuperman (mailto:miron+cms@google.com) # Copyright:: Google Inc. 2012 # License:: Apache 2.0 # Handle Transactions class TransactionsController < BaseObjectsController # access_control :acl do # allow :superuser # end layout 'dashboard' no_base_action :index, :show, :tooltip private ...
Ruby
class ObjectDocumentsController < BaseMappingsController # access_control :acl do # allow :superuser # # actions :index do # allow :read, :read_object_document # end # # actions :create do # allow :create, :create_object_document # end # # actions :list_edit, :create do # allow :updat...
Ruby
# Author:: Slobodan Kovacevic (mailto:basti@reciprocitynow.com) # Copyright:: Google Inc. 2012 # License:: Apache 2.0 class OptionsController < BaseObjectsController # access_control :acl do # allow :superuser # end layout 'dashboard' def index @options = Option.all if params[:s].present? @op...
Ruby
class SystemSystemsController < BaseMappingsController # access_control :acl do # allow :superuser # end def index @objects = SystemSystem if params[:parent_id].present? @objects = @objects.where(:parent_id => params[:parent_id]) end render :json => @objects, :include => :child end p...
Ruby
# Handle markets class DataAssetsController < BusinessObjectsController # access_control :acl do # # FIXME: Implement real authorization # # allow :superuser # # actions :new, :create do # allow :create, :create_data_asset # end # # actions :edit, :update do # allow :update, :update_data_asse...
Ruby
# Handle Risks require 'csv' class RisksController < BaseObjectsController # access_control :acl do # # FIXME: Implement real authorization # # allow :superuser # # actions :index do # allow :read, :read_risk # end # # actions :new, :create do # allow :create, :create_risk # end # # a...
Ruby
# Handle Control Assessments class ControlAssessmentsController < BaseObjectsController # access_control :acl do # # FIXME: Implement real authorization # # allow :superuser # # actions :index do # allow :read, :read_control_assessment # end # # actions :new, :create do # allow :create, :crea...
Ruby
# Author:: Miron Cuperman (mailto:miron+cms@google.com) # Copyright:: Google Inc. 2012 # License:: Apache 2.0 # Handle Documents class DocumentsController < BaseObjectsController # access_control :acl do # allow :superuser # # actions :create, :new do # allow :create, :create_document # end # # acti...
Ruby
class ObjectPeopleController < BaseMappingsController # access_control :acl do # allow :superuser # # actions :index do # allow :read, :read_object_person # end # # actions :create do # allow :create, :create_object_person # end # # actions :list_edit, :create do # allow :update, :upd...
Ruby
# Handle Responses class ResponsesController < BaseObjectsController # access_control :acl do # # FIXME: Implement real authorization # # allow :superuser # # actions :index do # allow :read, :read_response # end # # actions :new, :create do # allow :create, :create_response # end # # a...
Ruby
# Browse programs class ProgramsController < BaseObjectsController # access_control :acl do # allow :superuser # # actions :new, :create do # allow :create, :create_program # end # # actions :edit, :update do # allow :update, :update_program, :of => :program # end # # actions :show, :toolt...
Ruby
# Author:: Miron Cuperman (mailto:miron+cms@google.com) # Copyright:: Google Inc. 2012 # License:: Apache 2.0 class AccountsController < BaseObjectsController # access_control :acl do # allow :superuser # # actions :new, :create do # allow :create, :create_account # end # # actions :edit, :update do...
Ruby
# Author:: Miron Cuperman (mailto:miron+cms@google.com) # Copyright:: Google Inc. 2011 # License:: Apache 2.0 # Handle Google Docs integration class DocumentController < ApplicationController include GdataHelper include DocumentHelper # access_control :acl do # allow :superuser # # actions :index do # ...
Ruby
# Author:: Miron Cuperman (mailto:miron+cms@google.com) # Copyright:: Google Inc. 2012 # License:: Apache 2.0 class PeopleController < BaseObjectsController # access_control :acl do # allow :superuser # # actions :index do # allow :read, :read_person # end # # actions :new, :create do # allow :...
Ruby
class SectionRowConverter < BaseRowConverter @model_class = :Section def setup_object object = setup_object_by_slug(attrs) if object.directive.present? && object.directive != @importer.options[:directive] add_error(:slug, "Code is used in #{object.directive.meta_kind.to_s.titleize}: #{object.direc...
Ruby
module ErrorWarningMessageObject attr_accessor :errors, :warnings, :messages def initialize @base_errors = [] @errors = HashWithIndifferentAccess.new @base_warnings = [] @warnings = HashWithIndifferentAccess.new @base_messages = [] @messages = HashWithIndifferentAccess.new super end...
Ruby
class SystemRowConverter < BaseRowConverter @model_class = :System def setup_object object = setup_object_by_slug(attrs) if object.new_record? object.infrastructure = false if object.infrastructure.nil? object.is_biz_process = true if @importer.options[:is_biz_process] else if object...
Ruby
class ControlRowConverter < BaseRowConverter @model_class = :Control def setup_object object = setup_object_by_slug(attrs) if object.directive.present? && object.directive != @importer.options[:directive] add_error(:slug, "Code is used in #{object.directive.meta_kind.to_s.titleize}: #{object.directi...
Ruby
class RiskRowConverter < BaseRowConverter @model_class = :Risk def setup_object object = setup_object_by_slug(attrs) if !object.new_record? add_warning(:slug, "Risk already exists and will be updated") end end def reify handle(:slug, SlugColumnHandler) handle(:controls, LinkControl...
Ruby
require 'csv' class ImportException < Exception end class BaseConverter attr_accessor :rows, :objects, :all_objects, :options, :warnings, :errors, :slugs def initialize(rows_or_objects, options=nil) @options = options || {} if @options[:export] @objects = rows_or_objects @rows = [] els...
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
Rails.backtrace_cleaner.remove_silencers!
Ruby
require 'gdoc' require 'gdoc/document'
Ruby
module CmsRails class Application < Rails::Application def self.sso_callback_url @@sso_callback rescue nil end def self.sso_callback_url=(url) @@sso_callback = url end end end
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. # 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. CmsRails::Application.config.session_store :encrypted_cookie_store, :key => '_cms_session_id' # 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 ...
Ruby
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
require 'sinatra/activerecord/rake' require './main'
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
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
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
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
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
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
require 'sinatra/activerecord/rake' require './main'
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
#!/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
#!/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/runner'
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/server'
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/plugin'
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/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/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/process/inspector'
Ruby