code stringlengths 1 1.73M | language stringclasses 1
value |
|---|---|
class AutomatorGenerator < Rails::Generator::Base
def manifest
record do |m|
m.migration_template 'migrate/create_automator_workflows.rb',
'db/migrate',
:migration_file_name => 'create_automator_workflows'
end
end
end | Ruby |
class CreateAutomatorWorkflows < ActiveRecord::Migration
def self.up
create_table :workflow_action_libraries do |t|
t.column :name, :string
end
create_table :workflows do |t|
t.column :name, :string
t.column :created_by, :integer
t.column :owner_email, :string
t.column :... | Ruby |
# This file is copied to ~/spec when you run 'ruby script/generate rspec'
# from the project root directory.
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../../../../config/environment")
require 'spec/rails'
Spec::Runner.configure do |config|
config.use_transactional_fixtures = true
... | 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 automator plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'Generate documentation for the automator plugin.'
R... | Ruby |
# Uninstall hook code here
| Ruby |
# Include hook code here
begin
require 'active_record/acts/list'
rescue
raise "Automator requires acts_as_list. script/plugin install acts_as_list"
end
| Ruby |
# Workflows
| Ruby |
# == Schema Information
# Schema version: 141
#
# Table name: workflow_action_libraries
#
# id :integer(11) not null, primary key
# name :string(255)
#
class WorkflowActionLibrary < ActiveRecord::Base
has_many :actions, :class_name => "WorkflowAction"
end
| Ruby |
# == Schema Information
# Schema version: 157
#
# Table name: workflows
#
# id :integer(11) not null, primary key
# name :string(255)
# created_by :integer(11)
#
class Workflow < ActiveRecord::Base
has_many :actions, :class_name => "WorkflowAction",
:order => ... | Ruby |
require 'csv'
class CsvPresenterAction < WorkflowAction
def valid_input_classes
[ActiveRecord::Base]
end
def output_class
String
end
def mime_type
'text/csv'
end
def execute
output = String.new
CSV.generate_row(field_labels, field_labels.size, output)
self.input.each do |reco... | Ruby |
class SaveFileAction < WorkflowAction
validates_presence_of :filename
def valid_input_classes
[String]
end
def output_class
File
end
def timestamp_format
options[:timestamp_format] || "%Y-%m-%d_%H-%m-%S"
end
def timestamp(format=timestamp_format)
Time.now.strftime(format)
... | Ruby |
class FindActiveRecordAction < WorkflowAction
def valid_input_classes
[]
end
def output_class
ActiveRecord::Base
end
def model=(model)
raise "#{model.to_s} is not a class" unless model.class == Class
options[:model] = model.to_s
end
def model
options[:model].constantize
end
... | Ruby |
require 'ruport/acts_as_reportable'
class ActiveReportAction < WorkflowAction
validates_inclusion_of :format, :in => [:csv, :html, :pdf, :native]
def valid_input_classes
[ActiveRecord::Base]
end
def output_class
format == :native ? Ruport::Data::Table : String
end
def format
options[:f... | Ruby |
# == Schema Information
# Schema version: 157
#
# Table name: workflow_actions
#
# id :integer(11) not null, primary key
# kind :string(255)
# position :integer(11)
# workflow_id :integer(11)
# quantities :text
# operators :text
# operands :text... | Ruby |
# Automator
| Ruby |
class SendMailAction < WorkflowAction
validates_presence_of :recipients
def valid_input_classes
[String]
end
def output_class
TMail::Mail
end
def mailer
options[:mailer].nil? ? WorkflowMailer : options[:mailer].constantize
end
def mailer=(mailer_class)
if (mailer_class.class ... | Ruby |
class WorkflowMailer < ActionMailer::Base
def workflow(workflow, recipients, from, attachable)
recipients recipients
from from
subject "Workflow Execution Report: #{workflow.name}"
body :workflow => workflow
if attachable
attachment :content_type => attachable[:mime_typ... | Ruby |
%w|set ostruct enumerator|.each { |g| require g }
# Main Library
require File.join(File.dirname(__FILE__), 'lib/main.rb')
# This is for debugging of the generator.
# puts AutoRest::Configuration::ARDataContainer.generator_helper | Ruby |
class <%= controller_class_name %>Controller < ApplicationController
create_auto_rest
=begin
# The following is an example of all the configuration fields that can be
# tweaked. AutoRest will try to find good defaults for all this, but
# sometimes you will have to tweak the confguration by yourself
# (sp... | Ruby |
module <%= controller_class_name %>Helper
end
| Ruby |
class <%= class_name %> < ActiveRecord::Base
#Uncomment to enable ferret search on this table
#acts_as_ferret
# Used by auto_rest for labeling the resource
def label
"Please label the <%= class_name %> resource."
end
# Options for auto_rest automatic options for select.
# resource is an active r... | Ruby |
module AutoRest
module DefaultMethods
module Create
# POST /resources
# POST /resources.xml
def create
ar_create_resource()
respond_to do |format|
if ar_save_resource
flash[:notice] = ardata.labels[:create_successfull]
format.html { redirect_to ar_reso... | Ruby |
module AutoRest
module DefaultMethods
module New
# GET /resources/new
def new options= params[:resource]
ar_new_resource(options)
render ardata.templates.new
end
end
end
end | Ruby |
module AutoRest
module DefaultMethods
module Edit
# GET /resources/1;edit
def edit
ar_get_resource()
render ardata.templates.edit
end
end
end
end | Ruby |
module AutoRest
module DefaultMethods
module Update
# PUT /resources/1
# PUT /resources/1.xml
def update
ar_get_resource()
respond_to do |format|
if ar_update_resource_attributes
ar_verify_parent_resource() if @parent_resource
flash[:notice] = ard... | Ruby |
module AutoRest
module DefaultMethods
module Show
# GET /resources/1
# GET /resources/1.xml
def show
ar_get_resource()
respond_to do |format|
format.html { render ardata.templates.show }
format.xml { render :xml => @resource.to_xml }
end
end
end
... | Ruby |
#
# for_ferret_support.rb
#
# Created on 21/09/2007, 17:32:10
#
module AutoRest
module DefaultMethods
module Search
# A route for :collection => { :search => :get } should be in place.
def search options= {}
@query= ar_transform_query_terms(params[:query_terms])
if !@query.empty?
... | Ruby |
module AutoRest
module DefaultMethods
module Destroy
# DELETE /resources/1
# DELETE /resources/1.xml
def destroy
ar_get_resource()
ar_destroy_resource()
respond_to do |format|
format.html { redirect_to ar_resources_url }
format.xml { head :ok }
end
... | Ruby |
#
# rest_instance_methods.rb
#
# Created on 08/08/2007, 15:10:55
#
# DEFAULT REST METHODS
# Taken from scaffolding.
#
# EmmanuelOga.wordpress.com
module AutoRest
module DefaultMethods
module Index
# GET /resources
# GET /resources.xml
def index
ar_get_resources()
respond_to do |format|
... | Ruby |
module AutoRest
# Labels for buttons and links (mostly for CRUD actions)
class Labels
@@defaults= {
:index_title => "<h3>Index</h3>",
:edit_title => "<h3>Edit</h3>",
:new_title => "<h3>New</h3>",
:show_title => "<h3>Show</h3>",
:searc... | Ruby |
class <%= migration_name %> < ActiveRecord::Migration
def self.up
create_table :<%= table_name %> do |t|
<% for attribute in attributes -%>
t.column :<%= attribute.name %>, :<%= attribute.type %>
<% end -%>
end
end
def self.down
drop_table :<%= table_name %>
end
end
| Ruby |
#
# configuration_generator.rb
#
# Created on 25/09/2007, 14:00:40
#
# Build a nice output to default configuration.
module AutoRest
module Configuration
class ARDataContainer
class FakeController
attr_accessor :ar_controller_parents
attr_accessor :controller_class_name
a... | Ruby |
# Generation of example options on the controller.
AutoRest.ar_require_relative __FILE__, 'configuration_generator.rb'
class ArSpecScaffoldGenerator < Rails::Generator::NamedBase
default_options :skip_migration => false
attr_reader :controller_name,
:controller_class_path,
:con... | Ruby |
class ResourcesController < ApplicationController
# The following is an example of all the configuration fields that can be
# tweaked. AutoRest will try to find good defaults for all this, but
# sometimes you will have to tweak the confguration by yourself
# (specially when changing labels/titles)
creat... | Ruby |
#
# little_rails_app.rb
#
# Created on 20/09/2007, 09:50:59
# EmmanuelOga.blogspot.com
require 'set'
require 'ferret'
require 'active_support'
require 'action_pack'
require 'action_controller'
require 'action_view'
require 'active_record'
# For testing, i require these manually (rails would load it automatically
#... | Ruby |
require 'rake'
require 'spec/rake/spectask'
require 'rake/rdoctask'
desc "Run all examples"
Spec::Rake::SpecTask.new('spec') do |t|
t.spec_files = FileList['specs/*.rb']
end
desc 'Generate documentation for the auto_rest plugin.'
Rake::RDocTask.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = 'rdoc'
rdoc.title = 'AutoRe... | Ruby |
# Uninstall hook code here
| Ruby |
# Install hook code here
| Ruby |
# Some handy methods for mocking records according to auto_rest defaults
module AutoRest
module SpecsHelper
# Return a default value given a type.
def ar_mock_default_value_for_type type
case type
when :int, :integer then "\"1\""
when :float then "\"1.5\"... | Ruby |
# Permutations of elements of an Array. Very usefull :)
# Don't remember where i got this but is not mine.
# This is used on rails_resources.rb to look for parent child relationships
# of resources whithout any complex modification of the rails resource creation mechanism.
class Array
def perm(n = size)
if ... | Ruby |
#
# application_helper_methods.rb
#
# Created on 22/08/2007, 14:36:25
module AutoRest
module ApplicationHelperMethods
# Will look for the parameter "meaning" given its type.
# other_parameters will be used to pass additional data if needed
# (ie the form_builder in a new or edit view)
def ar_... | Ruby |
#
# configuration.rb
#
# Created on 12/09/2007, 16:33:34
#
# BREADCRUBS: Controller class methods for getting information on controller chain
# This methods should be inserted on ActionController::Base
module AutoRest
module BreadcrumbsClassMethods
# Store controller relationships for nested r... | Ruby |
#
# breadcrumbs_helpers.rb
#
# Created on 24/08/2007, 16:24:10
# Methods to be called on controller helpers and views.
# Returns the links to every linked controller (breadcrumbs)
module AutoRest
module BreadcrumbsHelpers
def ar_breadcrumbs
return if not ActionController::Base.ar_has_controller_on_... | Ruby |
#-------------------------------------------------------------------------------
# Formats for some parameters of ARDataContainer.
#-------------------------------------------------------------------------------
# Storage for each resource relevant data.
# ie, a resource name "zone" may have a plural "zones", a model ... | Ruby |
#
# configuration_helpers.rb
#
# Created on 24/09/2007, 11:47:25
#
module AutoRest
module Configuration
# With all options in place, i can use the data to provide helper methods.
class ARDataContainer
# Based on the params of the request, find the parent model
# (a same resource can ... | Ruby |
#
# configuration.rb
#
# Created on 12/09/2007, 16:33:34
#
# Here is defined ARDataContainer, the object that will hold all user
# supplied configuration and will generate defaults for all the missing options
AutoRest.ar_require_relative __FILE__, 'ardata_container.rb'
# Helpers to manipulate the ARDataContainer ... | Ruby |
#
# main.rb
#
# Created on 08/08/2007, 15:10:40
#
# EmmanuelOga.WordPress.com
AutoRest.ar_require_relative __FILE__, 'configuration', 'main.rb'
AutoRest.ar_require_relative __FILE__, 'application_helpers', 'application_helper_methods.rb'
AutoRest.ar_require_relative __FILE__, 'instance_methods', 'for_model_manipu... | Ruby |
#
# nested_class_methods.rb
#
# Created on 09/08/2007, 16:39:13
#
# This set of methods is meant to work WITH a parent resource.
# See main module RestClassMethods
module AutoRest
module RestInstanceMethods
module ModelManipulation
private
def ar_get_records_source
# AutoRest ARDataContainer hold... | Ruby |
#
# for_miscelaneous.rb
#
# Created on 21/09/2007, 17:32:29
#
module AutoRest
module RestInstanceMethods
module Miscelaneous
# Shortcut for accessing class data.
def ardata
self.class.ardata
end
# Url for a resource
def ar_resource_url resource= @resource
meth= "#{ard... | Ruby |
module WillPaginate
# = Global options for pagination helpers
#
# Options for pagination helpers are optional and get their default values from the
# WillPaginate::ViewHelpers.pagination_options hash. You can write to this hash to
# override default options on the global level:
#
# WillPaginate::ViewHel... | Ruby |
module AutoRest
# This will load the will_paginate fix that replaces the link_to to link_to_remote
# in the links when the proper options are used to the will_paginate helper method.
# To include the patch, add AutoRest.add_ajax_support_to_will_paginate in
# environment.rb of your rails app.
def add_ajax_su... | Ruby |
# Thank you
# http://opensoul.org/2007/8/17/acts_as_ferret-will_paginate
module ActsAsFerret
module ClassMethods
def paginate_search(query, options = {})
options, page, per_page = wp_parse_options!(options)
pager = WillPaginate::Collection.new(page, per_page, nil)
options.merge!(:of... | Ruby |
# Patch Rails "ActionController::Resources::Resource" class,
module AutoRest
# A simple container for storing the ActionController::Resources::Resource
# objects that the routes manager creates (because rails does not store
# those objects anywhere)
class RailsResources
@@resources_array= []
@@resou... | Ruby |
module AutoRest
# This is a require "replacement" to easily chain directories to the required file.
# Pass a list of directories and a final filename.
# First parameter should always be __FILE__, as the method is intented to be
# used to load a file that is located in a directory relative to the one you are
... | Ruby |
#!/usr/bin/env ruby
#password = password123 ~ it was for dev purposes and i cant be bothered taking it out ^_^
#password finally removed
login = true
while login==true
puts "Please enter your name, Please note this has to be the user name of your account on your system:"
username = gets.chomp.to_s
system "clear"
pu... | Ruby |
#!/usr/bin/env ruby
#password = password123 ~ it was for dev purposes and i cant be bothered taking it out ^_^
#password finally removed
login = true
while login==true
puts "Please enter your name, Please note this has to be the user name of your account on your system:"
username = gets.chomp.to_s
system "clear"
pu... | Ruby |
# hardware_platform.rb
Facter.add("vmx_memsize") do
setcode do
%x{/usr/bin/free -mo|/usr/bin/awk '$1 ~/Mem:/ {print $2}'}.chomp
end
end
| Ruby |
# hardware_platform.rb
Facter.add("squid_cache_disks") do
setcode do
%x{/bin/df|/usr/bin/awk '$0 ~/squid_cache/{print "cache_dir aufs "$NF" "int($2*0.00085)" 64 128"}'}.chomp
end
end
| Ruby |
require 'boottest'
require 'test/unit'
require 'lib/JobList'
require 'lib/Job'
class TestJobList < Test::Unit::TestCase
def test_append
list = JobList.new()
a = Job.new('DAVID')
a.properties['last_name'] = 'MOODY'
b = Job.new('DEBBIE')
list.append(a).append(b)
assert_equal(a, list[0])
as... | Ruby |
$app_dir = File.expand_path(File.join(File.dirname(__FILE__), '..'))
$:.unshift($app_dir) | Ruby |
#---
#
file_array= Dir.glob('**/[0-9]_cte1crw_[0-9]*.sql').each { | file | file }.sort
file_array.each do |element|
puts element
end
#this is a change that I wanted to check in
| Ruby |
#Job collection
class JobList
def initialize
@jobs = Array.new
end
def append(job)
@jobs.push(job)
self
end
def with_name(name)
@jobs.find { |job| name ==job.name }
end
def [](index)
@jobs[index]
end
end | Ruby |
class Job
attr_accessor :properties
attr_accessor :name
def initialize(name, properties = {})
@name = name
@properties = properties
end
end | Ruby |
class Environment
attr_accessor :properties
attr_accessor :name
def initalize(env_name, properties = {})
@name = env_name
@properties = properties
end
end | Ruby |
require 'Job'
require 'JobList'
class JilFileParser
def initialize(file_object)
@file_object = file_object
end
#returns a Joblist
def parse
nil
end
end
| Ruby |
name = Autosave Playlist
type = generic
| Ruby |
#author newdongyuwei@gmail.com
require 'rubygems'
require 'fsevents'
require 'net/scp'
require 'ruby-growl'if RUBY_PLATFORM.downcase.include?("darwin") #only macruby implemented growl lib supports click callback
$host = "10.210.74.63"
$username = "my name"
$password = "my password"
$_scp_ = Net::SCP.start($host, $use... | Ruby |
require "rubygems"
require 'watir'
ie = Watir::IE.new
ie.speed = :slow
#set veriables
testsite = Array.new
testsite[0] = "http://davidcch.pixnet.net/blog/post/25964106"
testsite[1] = "http://davidcch.pixnet.net/blog/post/33531453"
testsite[2] = "http://davidcch.pixnet.net/blog/post/33531247"
testsite[3] = "htt... | Ruby |
# Copyright (c) 2008 [Sur http://expressica.com]
require 'auto_tags'
| Ruby |
# Copyright (c) 2008 [Sur http://expressica.com]
# desc "Explaining what the task does"
# task :auto_tags do
# # Task goes here
# end
| Ruby |
# Copyright (c) 2008 [Sur http://expressica.com]
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the auto_tags plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
desc 'G... | Ruby |
# Copyright (c) 2008 [Sur http://expressica.com]
class AutoTagsIncludeError < ArgumentError #:nodoc
end
class AutoTagsNotDefinedError < NoMethodError #:nodoc
end
class AutoTagsServerError < StandardError #:nodoc
end
| Ruby |
# Copyright (c) 2008 [Sur http://expressica.com]
require 'auto_tags_active_record'
require 'auto_tags_exceptions'
require 'net/http'
require 'rexml/document'
module AutoTags #:nodoc
class AutoTagsGeneration
cattr_accessor :appid
CONFIG = {
:default_appid => 'k5rYmAnV34EN0RqBR_dl_PbL.B5mTq2KhEO2t4... | Ruby |
# Copyright (c) 2008 [Sur http://expressica.com]
module AutoTags
module ModelHelpers
module ClassMethods
def self.extended(base) #:nodoc
base.send('include', ModelHelpers::InstanceMethods)
end
# Enables the model class to leverage the automatic tags generation.
#
# Av... | Ruby |
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string :email
t.string :crypted_password
t.string :salt
t.string :name
t.timestamps
end
end
def self.down
drop_table :users
end
end
| Ruby |
ENV["RAILS_ENV"] = "test"
require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
require 'test_help'
class Test::Unit::TestCase
# Transactional fixtures accelerate your tests by wrapping each test method
# in a transaction that's rolled back on completion. This ensures that the
# test datab... | Ruby |
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispat... | Ruby |
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
#
# You may specify the path to the FastCGI crash log (a log of unhandled
# exceptions which forced the FastCGI instance to exit, great for debugging)
# and the number of requests to process before running garbage collection.
#
# By default, the Fast... | Ruby |
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispat... | Ruby |
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispat... | Ruby |
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
#
# You may specify the path to the FastCGI crash log (a log of unhandled
# exceptions which forced the FastCGI instance to exit, great for debugging)
# and the number of requests to process before running garbage collection.
#
# By default, the Fast... | Ruby |
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
# If you're using RubyGems and mod_ruby, this require should be changed to an absolute path one, like:
# "/usr/local/lib/ruby/gems/1.8/gems/rails-0.8.0/lib/dispat... | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/destroy'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about' | Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/runner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/runner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/server'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/generate'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/destroy'
| 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/console'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/dbconsole'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
$LOAD_PATH.unshift "#{RAILTIES_PATH}/builtin/rails_info"
require 'commands/about' | 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/dbconsole'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/console'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require 'commands/plugin'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/spawner'
| Ruby |
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../../config/boot'
require 'commands/process/spawner'
| Ruby |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.