code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
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 |
source :gemcutter
gem 'sinatra', :require => 'sinatra/base'
gem 'thin', '~> 1.3'
gem 'pg'
gem 'data_mapper', '~> 1.2'
gem 'dm-postgres-adapter'
gem 'google-api-client', '>= 0.4.3'
group :development do
gem 'dm-sqlite-adapter', '~> 1.2'
gem 'do_sqlite3', '~> 0.10'
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 |
description "Unit tests for the Zen Grids system."
stylesheet 'sass/function-zen-direction-flip.scss', :media => 'all', :to => 'function-zen-direction-flip.scss'
stylesheet 'sass/function-zen-grid-item-width.scss', :media => 'all', :to => 'function-zen-grid-item-width.scss'
stylesheet 'sass/function-zen-half-gutter.s... | Ruby |
description "The Zen Grids system."
stylesheet 'common.scss', :media => 'all'
stylesheet 'layout.scss', :media => 'all'
stylesheet 'styles.scss', :media => 'all'
html 'example.html'
help %Q{
Zen Grids is an intuitive, flexible grid system that leverages the natural source order of your content to make it easier to c... | Ruby |
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = 'zen-grids'
s.summary = %q{A Compass plugin for Zen Grids, a fluid responsive grid system}
s.description = %q{Zen Grids is an intuitive, flexible grid system that leverages the natural source order of your content to make it easier to c... | Ruby |
require 'compass'
extension_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
Compass::Frameworks.register('zen-grids', :path => extension_path)
| Ruby |
#
# This file is only needed for Compass/Sass integration. If you are not using
# Compass, you may safely ignore or delete this file.
#
# If you'd like to learn more about Sass and Compass, see the sass/README.txt
# file for more information.
#
# Change this to :production when ready to deploy the CSS to the live ser... | Ruby |
description "Unit tests for the Zen Grids system."
stylesheet 'sass/function-zen-direction-flip.scss', :media => 'all', :to => 'function-zen-direction-flip.scss'
stylesheet 'sass/function-zen-grid-item-width.scss', :media => 'all', :to => 'function-zen-grid-item-width.scss'
stylesheet 'sass/function-zen-half-gutter.s... | Ruby |
description "The Zen Grids system."
stylesheet 'common.scss', :media => 'all'
stylesheet 'layout.scss', :media => 'all'
stylesheet 'styles.scss', :media => 'all'
html 'example.html'
help %Q{
Zen Grids is an intuitive, flexible grid system that leverages the natural source order of your content to make it easier to c... | Ruby |
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = 'zen-grids'
s.summary = %q{A Compass plugin for Zen Grids, a fluid responsive grid system}
s.description = %q{Zen Grids is an intuitive, flexible grid system that leverages the natural source order of your content to make it easier to c... | Ruby |
require 'compass'
extension_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
Compass::Frameworks.register('zen-grids', :path => extension_path)
| Ruby |
#
# This file is only needed for Compass/Sass integration. If you are not using
# Compass, you may safely ignore or delete this file.
#
# If you'd like to learn more about Sass and Compass, see the sass/README.txt
# file for more information.
#
# Change this to :production when ready to deploy the CSS to the live ser... | Ruby |
description "Unit tests for the Zen Grids system."
stylesheet 'sass/function-zen-direction-flip.scss', :media => 'all', :to => 'function-zen-direction-flip.scss'
stylesheet 'sass/function-zen-grid-item-width.scss', :media => 'all', :to => 'function-zen-grid-item-width.scss'
stylesheet 'sass/function-zen-half-gutter.s... | Ruby |
description "The Zen Grids system."
stylesheet 'common.scss', :media => 'all'
stylesheet 'layout.scss', :media => 'all'
stylesheet 'styles.scss', :media => 'all'
html 'example.html'
help %Q{
Zen Grids is an intuitive, flexible grid system that leverages the natural source order of your content to make it easier to c... | Ruby |
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = 'zen-grids'
s.summary = %q{A Compass plugin for Zen Grids, a fluid responsive grid system}
s.description = %q{Zen Grids is an intuitive, flexible grid system that leverages the natural source order of your content to make it easier to c... | Ruby |
require 'compass'
extension_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
Compass::Frameworks.register('zen-grids', :path => extension_path)
| Ruby |
#
# This file is only needed for Compass/Sass integration. If you are not using
# Compass, you may safely ignore or delete this file.
#
# If you'd like to learn more about Sass and Compass, see the sass/README.txt
# file for more information.
#
# Change this to :production when ready to deploy the CSS to the live ser... | Ruby |
description "Unit tests for the Zen Grids system."
stylesheet 'sass/function-zen-direction-flip.scss', :media => 'all', :to => 'function-zen-direction-flip.scss'
stylesheet 'sass/function-zen-grid-item-width.scss', :media => 'all', :to => 'function-zen-grid-item-width.scss'
stylesheet 'sass/function-zen-half-gutter.s... | Ruby |
description "The Zen Grids system."
stylesheet 'common.scss', :media => 'all'
stylesheet 'layout.scss', :media => 'all'
stylesheet 'styles.scss', :media => 'all'
html 'example.html'
help %Q{
Zen Grids is an intuitive, flexible grid system that leverages the natural source order of your content to make it easier to c... | Ruby |
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = 'zen-grids'
s.summary = %q{A Compass plugin for Zen Grids, a fluid responsive grid system}
s.description = %q{Zen Grids is an intuitive, flexible grid system that leverages the natural source order of your content to make it easier to c... | Ruby |
require 'compass'
extension_path = File.expand_path(File.join(File.dirname(__FILE__), ".."))
Compass::Frameworks.register('zen-grids', :path => extension_path)
| Ruby |
#
# This file is only needed for Compass/Sass integration. If you are not using
# Compass, you may safely ignore or delete this file.
#
# If you'd like to learn more about Sass and Compass, see the sass/README.txt
# file for more information.
#
# Change this to :production when ready to deploy the CSS to the live ser... | Ruby |
# Include hook code here
require 'middleman_rails_init'
| Ruby |
module RDoc
module Page
FONTS = "\"Bitstream Vera Sans\", Verdana, Arial, Helvetica, sans-serif"
STYLE = <<CSS
a {
color: #00F;
text-decoration: none;
}
a:hover {
color: #77F;
text-decoration: underline;
}
body, td, p {
font-family: %fonts%;
background: #FFF;
color: #000;
margin: 0px;
font-size: s... | Ruby |
class SampleWorker < BackgrounDRb::Rails
attr_reader :progress
def do_work(args)
@progress = 0
while @progress < 50
puts @progress
@progress += 1
sleep 0.0001
end
done_working!
end
end
SampleWorker.register
| Ruby |
class RailsWorker < BackgrounDRb::Worker::RailsBase
def do_work
sleep 10000
end
def progress
"this is worker2 progress"
ActiveRecord.methods
end
end
| Ruby |
class DrbController < ApplicationController
def index
end
def start
if request.xhr?
session[:job_key] =
::MiddleMan.new_worker(:class => :progress_worker,
:args => {:text => 'this text has been sent to the worker.'})
render :update do |page|
page.... | Ruby |
class ProgressWorker < BackgrounDRb::Worker::RailsBase
attr_accessor :text
def do_work(args)
results[:progress] = 0
@text = args[:text]
while results[:progress] < 100
sleep rand / 2
a = [1,3,5,7]
results[:progress] += a[rand(a.length-1)]
if results[:progress] >= 100... | Ruby |
class WorkerGenerator < Rails::Generator::NamedBase
def manifest
record do |m|
# Check for class naming collisions.
m.class_collisions class_path, class_name, "#{class_name}WorkerTest"
# Worker and test directories.
m.directory File.join('lib/workers', class_path)
#m.directory File.... | Ruby |
# Put your code that runs your task inside the do_work method it will be
# run automatically in a thread. You have access to all of your rails
# models. You also get logger and results method inside of this class
# by default.
class <%= class_name %>Worker < BackgrounDRb::Worker::RailsBase
def do_work(args)
#... | Ruby |
$:.unshift(File.dirname(__FILE__) + '/../lib')
$:.unshift(File.dirname(__FILE__) + '/../server/lib')
require 'rubygems'
require 'spec'
require 'drb'
require 'singleton'
root = File.expand_path(File.dirname(__FILE__) + '/data/server')
BACKGROUNDRB_ROOT = root unless defined?(BACKGROUNDRB_ROOT)
BACKGROUNDRB_CODE = Dir... | Ruby |
# run with server:
# ./script/backgroundrb run -- -w ./specs/data/server/workers
#
# we use this script to check issues with having many slaves active
# simultaneously.
#
# we see occasional failed worker creation attempts right now with this
#
require 'drb'
max = ARGV[0]
unless max
max = 100
end
DRb.start_service... | Ruby |
class ResultsParallelWorker < BackgrounDRb::Worker::Base
def do_work(args)
args.times do |counter|
results[:data] = Time.now
results[:counter] = counter
end
end
end
ResultsParallelWorker.register
| Ruby |
class RSSWorker < BackgrounDRb::Worker::Base
require 'rss'
require 'net/http'
def do_work(args)
end
# This will fail since rss.parse will return non-serializable data
def simple_rss
Net::HTTP.start('www.mozilla.org') do |http|
response = http.get('/news.rdf')
fail response.code unless resp... | Ruby |
class SimpleWorker < BackgrounDRb::Worker::Base
def do_work(args)
logger.info "logging do_work with args: #{args}"
end
def simple_work
"simple string returned from worker"
end
def simple_result
results[:simple] = "simple result string"
end
def simple_work_with_logging
logger.info 'loggi... | Ruby |
class TimeoutWorker < BackgrounDRb::Worker::Base
require 'timeout'
def do_work(args)
results[:timeout] = self.rescued_timeout
end
def simple_timeout
Timeout::timeout(3) { sleep 5 }
end
def rescued_timeout
begin
self.simple_timeout
rescue Timeout::Error
"timed out"
end
en... | Ruby |
class DoWorkWithArgWorker < BackgrounDRb::Worker::Base
def do_work(args)
results[:from_do_work] = args
end
end
DoWorkWithArgWorker.register
| Ruby |
require 'rake'
require 'rubygems'
require 'rake/testtask'
require 'rake/rdoctask'
require 'spec/rake/spectask'
require 'rake/contrib/sshpublisher'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the backgroundrb plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_tes... | Ruby |
#!/usr/bin/env ruby
require 'pathname'
script_dir = Pathname.new(File.dirname(__FILE__)).realpath
rails_script = script_dir + '../vendor/plugins/backgroundrb/script'
plugin_script = script_dir + '../../../../vendor/plugins/backgroundrb/script'
if rails_script.directory?
rails_root = script_dir + '../'
elsif plugin... | Ruby |
#!/usr/bin/env ruby
require 'pathname'
script_dir = Pathname.new(File.dirname(__FILE__)).realpath
rails_script = script_dir + '../vendor/plugins/backgroundrb/script'
plugin_script = script_dir + '../../../../vendor/plugins/backgroundrb/script'
if rails_script.directory?
rails_root = script_dir + '../'
elsif plugin... | Ruby |
namespace :backgroundrb do
require 'yaml'
desc 'Setup backgroundrb in your rails application'
task :setup do
script_dest = "#{RAILS_ROOT}/script/backgroundrb"
script_src = File.dirname(__FILE__) + "/../script/backgroundrb"
FileUtils.chmod 0774, script_src
defaults = {:host => 'localhost',
... | Ruby |
require 'rubygems'
require 'daemons'
require 'fastthread'
require 'backgroundrb'
require 'backgroundrb/middleman'
require 'backgroundrb/scheduler'
require 'backgroundrb/console'
require 'optparse'
require 'tmpdir'
require 'fileutils'
require 'drb/acl'
module BackgrounDRb
end
class BackgrounDRb::ServerScheduler
def ... | Ruby |
require 'drb'
require 'logger'
require 'monitor'
require 'backgroundrb/middleman'
module BackgrounDRb
module Worker
class Base
include DRbUndumped
attr_reader :jobkey
attr_accessor :results
attr_accessor :initial_do_work
class << self
def register
MiddleMan.inst... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.