taskmaster 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ gem 'whenever'
7
+ gem 'activesupport', '~> 2.3'
8
+
9
+ # Add dependencies to develop your gem here.
10
+ # Include everything needed to run rake, tests, features, etc.
11
+ group :development do
12
+ gem "bundler", "~> 1.0.0"
13
+ gem "jeweler", "~> 1.6.2"
14
+ gem "rcov", ">= 0"
15
+ gem "rake", "0.8.7"
16
+ end
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Ben Scofield
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.
@@ -0,0 +1,41 @@
1
+ = taskmaster
2
+
3
+ Make your Ruby classes cron-aware!
4
+
5
+
6
+ == Example
7
+
8
+ require 'taskmaster'
9
+
10
+ class FootSoldier
11
+ include Taskmaster::Henchman
12
+
13
+ every 10.minutes, :at => 5
14
+
15
+ def self.run
16
+ # do super cool and important stuff
17
+ end
18
+ end
19
+
20
+ puts FootSoldier.cron_output # => "5,15,25,35,45,55 * * * * /bin/bash -l -c 'cd /... && script/runner -e production '\''BulkTask.run'\'''"
21
+
22
+ == TODO
23
+
24
+ * figure out different task types
25
+ * add a Rake task to output and save crontab for all Taskmaster-including classes (fall back to whenever)
26
+
27
+ == Contributing to taskmaster
28
+
29
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
30
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
31
+ * Fork the project
32
+ * Start a feature/bugfix branch
33
+ * Commit and push until you are happy with your contribution
34
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
35
+ * 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.
36
+
37
+ == Copyright
38
+
39
+ Copyright (c) 2011 Ben Scofield. See LICENSE.txt for
40
+ further details.
41
+
@@ -0,0 +1,53 @@
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 = "taskmaster"
18
+ gem.homepage = "http://github.com/bscofield/taskmaster"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Make your Ruby classes cron-aware}
21
+ gem.description = %Q{Taskmaster allows you to easily make your Ruby classes aware of cron.}
22
+ gem.email = "git@turrean.com"
23
+ gem.authors = ["Ben Scofield"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ require 'rcov/rcovtask'
36
+ Rcov::RcovTask.new do |test|
37
+ test.libs << 'test'
38
+ test.pattern = 'test/**/test_*.rb'
39
+ test.verbose = true
40
+ test.rcov_opts << '--exclude "gems/*"'
41
+ end
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "taskmaster #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,9 @@
1
+ require 'whenever'
2
+
3
+ require './lib/taskmaster/henchman'
4
+
5
+ module Taskmaster
6
+ def self.cron_output
7
+ Henchman.included_in.map { |klass| klass.cron_output.strip }.join("\n")
8
+ end
9
+ end
@@ -0,0 +1,30 @@
1
+ module Taskmaster
2
+ module Henchman
3
+ def self.included(base)
4
+ base.extend ClassMethods
5
+
6
+ @including_classes ||= []
7
+ @including_classes << base
8
+ end
9
+
10
+ def self.included_in
11
+ @including_classes
12
+ end
13
+
14
+ module ClassMethods
15
+ def every(frequency, options = {})
16
+ @schedule = "every #{frequency.to_s}, #{options.inspect} do
17
+ runner \'#{self.name}.run\'
18
+ end"
19
+ end
20
+
21
+ def run
22
+ raise 'Not implemented'
23
+ end
24
+
25
+ def cron_output
26
+ Whenever::JobList.new(@schedule).generate_cron_output
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,67 @@
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 = %q{taskmaster}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Ben Scofield"]
12
+ s.date = %q{2011-06-16}
13
+ s.description = %q{Taskmaster allows you to easily make your Ruby classes aware of cron.}
14
+ s.email = %q{git@turrean.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "LICENSE.txt",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "lib/taskmaster.rb",
27
+ "lib/taskmaster/henchman.rb",
28
+ "taskmaster.gemspec",
29
+ "test/foot_soldier.rb",
30
+ "test/helper.rb",
31
+ "test/test_henchman.rb",
32
+ "test/test_taskmaster.rb"
33
+ ]
34
+ s.homepage = %q{http://github.com/bscofield/taskmaster}
35
+ s.licenses = ["MIT"]
36
+ s.require_paths = ["lib"]
37
+ s.rubygems_version = %q{1.6.2}
38
+ s.summary = %q{Make your Ruby classes cron-aware}
39
+
40
+ if s.respond_to? :specification_version then
41
+ s.specification_version = 3
42
+
43
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
44
+ s.add_runtime_dependency(%q<whenever>, [">= 0"])
45
+ s.add_runtime_dependency(%q<activesupport>, ["~> 2.3"])
46
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
47
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.2"])
48
+ s.add_development_dependency(%q<rcov>, [">= 0"])
49
+ s.add_development_dependency(%q<rake>, ["= 0.8.7"])
50
+ else
51
+ s.add_dependency(%q<whenever>, [">= 0"])
52
+ s.add_dependency(%q<activesupport>, ["~> 2.3"])
53
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
54
+ s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
55
+ s.add_dependency(%q<rcov>, [">= 0"])
56
+ s.add_dependency(%q<rake>, ["= 0.8.7"])
57
+ end
58
+ else
59
+ s.add_dependency(%q<whenever>, [">= 0"])
60
+ s.add_dependency(%q<activesupport>, ["~> 2.3"])
61
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
62
+ s.add_dependency(%q<jeweler>, ["~> 1.6.2"])
63
+ s.add_dependency(%q<rcov>, [">= 0"])
64
+ s.add_dependency(%q<rake>, ["= 0.8.7"])
65
+ end
66
+ end
67
+
@@ -0,0 +1,9 @@
1
+ class FootSoldier
2
+ include Taskmaster::Henchman
3
+
4
+ every 10.minutes
5
+
6
+ def self.run
7
+ # get beaten up by a superhero
8
+ end
9
+ end
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+
12
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
13
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
14
+ require 'taskmaster'
15
+
16
+ require './test/foot_soldier'
17
+
18
+ class Test::Unit::TestCase
19
+ end
@@ -0,0 +1,13 @@
1
+ require 'helper'
2
+
3
+ class TestTaskmaster < Test::Unit::TestCase
4
+ def test_class_should_be_definable
5
+ assert_nothing_raised do
6
+ FootSoldier
7
+ end
8
+ end
9
+
10
+ def test_footsoldier_should_have_expected_cron_output
11
+ assert_equal "0,10,20,30,40,50 * * * * /bin/bash -l -c 'cd /Users/benscofield/personal/util/taskmaster && script/runner -e production '\\''FootSoldier.run'\\'''", FootSoldier.cron_output.strip
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ require 'helper'
2
+
3
+ class TestTaskmaster < Test::Unit::TestCase
4
+ def test_constants_should_exist
5
+ assert_nothing_raised do
6
+ Taskmaster
7
+ Taskmaster::Henchman
8
+ end
9
+ end
10
+
11
+ def test_taskmaster_should_know_all_output
12
+ assert_equal "0,10,20,30,40,50 * * * * /bin/bash -l -c 'cd /Users/benscofield/personal/util/taskmaster && script/runner -e production '\\''FootSoldier.run'\\'''", Taskmaster.cron_output.strip
13
+ end
14
+ end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: taskmaster
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Ben Scofield
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-06-16 00:00:00.000000000 -04:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: whenever
17
+ requirement: &2160379820 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
23
+ type: :runtime
24
+ prerelease: false
25
+ version_requirements: *2160379820
26
+ - !ruby/object:Gem::Dependency
27
+ name: activesupport
28
+ requirement: &2160379120 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '2.3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: *2160379120
37
+ - !ruby/object:Gem::Dependency
38
+ name: bundler
39
+ requirement: &2160377580 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ version: 1.0.0
45
+ type: :development
46
+ prerelease: false
47
+ version_requirements: *2160377580
48
+ - !ruby/object:Gem::Dependency
49
+ name: jeweler
50
+ requirement: &2160376300 !ruby/object:Gem::Requirement
51
+ none: false
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: 1.6.2
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: *2160376300
59
+ - !ruby/object:Gem::Dependency
60
+ name: rcov
61
+ requirement: &2160375040 !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
66
+ version: '0'
67
+ type: :development
68
+ prerelease: false
69
+ version_requirements: *2160375040
70
+ - !ruby/object:Gem::Dependency
71
+ name: rake
72
+ requirement: &2160373360 !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - =
76
+ - !ruby/object:Gem::Version
77
+ version: 0.8.7
78
+ type: :development
79
+ prerelease: false
80
+ version_requirements: *2160373360
81
+ description: Taskmaster allows you to easily make your Ruby classes aware of cron.
82
+ email: git@turrean.com
83
+ executables: []
84
+ extensions: []
85
+ extra_rdoc_files:
86
+ - LICENSE.txt
87
+ - README.rdoc
88
+ files:
89
+ - .document
90
+ - Gemfile
91
+ - LICENSE.txt
92
+ - README.rdoc
93
+ - Rakefile
94
+ - VERSION
95
+ - lib/taskmaster.rb
96
+ - lib/taskmaster/henchman.rb
97
+ - taskmaster.gemspec
98
+ - test/foot_soldier.rb
99
+ - test/helper.rb
100
+ - test/test_henchman.rb
101
+ - test/test_taskmaster.rb
102
+ has_rdoc: true
103
+ homepage: http://github.com/bscofield/taskmaster
104
+ licenses:
105
+ - MIT
106
+ post_install_message:
107
+ rdoc_options: []
108
+ require_paths:
109
+ - lib
110
+ required_ruby_version: !ruby/object:Gem::Requirement
111
+ none: false
112
+ requirements:
113
+ - - ! '>='
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ segments:
117
+ - 0
118
+ hash: 2376148929927607973
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ none: false
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 1.6.2
128
+ signing_key:
129
+ specification_version: 3
130
+ summary: Make your Ruby classes cron-aware
131
+ test_files: []