code
stringlengths
1
1.73M
language
stringclasses
1 value
module ActiveBackground module DatabaseHandler def database(attempt=0, &block) database = ActiveBackground::Database.instance database.lock # TODO: Optimize code and remove double checks begin db = Thread.new do begin database.prepare self.i...
Ruby
module ActiveBackground # ActiveBackground server is responsible for setting up a DRb server # with a ActiveBackground::Manager instance (Singleton). # # == Creation # # ActiveBackground::Server uses a ActiveBackground:Manager instance # to start a DRb server based on the configuration file. It i...
Ruby
module ActiveBackground class Worker < ActiveBackground::Job def initialize(name, options={}, args={}) options[:file] = File.expand_path(__FILE__) options[:class] = self.class.to_s super(name, options, args) @worker_threads = Hash.new end def process # start work...
Ruby
module ActiveBackground class Queue < ActiveBackground::Job def process_job # advanced job handeling (including queue handeling....) end end end
Ruby
module ActiveBackground module Handler class Job < ActiveBackground::Handler::Base # initialize implementation by including the default worker directories def initialize super @job_dirs = @config.job.dirs @job_files = Hash.new @config.job...
Ruby
module ActiveBackground module Handler class Cache < ActiveBackground::Handler::Base def initialize super end end end end
Ruby
module ActiveBackground module Handler class Base < ActiveBackground::Base def initialize super @config = ActiveBackground::Configuration.instance @middle_man = ActiveBackground::MiddleManProxy.instance @logger = @config.logger end end end end
Ruby
module ActiveBackground class Client < Base include Singleton @@server = false def initialize end # this method is called before every method def prepare begin # try to connect again if @@server is LocalCache connect unless @@server if...
Ruby
module ActiveBackground # some methods to convert the keys from symbols to strings # and back again.... # FIXME: Need to change the way configurations are processed (not when setting but when done) class Configuration include Singleton attr_accessor :environment, :initialization, :exclud...
Ruby
module ActiveBackground class Archive end end
Ruby
module ActiveBackground class Manager < Base attr_accessor :config def initialize @jobs = Hash.new @queue = Hash.new @running = true @lock = Monitor.new @threads = Hash.new @terminated = nil @logger = ACTIVE_BACKGROUND_CONFIG.logger @confi...
Ruby
module ActiveBackground class Job < Base include DRbUndumped include ActiveBackground::DatabaseHandler # # Arguments: # <tt>name</tt>: Name of the job (doesn't have to be uniq but similar jobs should get the same name)j # <tt>options</tt>: Options that configure the...
Ruby
module ActiveBackground class Assistent end end
Ruby
module ActiveBackground class Negotiator end end
Ruby
module ActiveBackground class Slave < ActiveBackground::Server end end
Ruby
module ActiveBackground # MiddleMan Proxy is a class that makes sure that calls passed to # MiddleMan are processed. Making sure that there is a connection # established or commands are cached till the server comes back. class MiddleManProxy include Singleton attr_reader :messages attr_...
Ruby
# Workaround a problem with script/plugin and http-based repos. # See http://dev.rubyonrails.org/ticket/8189 Dir.chdir(Dir.getwd.sub(/vendor.*/, '')) do ## ## Copy over asset files (javascript/css/images) from the plugin directory to public/ ## def copy_files(source_path, destination_path, directory) source, destin...
Ruby
require "#{File.dirname __FILE__}/lib/search" require "#{File.dirname __FILE__}/lib/extensions/java_script_macros_helper" require "#{File.dirname __FILE__}/lib/actions/field_search" require "#{File.dirname __FILE__}/lib/actions/print_list" require "#{File.dirname __FILE__}/lib/actions/customize" require "#{File.dirna...
Ruby
# Make sure that ActiveScaffold has already been included ActiveScaffold rescue throw "should have included ActiveScaffold plug in first. Please make sure that this overwrite plugging comes alphabetically after the ActiveScaffold plug in" ## ## Initialize the environment ## require File.dirname(__FILE__) + '/environm...
Ruby
require "rails_generator/generators/components/scaffold/scaffold_generator" class ActiveScaffoldingSandbox < ScaffoldingSandbox #:nodoc: def default_input_block input_block = Proc.new { |record, column| " <li class=\"form-element <%= 'required' if active_scaffold_config.columns[:#{column.name}].required? %...
Ruby
class <%= controller_class_name %>Controller < ApplicationController before_filter :authorize <%= template_for_inclusion %> protected # =================== # = Authorize BEGIN = # =================== def create_authorized? permit? [:super] end def delete_authorized? permit? [:super]...
Ruby
class <%= controller_class_name -%>Controller < ApplicationController <%= template_for_inclusion %> end
Ruby
module <%= controller_class_name -%>Helper end
Ruby
# == Schema Information<% version = ActiveRecord::Migrator.current_version rescue 0 klass = class_name.constantize if version > 0 %> # Schema version: <%= version %><% end %> # # Table name: <%= klass.table_name %> # <% max_size = klass.column_names.collect{|name| name.size}.max + 1 klass.columns.each do |col| attrs...
Ruby
module ActionView module Helpers module JavaScriptMacrosHelper # Fix html_escape issues with url_for. def in_place_editor(field_id, options = {}) function = "new Ajax.InPlaceEditor(" function << "'#{field_id}', " function << "'#{url_for(options[:url])}'".gsub("&amp;", "&") ...
Ruby
module ActiveScaffold module Helpers module ViewHelpers # Add the tools plugin includes def active_scaffold_includes_with_tools(frontend = :default) js = javascript_include_tag(ActiveScaffold::Config::Core.asset_path('input_box.js', frontend)) js << javascript_include_tag(ActiveScaffol...
Ruby
module ActiveScaffold module Helpers # A bunch of helper methods to produce the common view ids module Ids def customize_form_id "#{controller_id}-customize-form" end def nested_id(options = {}) options[:action] = :nested element_row_id(options) end def...
Ruby
module ActiveScaffold module Helpers module ListColumns def active_scaffold_column_percentage(column, record) number_to_percentage(record[column.name].to_s, :precision => 1) end def active_scaffold_column_ssn(column, record) usa_number_to_ssn(record[column.name].to_s) end ...
Ruby
module ActionView module Helpers # Provides methods for converting a number into a formatted string that currently represents # one of the following forms: phone number, percentage, money, or precision level. module NumberHelper # Formats a +number+ into a US ssn number string. The +options+ can be ...
Ruby
module ActiveScaffold module Helpers # Helpers that assist with the rendering of a Form Column module FormColumns def active_scaffold_input_for_search(column, options = {}, scope = nil) options[:name] ||= "search[#{column.name}]" options[:id] ||= "search_#{column.name}" if overri...
Ruby
module ActiveScaffold::Actions module PrintList include ActiveScaffold::Search protected def do_print_list(print_list_config) active_scaffold_config.list.empty_field_text = print_list_config.empty_field_text includes_for_print_list_columns = active_scaffold_tools_list_columns.collect{ |c|...
Ruby
module ActiveScaffold::Actions module ExportTool include ActiveScaffold::Actions::PrintList def self.included(base) base.before_filter :export_tool_authorized?, :only => [:export_tool] base.before_filter :store_search_session_info end def show_export_tool respond_to do |wants| ...
Ruby
module ActiveScaffold::Actions module FieldSearch include ActiveScaffold::Search def self.included(base) base.before_filter :field_search_authorized?, :only => :show_search base.before_filter :store_search_session_info base.before_filter :do_search end # FieldSearch uses params[:sea...
Ruby
#TODO 2007-11-16 (EJM) Level=0 - Ignore lock_version module ActiveScaffold::Actions module Customize include ActiveScaffold::Actions::PrintList def self.included(base) base.before_filter :customize_authorized?, :only => [:customize] base.before_filter :store_custum_list base.before_filter :d...
Ruby
module ActiveScaffold::Actions module PrintHtml include ActiveScaffold::Actions::PrintList def self.included(base) base.before_filter :print_html_authorized?, :only => [:print_html] base.before_filter :store_search_session_info end def print_html do_print_list active_scaffold_config...
Ruby
module ActiveScaffold::Actions module PrintPdf include ActiveScaffold::Actions::PrintList def self.included(base) base.before_filter :print_pdf_authorized?, :only => [:print_pdf] base.before_filter :store_search_session_info end def print_pdf do_print_list active_scaffold_config.pri...
Ruby
module ActiveScaffold::Actions module List include ActiveScaffold::Search def list reset_search_session_info do_list respond_to do |type| type.html { render :action => 'list', :layout => true } type.xml { render :xml => response_object.to_xml, :content_type...
Ruby
module ActiveScaffold module Search def reset_search_session_info active_scaffold_session_storage[:search] = {} end def store_search_session_info active_scaffold_session_storage[:search] = params[:search] if params[:search] || params[:commit] == as_('Search') end end end
Ruby
module ActiveScaffold::Config class PrintList < Base self.crud_type = :read def initialize(core_config) @core = core_config # inherit from global scope @empty_field_text = self.class.empty_field_text end # global level configuration # -------------------------- # the ...
Ruby
module ActiveScaffold::Config class Core # configures where the active_scaffold_tools plugin itself is located. there is no instance version of this. cattr_accessor :tools_plugin_directory @@tools_plugin_directory = File.expand_path(__FILE__).match(/vendor\/plugins\/([^\/]*)/)[1] cattr_accessor :left...
Ruby
module ActiveScaffold::Config class ExportTool < Base self.crud_type = :read def initialize(core_config) @core = core_config # inherit from global scope @empty_field_text = self.class.empty_field_text @delimiter = self.class.delimiter @force_quotes = self.class.force_quotes ...
Ruby
module ActiveScaffold::Config class Customize < Base self.crud_type = :read def initialize(core_config) @core = core_config # inherit from global scope end # global level configuration # -------------------------- # the ActionLink for this action cattr_reader :link @@li...
Ruby
module ActiveScaffold::Config class PrintHtml < PrintList self.crud_type = :read def initialize(*args) super end # global level configuration # -------------------------- # the ActionLink for this action cattr_reader :link @@link = ActiveScaffold::DataStructures::ActionLin...
Ruby
module ActiveScaffold::Config class PrintPdf < PrintList self.crud_type = :read def initialize(*args) super # inherit from global scope @font_size = self.class.font_size @footer_font_size = self.class.footer_font_size @header_font_size = self.class.header_font_size @head...
Ruby
module ActiveScaffold::Config class Core < Base def initialize_with_checkbox(model_id) initialize_without_checkbox(model_id) checkbox_fields = self.model.columns.collect{|c| c.name.to_sym if [:boolean].include?(c.type) }.compact # check to see if file column was used on the model ...
Ruby
module ActiveScaffold::Config class Core < Base def initialize_with_dhtml_calendar(model_id) initialize_without_dhtml_calendar(model_id) dhtml_calendar_fields = self.model.columns.collect{|c| c.name.to_sym if [:date, :datetime].include?(c.type) }.compact # check to see if file col...
Ruby
# Workaround a problem with script/plugin and http-based repos. # See http://dev.rubyonrails.org/ticket/8189 Dir.chdir(Dir.getwd.sub(/vendor.*/, '')) do ## ## Copy over asset files (javascript/css/images) from the plugin directory to public/ ## def copy_files(source_path, destination_path, directory) source, destin...
Ruby
require "#{File.dirname __FILE__}/lib/search" require "#{File.dirname __FILE__}/lib/extensions/java_script_macros_helper" require "#{File.dirname __FILE__}/lib/actions/field_search" require "#{File.dirname __FILE__}/lib/actions/print_list" require "#{File.dirname __FILE__}/lib/actions/customize" require "#{File.dirna...
Ruby
# Make sure that ActiveScaffold has already been included ActiveScaffold rescue throw "should have included ActiveScaffold plug in first. Please make sure that this overwrite plugging comes alphabetically after the ActiveScaffold plug in" ## ## Initialize the environment ## require File.dirname(__FILE__) + '/environm...
Ruby
require "rails_generator/generators/components/scaffold/scaffold_generator" class ActiveScaffoldingSandbox < ScaffoldGenerator #:nodoc: def default_input_block input_block = Proc.new { |record, column| " <li class=\"form-element <%= 'required' if active_scaffold_config.columns[:#{column.name}].required? %>...
Ruby
class <%= controller_class_name %>Controller < ApplicationController before_filter :authorize <%= template_for_inclusion %> protected # =================== # = Authorize BEGIN = # =================== def create_authorized? permit? [:super] end def delete_authorized? permit? [:super]...
Ruby
class <%= controller_class_name -%>Controller < ApplicationController <%= template_for_inclusion %> end
Ruby
module <%= controller_class_name -%>Helper end
Ruby
# == Schema Information<% version = ActiveRecord::Migrator.current_version rescue 0 klass = class_name.constantize if version > 0 %> # Schema version: <%= version %><% end %> # # Table name: <%= klass.table_name %> # <% max_size = klass.column_names.collect{|name| name.size}.max + 1 klass.columns.each do |col| attrs...
Ruby
module ActionView module Helpers module JavaScriptMacrosHelper # Fix html_escape issues with url_for. def in_place_editor(field_id, options = {}) function = "new Ajax.InPlaceEditor(" function << "'#{field_id}', " function << "'#{url_for(options[:url])}'".gsub("&amp;", "&") ...
Ruby
# Can't name this view_helpers.rb module ActiveScaffold module Helpers module ViewHelpers def active_scaffold_includes_with_tools(frontend = :default) js = javascript_include_tag(ActiveScaffold::Config::Core.asset_path('input_box.js', frontend)) js << javascript_include_tag(ActiveScaffold::C...
Ruby
module ActiveScaffold module Helpers # A bunch of helper methods to produce the common view ids module Ids def customize_form_id "#{controller_id}-customize-form" end def nested_id(options = {}) options[:action] = :nested element_row_id(options) end def...
Ruby
module ActiveScaffold module Helpers module ListColumns def active_scaffold_column_percentage(column, record) number_to_percentage(record[column.name].to_s, :precision => 1) end def active_scaffold_column_ssn(column, record) usa_number_to_ssn(record[column.name].to_s) end ...
Ruby
module ActionView module Helpers # Provides methods for converting a number into a formatted string that currently represents # one of the following forms: phone number, percentage, money, or precision level. module NumberHelper # Formats a +number+ into a US ssn number string. The +options+ can be ...
Ruby
module ActiveScaffold module Helpers # Helpers that assist with the rendering of a Form Column module FormColumns def active_scaffold_input_for_search(column, options = {}, scope = nil) options[:name] ||= "search[#{column.name}]" options[:id] ||= "search_#{column.name}" if overri...
Ruby
module ActiveScaffold::Actions module PrintList include ActiveScaffold::Search protected def do_print_list(print_list_config) active_scaffold_config.list.empty_field_text = print_list_config.empty_field_text includes_for_print_list_columns = active_scaffold_tools_list_columns.collect{ |c|...
Ruby
module ActiveScaffold::Actions module ExportTool include ActiveScaffold::Actions::PrintList def self.included(base) base.before_filter :export_tool_authorized?, :only => [:export_tool] base.before_filter :store_search_session_info end def show_export_tool respond_to do |wants| ...
Ruby
module ActiveScaffold::Actions module FieldSearch include ActiveScaffold::Search def self.included(base) base.before_filter :field_search_authorized?, :only => :show_search base.before_filter :store_search_session_info base.before_filter :do_search end # FieldSearch uses params[:sea...
Ruby
#TODO 2007-11-16 (EJM) Level=0 - Ignore lock_version module ActiveScaffold::Actions module Customize include ActiveScaffold::Actions::PrintList def self.included(base) base.before_filter :customize_authorized?, :only => [:customize] base.before_filter :store_custum_list base.before_filter :d...
Ruby
module ActiveScaffold::Actions module PrintHtml include ActiveScaffold::Actions::PrintList def self.included(base) base.before_filter :print_html_authorized?, :only => [:print_html] base.before_filter :store_search_session_info end def print_html do_print_list active_scaffold_config...
Ruby
module ActiveScaffold::Actions module PrintPdf include ActiveScaffold::Actions::PrintList def self.included(base) base.before_filter :print_pdf_authorized?, :only => [:print_pdf] base.before_filter :store_search_session_info end def print_pdf do_print_list active_scaffold_config.pri...
Ruby
module ActiveScaffold::Actions module List include ActiveScaffold::Search def list reset_search_session_info do_list respond_to do |type| type.html { render :action => 'list', :layout => true } type.xml { render :xml => response_object.to_xml, :content_type...
Ruby
module ActiveScaffold module Search def reset_search_session_info active_scaffold_session_storage[:search] = {} end def store_search_session_info active_scaffold_session_storage[:search] = params[:search] if params[:search] || params[:commit] == as_('Search') end end end
Ruby
module ActiveScaffold::Config class PrintList < Base self.crud_type = :read def initialize(core_config) @core = core_config # inherit from global scope @empty_field_text = self.class.empty_field_text @maximum_rows = self.class.maximum_rows end # global level configurati...
Ruby
module ActiveScaffold::Config class Core # configures where the active_scaffold_tools plugin itself is located. there is no instance version of this. cattr_accessor :tools_plugin_directory @@tools_plugin_directory = File.expand_path(__FILE__).match(/vendor\/plugins\/([^\/]*)/)[1] cattr_accessor :left...
Ruby
module ActiveScaffold::Config class ExportTool < PrintList self.crud_type = :read def initialize(core_config) super # inherit from global scope @delimiter = self.class.delimiter @force_quotes = self.class.force_quotes @skip_header = self.class.skip_header end # global...
Ruby
module ActiveScaffold::Config class Customize < Base self.crud_type = :read def initialize(core_config) @core = core_config # inherit from global scope end # global level configuration # -------------------------- # the ActionLink for this action cattr_reader :link @@li...
Ruby
module ActiveScaffold::Config class PrintHtml < PrintList self.crud_type = :read def initialize(*args) super end # global level configuration # -------------------------- # the ActionLink for this action cattr_reader :link @@link = ActiveScaffold::DataStructures::ActionLin...
Ruby
module ActiveScaffold::Config class PrintPdf < PrintList self.crud_type = :read def initialize(*args) super # inherit from global scope @font_size = self.class.font_size @footer_font_size = self.class.footer_font_size @header_font_size = self.class.header_font_size @head...
Ruby
module ActiveScaffold::Config class Core < Base def initialize_with_checkbox(model_id) initialize_without_checkbox(model_id) checkbox_fields = self.model.columns.collect{|c| c.name.to_sym if [:boolean].include?(c.type) }.compact # check to see if file column was used on the model ...
Ruby
module ActiveScaffold::Config class Core < Base def initialize_with_dhtml_calendar(model_id) initialize_without_dhtml_calendar(model_id) dhtml_calendar_fields = self.model.columns.collect{|c| c.name.to_sym if [:date, :datetime].include?(c.type) }.compact # check to see if file col...
Ruby
require 'action_sms'
Ruby
require 'rake' require 'rake/testtask' require 'rake/rdoctask' desc 'Default: run unit tests.' task :default => :test desc 'Test the action_sms plugin.' Rake::TestTask.new(:test) do |t| t.libs << 'lib' t.pattern = 'test/**/*_test.rb' t.verbose = true end desc 'Generate documentation for the action_sms plugin.'...
Ruby
# desc "Explaining what the task does" # task :action_sms do # # Task goes here # end
Ruby
# Uninstall hook code here
Ruby
# Install hook code here
Ruby
ActionMailer::Base.class_eval do private def perform_delivery_smtp_with_sms(mail) perform_delivery_sms(mail) perform_delivery_smtp_without_sms(clean_numbers_from_destinations(mail)) end def perform_delivery_sendmail_with_sms(mail) perform_delivery_sms(mail) perform_delivery_se...
Ruby
require 'net/http' require 'uri' class MovistarGateway URL = 'https://opensms.movistar.es/aplicacionpost/loginEnvio.jsp' def initialize(login, password) @login = login.to_s @password = password.to_s end def send(destinations, message) numbers = destinations.find_all do |destination| destin...
Ruby
require 'action_sms'
Ruby
require 'rake' require 'rake/testtask' require 'rake/rdoctask' desc 'Default: run unit tests.' task :default => :test desc 'Test the action_sms plugin.' Rake::TestTask.new(:test) do |t| t.libs << 'lib' t.pattern = 'test/**/*_test.rb' t.verbose = true end desc 'Generate documentation for the action_sms plugin.'...
Ruby
# desc "Explaining what the task does" # task :action_sms do # # Task goes here # end
Ruby
# Uninstall hook code here
Ruby
# Install hook code here
Ruby
ActionMailer::Base.class_eval do private def perform_delivery_smtp_with_sms(mail) perform_delivery_sms(mail) perform_delivery_smtp_without_sms(clean_numbers_from_destinations(mail)) end def perform_delivery_sendmail_with_sms(mail) perform_delivery_sms(mail) perform_delivery_se...
Ruby
require 'net/http' require 'uri' class MovistarGateway URL = 'https://opensms.movistar.es/aplicacionpost/loginEnvio.jsp' def initialize(login, password) @login = login.to_s @password = password.to_s end def send(destinations, message) numbers = destinations.find_all do |destination| destin...
Ruby
## batch_create Dir["#{File.dirname __FILE__}/lib/*.rb"].each { |file| require file } # install files unless File.exists?(RAILS_ROOT + '/public/javascripts/active_scaffold_ext/active_scaffold_ext.js') ['/public', '/public/javascripts/active_scaffold_ext', '/public/stylesheets/active_scaffold_ext', '/public/...
Ruby
require 'rake' require 'rake/testtask' require 'rake/packagetask' require 'rake/rdoctask' require 'find' desc 'Default: run unit tests.' task :default => :test desc 'Test ActiveScaffold Extensions.' Rake::TestTask.new(:test) do |t| t.libs << 'lib' t.pattern = 'test/**/*_test.rb' t.verbose = true end desc 'Gene...
Ruby
require 'exceptions' ## ## Check for dependencies ## version = Rails::VERSION::STRING.split(".") if version[0] < "1" or (version[0] == "1" and version[1] < "2") message = <<-EOM ************************************************************************ Rails 1.2.1 or greater is required. Please remove ActiveSc...
Ruby
module ActiveScaffold module Helpers module ViewHelpers def ext_includes(*args) return "" if @ext_already_included @ext_already_included=true #options = (Hash === args.last) ? args.pop : {} #options.assert_valid_keys(:style, :format, :locale) #locale = optio...
Ruby
module ActiveScaffold::DataStructures class ActionLink # true or false(nil) attr_accessor :macro end end module ActiveScaffold::Config class Core < Base def add_macro(action, options={}) @action_links.add(action, options.merge({:type => :table, :position => false, ...
Ruby
module ActiveScaffold::Config # batch-create do not support columns of plural-associations class BatchCreate < Form self.crud_type = :create def initialize(*args) super @columns = @core.create.columns.dup self.persistent = self.class.persistent end # global level configuration ...
Ruby
# field_search for date range module ActiveScaffold module Finder DateUnits = [ ["Days", :day], ["Weeks", :week], ["Months", :month], ["Years", :year] ] DateRanges = [ ["Today", "TODAY"], ["Yesterday", "YESTERDAY"], ["This Week", "THIS_WEEK"], ["Previous...
Ruby
# filter module ActiveScaffold::Actions module List def filter filter_cookie = "#{controller_name}_filter" filter_name = params[:name] || cookies[filter_cookie] cookies[filter_cookie] = filter_name if filter_name redirect_to (active_scaffold_config.list.get_filter_conditions(filter_name) ...
Ruby
puts IO.read(File.join(File.dirname(__FILE__), 'README'))
Ruby
class AuthenticatedMailerGenerator < Rails::Generator::NamedBase def manifest record do |m| # Check for class naming collisions. m.class_collisions class_path, "#{class_name}Notifier", "#{class_name}NotifierTest", "#{class_name}Observer" # Controller, helper, views, and test directories. ...
Ruby