cavalcade 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.rvmrc ADDED
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # This is an RVM Project .rvmrc file, used to automatically load the ruby
4
+ # development environment upon cd'ing into the directory
5
+
6
+ # First we specify our desired <ruby>[@<gemset>], the @gemset name is optional.
7
+ environment_id="ruby-1.9.2-p290@cavalcade"
8
+
9
+ #
10
+ # Uncomment following line if you want options to be set only for given project.
11
+ #
12
+ # PROJECT_JRUBY_OPTS=( --1.9 )
13
+
14
+ #
15
+ # First we attempt to load the desired environment directly from the environment
16
+ # file. This is very fast and efficient compared to running through the entire
17
+ # CLI and selector. If you want feedback on which environment was used then
18
+ # insert the word 'use' after --create as this triggers verbose mode.
19
+ #
20
+ if [[ -d "${rvm_path:-$HOME/.rvm}/environments" \
21
+ && -s "${rvm_path:-$HOME/.rvm}/environments/$environment_id" ]]
22
+ then
23
+ \. "${rvm_path:-$HOME/.rvm}/environments/$environment_id"
24
+
25
+ if [[ -s "${rvm_path:-$HOME/.rvm}/hooks/after_use" ]]
26
+ then
27
+ . "${rvm_path:-$HOME/.rvm}/hooks/after_use"
28
+ fi
29
+ else
30
+ # If the environment file has not yet been created, use the RVM CLI to select.
31
+ if ! rvm --create "$environment_id"
32
+ then
33
+ echo "Failed to create RVM environment '${environment_id}'."
34
+ exit 1
35
+ fi
36
+ fi
37
+
38
+ #
39
+ # If you use an RVM gemset file to install a list of gems (*.gems), you can have
40
+ # it be automatically loaded. Uncomment the following and adjust the filename if
41
+ # necessary.
42
+ #
43
+ # filename=".gems"
44
+ # if [[ -s "$filename" ]]
45
+ # then
46
+ # rvm gemset import "$filename" | grep -v already | grep -v listed | grep -v complete | sed '/^$/d'
47
+ # fi
48
+
49
+ # If you use bundler, this might be useful to you:
50
+ # if command -v bundle && [[ -s Gemfile ]]
51
+ # then
52
+ # bundle
53
+ # fi
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "activesupport", ">= 2.3.2"
4
+ gem "i18n" # ActiveSupport screws up its dependencies, so adding this manually (version-agnostic) so that bad versions of activesupport will still work.
5
+ gem "rake", ">= 0.9"
6
+ gem "resque", "~> 1.19"
7
+
8
+ group :development do
9
+ gem "rspec", "~> 2.6"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "jeweler", "~> 1.6.4"
12
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,52 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activesupport (3.1.1)
5
+ multi_json (~> 1.0)
6
+ diff-lcs (1.1.3)
7
+ git (1.2.5)
8
+ i18n (0.6.0)
9
+ jeweler (1.6.4)
10
+ bundler (~> 1.0)
11
+ git (>= 1.2.5)
12
+ rake
13
+ multi_json (1.0.3)
14
+ rack (1.3.5)
15
+ rack-protection (1.1.4)
16
+ rack
17
+ rake (0.9.2.2)
18
+ redis (2.2.2)
19
+ redis-namespace (1.0.3)
20
+ redis (< 3.0.0)
21
+ resque (1.19.0)
22
+ multi_json (~> 1.0)
23
+ redis-namespace (~> 1.0.2)
24
+ sinatra (>= 0.9.2)
25
+ vegas (~> 0.1.2)
26
+ rspec (2.7.0)
27
+ rspec-core (~> 2.7.0)
28
+ rspec-expectations (~> 2.7.0)
29
+ rspec-mocks (~> 2.7.0)
30
+ rspec-core (2.7.1)
31
+ rspec-expectations (2.7.0)
32
+ diff-lcs (~> 1.1.2)
33
+ rspec-mocks (2.7.0)
34
+ sinatra (1.3.1)
35
+ rack (~> 1.3, >= 1.3.4)
36
+ rack-protection (~> 1.1, >= 1.1.2)
37
+ tilt (~> 1.3, >= 1.3.3)
38
+ tilt (1.3.3)
39
+ vegas (0.1.8)
40
+ rack (>= 1.0.0)
41
+
42
+ PLATFORMS
43
+ ruby
44
+
45
+ DEPENDENCIES
46
+ activesupport (>= 2.3.2)
47
+ bundler (~> 1.0.0)
48
+ i18n
49
+ jeweler (~> 1.6.4)
50
+ rake (>= 0.9)
51
+ resque (~> 1.19)
52
+ rspec (~> 2.6)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Robby Grossman
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # Cavalcade
2
+
3
+ a lightweight infrastructure for using [Resque](https://github.com/defunkt/resque) as a stand-alone job queue
4
+
5
+ ## Overview
6
+
7
+ Github built Resque to perform background jobs for the github web app. It has gained a large following in the Ruby community for running out-of-process jobs in all sorts of web apps.
8
+
9
+ But Resque can be very useful outside of a web app, too. What if you want to write jobs in Ruby and just enqueue them from your console? Or from a Java application? Or in cron jobs? Cavalcade to the Resque!
10
+
11
+ Cavalcade creates a Resque-based, stand-alone job queue, and provides rake tasks to enqueue all of your jobs.
12
+
13
+ ## Contributing to Cavalcade
14
+
15
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
16
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
17
+ * Fork the project
18
+ * Start a feature/bugfix branch
19
+ * Commit and push until you are happy with your contribution
20
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
21
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
22
+
23
+ ## Copyright
24
+
25
+ Copyright (c) 2011 Robby Grossman. MIT Licensed. See LICENSE.txt for details.
26
+
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "cavalcade"
18
+ gem.homepage = "http://github.com/freerobby/cavalcade"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{a lightweight infrastructure for using Resque as a stand-alone job queue}
21
+ gem.description = %Q{Resque can be very useful outside of a web app, too. What if you want to write jobs in Ruby and just enqueue them from your console? Or from a Java application? Or in cron jobs? Cavalcade to the resque! Cavalcade creates a resque-based, stand-alone job queue, and provides rake tasks to enqueue all of your jobs.}
22
+ gem.email = "robby@freerobby.com"
23
+ gem.authors = ["Robby Grossman"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rake/rdoctask'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "cavalcade #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
data/cavalcade.gemspec ADDED
@@ -0,0 +1,76 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "cavalcade"
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Robby Grossman"]
12
+ s.date = "2011-11-15"
13
+ s.description = "Resque can be very useful outside of a web app, too. What if you want to write jobs in Ruby and just enqueue them from your console? Or from a Java application? Or in cron jobs? Cavalcade to the resque! Cavalcade creates a resque-based, stand-alone job queue, and provides rake tasks to enqueue all of your jobs."
14
+ s.email = "robby@freerobby.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.md"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ ".rvmrc",
23
+ "Gemfile",
24
+ "Gemfile.lock",
25
+ "LICENSE.txt",
26
+ "README.md",
27
+ "Rakefile",
28
+ "VERSION",
29
+ "cavalcade.gemspec",
30
+ "lib/cavalcade.rb",
31
+ "lib/cavalcade/job.rb",
32
+ "lib/cavalcade/jobs_finder.rb",
33
+ "lib/cavalcade/tasks.rb",
34
+ "lib/cavalcade/tasks/jobs.rake",
35
+ "spec/lib/cavalcade/job_spec.rb",
36
+ "spec/lib/cavalcade/jobs_finder_spec.rb",
37
+ "spec/lib/cavalcade/tasks/jobs_spec.rb",
38
+ "spec/spec_helper.rb"
39
+ ]
40
+ s.homepage = "http://github.com/freerobby/cavalcade"
41
+ s.licenses = ["MIT"]
42
+ s.require_paths = ["lib"]
43
+ s.rubygems_version = "1.8.10"
44
+ s.summary = "a lightweight infrastructure for using Resque as a stand-alone job queue"
45
+
46
+ if s.respond_to? :specification_version then
47
+ s.specification_version = 3
48
+
49
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
50
+ s.add_runtime_dependency(%q<activesupport>, [">= 2.3.2"])
51
+ s.add_runtime_dependency(%q<i18n>, [">= 0"])
52
+ s.add_runtime_dependency(%q<rake>, [">= 0.9"])
53
+ s.add_runtime_dependency(%q<resque>, ["~> 1.19"])
54
+ s.add_development_dependency(%q<rspec>, ["~> 2.6"])
55
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
56
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
57
+ else
58
+ s.add_dependency(%q<activesupport>, [">= 2.3.2"])
59
+ s.add_dependency(%q<i18n>, [">= 0"])
60
+ s.add_dependency(%q<rake>, [">= 0.9"])
61
+ s.add_dependency(%q<resque>, ["~> 1.19"])
62
+ s.add_dependency(%q<rspec>, ["~> 2.6"])
63
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
64
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
65
+ end
66
+ else
67
+ s.add_dependency(%q<activesupport>, [">= 2.3.2"])
68
+ s.add_dependency(%q<i18n>, [">= 0"])
69
+ s.add_dependency(%q<rake>, [">= 0.9"])
70
+ s.add_dependency(%q<resque>, ["~> 1.19"])
71
+ s.add_dependency(%q<rspec>, ["~> 2.6"])
72
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
73
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
74
+ end
75
+ end
76
+
@@ -0,0 +1,4 @@
1
+ module Cavalcade
2
+ class Job
3
+ end
4
+ end
@@ -0,0 +1,15 @@
1
+ module Cavalcade
2
+ # Locates defined jobs ProcessingJobs.
3
+ class JobsFinder
4
+ def self.defined_jobs
5
+ classes = []
6
+ Module.constants.each do |c|
7
+ the_obj = eval(c.to_s)
8
+ if the_obj.is_a?(Class) && the_obj.ancestors.include?(Job) && the_obj != Job
9
+ classes << the_obj
10
+ end
11
+ end
12
+ classes
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,19 @@
1
+ require "resque/tasks"
2
+ require "active_support/inflector" # #underscore used to convert ClassName to class_name
3
+
4
+ require "cavalcade"
5
+
6
+ namespace :cavalcade do
7
+ namespace :jobs do
8
+ Cavalcade::JobsFinder.defined_jobs.each do |klass|
9
+ classname = klass.to_s
10
+ namespace classname.underscore do
11
+ desc "Create new #{classname} job; set params with RUBY_PARAMS_STR= (default is nil)."
12
+ task :enqueue do
13
+ PARAMS = ENV["RUBY_PARAMS_STR"] || nil
14
+ eval("Resque.enqueue(#{classname}, #{PARAMS})")
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1 @@
1
+ load File.join(File.dirname(__FILE__), 'tasks', 'jobs.rake')
data/lib/cavalcade.rb ADDED
@@ -0,0 +1,2 @@
1
+ require "cavalcade/job"
2
+ require "cavalcade/jobs_finder"
@@ -0,0 +1,7 @@
1
+ require "#{File.dirname(__FILE__)}/../../spec_helper"
2
+
3
+ describe Cavalcade::Job do
4
+ it "is defined as a class" do
5
+ Cavalcade::Job.is_a?(Class).should be_true
6
+ end
7
+ end
@@ -0,0 +1,15 @@
1
+ require "#{File.dirname(__FILE__)}/../../spec_helper"
2
+
3
+ describe Cavalcade::JobsFinder do
4
+ describe "#self.defined_jobs" do
5
+ it "returns array of all classes that inherit ProcessingJob" do
6
+ class MyClass1 < Cavalcade::Job; end
7
+ class MyClass2 < Cavalcade::Job; end
8
+ Cavalcade::JobsFinder.defined_jobs.should include(MyClass1)
9
+ Cavalcade::JobsFinder.defined_jobs.should include(MyClass2)
10
+ end
11
+ it "does not include Job" do
12
+ Cavalcade::JobsFinder.defined_jobs.should_not include(Cavalcade::Job)
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,18 @@
1
+ require "#{File.dirname(__FILE__)}/../../../spec_helper"
2
+
3
+ require "rake"
4
+
5
+ describe "jobs.rake" do
6
+ it "creates an enqueue task in own namespace for each Job" do
7
+ class File1 < Cavalcade::Job; end
8
+ class SomeClass < Cavalcade::Job; end
9
+ class SomeLongClassName < Cavalcade::Job; end
10
+ Cavalcade::JobsFinder.stub!(:defined_jobs).and_return([File1, SomeClass, SomeLongClassName])
11
+ Rake.application = Rake::Application.new
12
+ require "cavalcade/tasks"
13
+ tasks = Rake.application.tasks.map{|t| t.name}
14
+ tasks.should include("cavalcade:jobs:file1:enqueue")
15
+ tasks.should include("cavalcade:jobs:some_class:enqueue")
16
+ tasks.should include("cavalcade:jobs:some_long_class_name:enqueue")
17
+ end
18
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'cavalcade'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cavalcade
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Robby Grossman
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-11-15 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: activesupport
16
+ requirement: &70124168375860 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.3.2
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70124168375860
25
+ - !ruby/object:Gem::Dependency
26
+ name: i18n
27
+ requirement: &70124168375360 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70124168375360
36
+ - !ruby/object:Gem::Dependency
37
+ name: rake
38
+ requirement: &70124168374860 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0.9'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70124168374860
47
+ - !ruby/object:Gem::Dependency
48
+ name: resque
49
+ requirement: &70124168374340 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.19'
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *70124168374340
58
+ - !ruby/object:Gem::Dependency
59
+ name: rspec
60
+ requirement: &70124168373840 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: '2.6'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70124168373840
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: &70124168373320 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ~>
75
+ - !ruby/object:Gem::Version
76
+ version: 1.0.0
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *70124168373320
80
+ - !ruby/object:Gem::Dependency
81
+ name: jeweler
82
+ requirement: &70124168372820 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ version: 1.6.4
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *70124168372820
91
+ description: Resque can be very useful outside of a web app, too. What if you want
92
+ to write jobs in Ruby and just enqueue them from your console? Or from a Java application?
93
+ Or in cron jobs? Cavalcade to the resque! Cavalcade creates a resque-based, stand-alone
94
+ job queue, and provides rake tasks to enqueue all of your jobs.
95
+ email: robby@freerobby.com
96
+ executables: []
97
+ extensions: []
98
+ extra_rdoc_files:
99
+ - LICENSE.txt
100
+ - README.md
101
+ files:
102
+ - .document
103
+ - .rspec
104
+ - .rvmrc
105
+ - Gemfile
106
+ - Gemfile.lock
107
+ - LICENSE.txt
108
+ - README.md
109
+ - Rakefile
110
+ - VERSION
111
+ - cavalcade.gemspec
112
+ - lib/cavalcade.rb
113
+ - lib/cavalcade/job.rb
114
+ - lib/cavalcade/jobs_finder.rb
115
+ - lib/cavalcade/tasks.rb
116
+ - lib/cavalcade/tasks/jobs.rake
117
+ - spec/lib/cavalcade/job_spec.rb
118
+ - spec/lib/cavalcade/jobs_finder_spec.rb
119
+ - spec/lib/cavalcade/tasks/jobs_spec.rb
120
+ - spec/spec_helper.rb
121
+ homepage: http://github.com/freerobby/cavalcade
122
+ licenses:
123
+ - MIT
124
+ post_install_message:
125
+ rdoc_options: []
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ segments:
135
+ - 0
136
+ hash: -590044956478310162
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ none: false
139
+ requirements:
140
+ - - ! '>='
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ requirements: []
144
+ rubyforge_project:
145
+ rubygems_version: 1.8.10
146
+ signing_key:
147
+ specification_version: 3
148
+ summary: a lightweight infrastructure for using Resque as a stand-alone job queue
149
+ test_files: []