code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
# Copyright (c) 2007 Fabio Makoto Akita
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,... | Ruby |
class CreateReplicas < ActiveRecord::Migration
def self.up
create_table :replicas do |t|
t.column :crud, :string, :default => "", :null => false
t.column :for_id, :string, :limit => 36
t.column :for_machine_id, :string, :limit => 36
t.column :met... | Ruby |
# Copyright (c) 2007 Fabio Makoto Akita
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,... | Ruby |
# Copyright (c) 2007 Fabio Makoto Akita
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,... | Ruby |
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the acts_as_replica plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'Generate documentation for the acts_as_replic... | Ruby |
# Copyright (c) 2007 Fabio Makoto Akita
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,... | Ruby |
# Copyright (c) 2007 Fabio Makoto Akita
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,... | Ruby |
module ActiveRecord
# Active Records will automatically record the user who created and/or updated a database objects
# if fields of the names created_by/created_by are present.
#
# This module requires that your user object (which by default is <tt>User</tt> but can be changed
# using the <tt>user_model... | Ruby |
# Copyright (c) 2007 Fabio Makoto Akita
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,... | Ruby |
# Copyright (c) 2007 Fabio Makoto Akita
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,... | Ruby |
# Copyright (c) 2007 Fabio Makoto Akita
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,... | Ruby |
module UpgradesHelper
def log_timestamp
Time.now.iso8601
end
def log_fmt_timestamp(time)
[(time/3600).to_i, (time/60 % 60).to_i, (time % 60).to_i].map{|t| t.to_s.rjust(2,'0')}.join(':')
end
# create or delete the process semaphore
def upgrade_semaphore_deal(create = true)
semaphore_file = ... | Ruby |
# Copyright (c) 2007 Fabio Makoto Akita
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,... | Ruby |
# Copyright (c) 2007 Fabio Makoto Akita
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,... | Ruby |
# Copyright (c) 2007 Fabio Makoto Akita
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,... | Ruby |
# Copyright (c) 2007 Fabio Makoto Akita
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,... | Ruby |
require 'acts_as_commentable'
ActiveRecord::Base.send(:include, ActiveRecord::Acts::Commentable)
| Ruby |
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the acts_as_commentable plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'Generate documentation for the acts_as_co... | Ruby |
# desc "Explaining what the task does"
# task :acts_as_commentable do
# # Task goes here
# end
| Ruby |
# Uninstall hook code here
| Ruby |
# Install hook code here
| Ruby |
module ActiveRecord
module Acts
module Commentable
def self.included(base)
base.extend(ClassMethods)
end
module ClassMethods
def acts_as_commentable(&block)
has_many :comments, :as => :commentable, :dependent => :destroy, &block
end
end
end
end
end... | Ruby |
# create table :comments do |t|
# t.column :author, :string
# t.column :comment, :string
# t.column :commentable_type, :string
# t.column :commentable_id, :integer
# t.column :created_at, :datetime, :null => false
# end
class Comment < ActiveRecord::Base
belongs_to :commentable, :polymorphic => true
end
| Ruby |
# Install hook code here
| Ruby |
# Include hook code here
require 'acts_as_taskable'
ActiveRecord::Base.send(:include, Hedgehoglab::Rails::Taskable)
| Ruby |
# ActsAsTaskable
module Hedgehoglab
module Rails
module Taskable #:nodoc:
def self.included(base)
base.extend ClassMethods
end
module ClassMethods
def acts_as_taskable
has_many :tasks, :as => :taskable, :dependent => :destroy, :order => 'created_at ASC'
in... | Ruby |
class Task < ActiveRecord::Base
belongs_to :taskable, :polymorphic => true
# NOTE: Tasks belong to a user
belongs_to :user
end | Ruby |
# desc "Explaining what the task does"
# task :act_as_feeder do
# # Task goes here
# end | Ruby |
class FeederGenerator < Rails::Generator::Base
def manifest
record do |m|
# Controller, helper, views, and test directories.
m.directory 'app/models/'
m.directory 'app/controllers/'
m.directory 'app/helpers/'
m.directory 'app/views/'
m.directory 'test/functional/'
... | Ruby |
class Feed < ActiveRecord::Base
acts_as_feeder
has_many :entries , :dependent => :destroy
validates_presence_of :url
end | Ruby |
class Entry < ActiveRecord::Base
belongs_to :feed
has_many :urls
end | Ruby |
class Url < ActiveRecord::Base
belongs_to :entry
end | Ruby |
class FeedController < ApplicationController
def index
@feeds = Feed.find :all , :include => [:entries]
end
def new
@feed = Feed.new
end
def create
@feed = Feed.new params[:feed]
if self.is_feed? @feed.url
if @feed.save
redirect_to :action => 'index'
else
f... | Ruby |
class FeedController < ApplicationController
def index
@feeds = Feed.find :all , :include => [:entries]
end
def new
@feed = Feed.new
end
def create
@feed = Feed.new params[:feed]
if xml = Feed.is_feed? (@feed.url , :feed_url)
@feed.parse_feed xml , :feed_url
if @feed.save
... | Ruby |
class CreateFeeds < ActiveRecord::Migration
def self.up
create_table :feeds, :force => true do |t|
t.column :url , :string
t.column :real_url, :string
t.column :title , :string
t.column :description , :text
t.column :last_updated , :datetime
t.column :type , :string
end
... | Ruby |
class Url < ActiveRecord::Base
belongs_to :entry
end | Ruby |
# Install hook code here
| Ruby |
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the act_as_feeder plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'Generate documentation for the act_as_feeder pl... | Ruby |
# Uninstall hook code here
| Ruby |
# Include hook code here
require 'acts_as_feeder'
ActiveRecord::Base.send :include, Orange::Acts::Feeder | Ruby |
module FeedFetcher #:nodoc:
class FeedSourceError < RuntimeError
end
class NoFeedForPageError < RuntimeError
end
class PageFeedError < RuntimeError
end
class PageDoesntExistError < RuntimeError
end
class InvalidURIError < RuntimeError
end
class FeedFetcher
# Che... | Ruby |
module Orange#:nodoc:
module Acts#:nodoc:
module Feeder #:nodoc:
# included is called from the ActiveRecord::Base
# when you inject this module
def self.included(base) #:nodoc:
# Add acts_as_roled availability by extending the module
# that owns the function.
base.extend AddActsAs... | Ruby |
# Include hook code here
require 'acts_as_proxy'
ActiveRecord::Base.send(:include, ActsAsProxy) | Ruby |
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the acts_as_proxy plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'Generate documentation for the acts_as_proxy pl... | Ruby |
# desc "Explaining what the task does"
# task :acts_as_proxy do
# # Task goes here
# end | Ruby |
# Uninstall hook code here
| Ruby |
# Install hook code here
| Ruby |
module ActsAsProxy
def self.included(base) #:nodoc:
base.send(:extend, ClassMethods)
base.after_save {|record| record.unsaved_proxied.all? {|associated| associated.save}}
end
# When the proxied object is not a new_record, ActiveRecord will not automatically take care of saving it.
# So, ActsAsProxy stu... | Ruby |
# desc "Explaining what the task does"
# task :acts_as_tiny_url do
# # Task goes here
# end
| Ruby |
# Install hook code here
| Ruby |
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the acts_as_tiny_url plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'Generate documentation for the acts_as_tiny_... | Ruby |
# Uninstall hook code here
| Ruby |
require File.dirname(__FILE__) + '/lib/acts_as_tiny_url'
ActionView::Base.send(:include, ActsAsTinyURL) | Ruby |
# Author:: Brendan G. Lim (brendangl@gmail.com)
module ActsAsTinyURL
class ActsAsTinyURLError < StandardError; end;
def tiny_url(uri, options = {})
defaults = { :validate_uri => false }
options = defaults.merge options
return validate_uri(uri) if options[:validate_uri]
return generate_uri(ur... | Ruby |
require 'activeshipping'
| Ruby |
require 'rubygems'
Gem::manage_gems
require 'rake/gempackagetask'
spec = Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.name = 'activeshipping'
s.version = "0.2"
s.author = "Jonathan Bartlett"
s.email = "jonathan@newmedio.com"
s.summary = "Unified API for Shipping"
s.files = FileList['lib/*.rb... | Ruby |
#Copyright 2007 New Medio. This file is part of ActiveShipping. See README for license and legal information.
#Used for a lot of modules
require 'bigdecimal'
require 'net/https'
require 'active_shipping/lib/util'
require 'active_shipping/lib/base'
require 'active_shipping/lib/location'
require 'active_shipping/lib... | Ruby |
#Copyright 2007 New Medio. This file is part of ActiveShipping. See README for license and legal information.
module ActiveShipping
class Location
attr_accessor :company, :name, :address1, :address2, :address3, :city, :state, :postal_code, :country, :handling_rules
def initialize(options = {})
options.each ... | Ruby |
#Copyright 2007 New Medio. This file is part of ActiveShipping. See README for license and legal information.
module ActiveShipping
class UspsGateway < Base
attr_accessor :username, :password, :debug_mode, :test_mode
def initialize(options = {})
if options[:dsn]
options = options.merge(Util.parse_dsn(op... | Ruby |
#Copyright 2007 New Medio. This file is part of ActiveShipping. See README for license and legal information.
module ActiveShipping
module Handling
class Base
end
class Generic < Base
attr_accessor :per_pound, :per_order, :per_item, :shipping_multiplier
def initialize(options = {})
if options[:dsn]... | Ruby |
module ActiveShipping
#
# This class contains utility functions used by the rest of ActiveShipping to make
# our lives easier. Frankly, I don't know why they aren't in the standard library already.
#
class Util
#
# Simple method to run an http post request. If request_body is a string, it will
# be stuck... | Ruby |
#Copyright 2007 New Medio. This file is part of ActiveShipping. See README for license and legal information.
module ActiveShipping
class UpsGateway < Base
attr_accessor :username, :ups_account, :ups_license, :ups_pickup_type, :debug_mode, :test_mode
#:username => "USERNAME|ACCOUNT_NUMBER|LICENSE_NUMBER|UPS_PI... | Ruby |
#Copyright 2007 New Medio. This file is part of ActiveShipping. See README for license and legal information.
module ActiveShipping
#
# This is the superclass to all included ActiveShipping modules, as well as
# being the repository of system-wide data about available ActiveShipping
# modules (modules is used... | Ruby |
#Copyright 2007 New Medio. This file is part of ActiveShipping. See README for license and legal information.
module ActiveShipping
class FedexGateway
attr_accessor :fedex_account, :fedex_meter, :fedex_packaging, :fedex_dropoff, :test_mode, :debug_mode, :password
def initialize(options)
if(options[:dsn])
... | Ruby |
module ActiveShipping
class ConWayGateway < Base
attr_accessor :username,:password,:test_mode,:debug_mode,:item_class,:customer_number,:shipping_adjustment,:accessorial_charges,:uom
def initialize(options = {})
if options.has_key? :dsn
options = options.merge(Util.parse_dsn(options.delete(:dsn)... | Ruby |
require 'ostruct'
require 'activemessaging'
| Ruby |
#!/usr/bin/env ruby
require 'rubygems'
require 'daemons'
require 'activesupport'
require 'activemessaging'
APP_ROOT = File.expand_path(File.dirname(__FILE__) + '/..')
tmp_dir = File.join(File.expand_path(APP_ROOT), 'log')
script_file = File.join(File.dirname(__FILE__)+'/../lib/poller.rb')
options = {
:app_name =>... | Ruby |
#!/usr/bin/env ruby
# Make sure stdout and stderr write out without delay for using with daemon like scripts
STDOUT.sync = true; STDOUT.flush
STDERR.sync = true; STDERR.flush
#Try to Load Merb
begin
require File.expand_path(File.dirname(__FILE__)+'/../config/boot')
require File.expand_path(File.dirname(__FILE__)+'... | Ruby |
#
# Add your destination definitions here
# can also be used to configure filters, and processor groups
#
ActiveMessaging::Gateway.define do |s|
#s.destination :orders, '/queue/Orders'
#s.filter :some_filter, :only=>:orders
#s.processor_group :group1, :order_processor
s.destination :<%= singular_name %>, '/q... | Ruby |
#!/usr/bin/env ruby
require 'rubygems'
require 'daemons'
require 'activesupport'
require 'activemessaging'
APP_ROOT = File.expand_path(File.dirname(__FILE__) + '/..')
tmp_dir = File.join(File.expand_path(APP_ROOT), 'log')
script_file = File.join(File.dirname(__FILE__)+'/../lib/poller.rb')
options = {
:app_name =>... | Ruby |
#!/usr/bin/env ruby
# Make sure stdout and stderr write out without delay for using with daemon like scripts
STDOUT.sync = true; STDOUT.flush
STDERR.sync = true; STDERR.flush
#Try to Load Merb
begin
require File.expand_path(File.dirname(__FILE__)+'/../config/boot')
require File.expand_path(File.dirname(__FILE__)+'... | Ruby |
class <%= class_name %>Processor < ApplicationProcessor
subscribes_to :<%= singular_name %>
def on_message(message)
logger.debug "<%= class_name %>Processor received: " + message
end
end | Ruby |
class ApplicationProcessor < ActiveMessaging::Processor
# Default on_error implementation - logs standard errors but keeps processing. Other exceptions are raised.
def on_error(err)
if (err.kind_of?(StandardError))
logger.error "ApplicationProcessor::on_error: #{err.class.name} rescued:\n" + \
er... | Ruby |
require File.dirname(__FILE__) + '/../../lib/activemessaging/named_base'
class ProcessorGenerator < NamedBase
def manifest
record do |m|
path = 'app/processors'
test_path = 'test/functional'
# Check for class naming collisions.
m.class_collisions class_path, "#{class_name}Controller", "#... | Ruby |
class <%= class_name %>Filter < ActiveMessaging::Filter
attr_accessor :options
def initialize(options={})
@options = options
end
def process(message, routing)
logger.debug "<%= class_name %>Filter filtering message: #{message.inspect} with routing: #{routing.inspect}"
end
end | Ruby |
class FilterGenerator < RubiGen::Base
def manifest
record do |m|
path = 'app/processors'
test_path = 'test/functional'
# Check for class naming collisions
m.class_collisions class_path, "#{class_name}Controller", "#{class_name}ControllerTest", "#{class_name}Helper"
# filter and tes... | Ruby |
class ActiveMessagingTestController < ApplicationController
include ActiveMessaging::MessageSender
def index
@destinations = ActiveMessaging::Gateway.named_destinations.values
if request.post?
@message = params[:message]
if params[:destination].nil? || params[:destination].empty?
fla... | Ruby |
class A13gTestHarnessGenerator < RubiGen::Base
def manifest
record do |m|
controller_path = 'app/controllers'
m.directory controller_path
m.file 'active_messaging_test_controller.rb', File.join(controller_path, 'active_messaging_test_controller.rb')
view_path = 'app/views/active_messagin... | Ruby |
class <%= class_name %>Controller < ApplicationController
include ActiveMessaging::MessageSender
publishes_to :trace
def index
end
def clear
publish :trace, "<trace-control>clear</trace-control>"
redirect_to :action=>'index'
end
end
| Ruby |
module <%= class_name %>Helper
end
| Ruby |
require 'mpath'
require 'active_support'
class Dot
attr_accessor :name, :nodes, :edges, :clean_names
def initialize name
@name = name
@nodes = {}
@clean_names = {}
@edges = []
yield self
end
def node name, params = {}
@nodes[clean_name(name)] = params.stringify_keys.reverse_merge... | Ruby |
class TracerGenerator < RubiGen::Base
def manifest
record do |m|
path = 'app/controllers'
m.directory path
m.template 'controller.rb', File.join(path, "#{file_name}_controller.rb")
path = 'app/processors'
m.directory path
m.template 'trace_processor.rb', File.join(path, "#{fil... | Ruby |
# -*- ruby -*-
require 'rubygems'
require 'power_hoe'
PowerHoe.new('activemessaging') do |p|
p.summary = "This gem is awesome"
end
# vim: syntax=Ruby | Ruby |
namespace "activemessaging" do
desc 'Run all consumers'
task :start_consumers do
load File.dirname(__FILE__) + '/../poller.rb'
end
end | Ruby |
# -*- ruby -*-
require 'rubygems'
require 'power_hoe'
PowerHoe.new('activemessaging') do |p|
p.summary = "This gem is awesome"
end
# vim: syntax=Ruby | Ruby |
#Adapter to rubigen / rails
if defined?(Rails)
class NamedBase < Rails::Generator::NamedBase
end
else
class NamedBase < RubiGen::Base
attr_reader :name, :class_name, :singular_name, :plural_name
attr_reader :class_path, :file_path, :class_nesting, :class_nesting_depth
alias_method :file_name, :si... | Ruby |
class TraceFilter< ActiveMessaging::Filter
include ActiveMessaging::MessageSender
def initialize(options)
@queue = options[:queue]
TraceFilter.publishes_to @queue
end
def process message, routing
unless ( routing[:destination].name == @queue ) then
puts "\nTrace: directio... | Ruby |
module ActiveMessaging
# include this module to make a new adapter - will register the adapter w/gateway so an be used in connection config
module Adapter
def self.included(included_by)
class << included_by
def register adapter_name
Gateway.register_adapter adapter_name, self
e... | Ruby |
require 'yaml'
module ActiveMessaging
class Gateway
cattr_accessor :adapters, :subscriptions, :named_destinations, :filters, :processor_groups, :connections
@@adapters = {}
@@subscriptions = {}
@@named_destinations = {}
@@filters = []
@@connections = {}
@@processor_groups = {}
@@curr... | Ruby |
# 'abstract' base class for ActiveMessaging processor classes
module ActiveMessaging
class Processor
include MessageSender
attr_reader :message
class<<self
def subscribes_to destination_name, headers={}
ActiveMessaging::Gateway.subscribe_to destination_name, self, headers
end
... | Ruby |
gem 'stomp'
require 'stomp'
module ActiveMessaging
module Adapters
module Stomp
class Connection < ::Stomp::Connection
include ActiveMessaging::Adapter
register :stomp
attr_accessor :reliable, :retryMax, :deadLetterQueue
def initialize(cfg)
@retryMax = cfg[:retr... | Ruby |
if defined?(JRUBY_VERSION)
#require 'java'
include Java
import javax.naming.InitialContext
import javax.jms.MessageListener
module ActiveMessaging
module Adapters
module Jms
class Connection
include ActiveMessaging::Adapter
register :jms
attr_accessor :reliable, :con... | Ruby |
################################################################################
# Copyright 2007 S. Perez. RBC Dexia Investor Servies Bank
#
# 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... | Ruby |
module ActiveMessaging
module Adapters
module AmazonSQS
class Connection
include ActiveMessaging::Adapter
register :asqs
QUEUE_NAME = 1..80
MESSAGE_SIZE = 1..(256 * 1024)
VISIBILITY_TIMEOUT = 0..(24 * 60 * 60)
NUMBER_OF_MESSAGES = 1..255
#configura... | Ruby |
module ActiveMessaging
module Adapters
module Base
# use this as a base for implementing new connections
class Connection
include ActiveMessaging::Adapter
#use the register method to add the adapter to the configurable list of supported adapters
# register :generic
... | Ruby |
require 'reliable-msg'
module ReliableMsg
class Client
def queue_manager
qm
end
end
end
module ActiveMessaging
module Adapters
module ReliableMsg
THREAD_OLD_TXS = :a13g_reliable_msg_old_txs
class Connection
include ActiveMessaging::Adapter
register :reliable_... | Ruby |
module ActiveMessaging
module Adapters
module Test
class Connection
include ActiveMessaging::Adapter
register :test
attr_accessor :config, :subscriptions, :destinations, :connected, :received_messages, :unreceived_messages
def initialize cfg
... | Ruby |
# #require 'dispatcher' unless defined?(::Dispatcher)
# ::Dispatcher.class_eval do
#
# def self.prepare_application_for_dispatch
# if (self.private_methods.include? "prepare_application")
# prepare_application
# else
# new(STDOUT).prepare_application
# end
# end
#
# def self.reset_appl... | Ruby |
require 'logger'
module ActiveMessaging
# This is a module so that we can send messages from (for example) web page controllers, or can receive a single message
module MessageSender
def self.included(included_by)
class << included_by
def publishes_to destination_name
Gateway.find_dest... | Ruby |
# 'abstract' base class for ActiveMessaging filter classes
module ActiveMessaging
class Filter
# give filters easy access to the logger
def logger()
@@logger = ActiveMessaging.logger unless defined?(@@logger)
@@logger
end
# these are the headers available for a message from the 'details'... | Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.