hireling 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ specification = Gem::Specification.new do |s|
6
6
  s.platform = Gem::Platform::RUBY
7
7
  s.name = "hireling"
8
8
  s.summary = "Simple scheduled process structure for Rails apps."
9
- s.version = "0.1.1"
9
+ s.version = "0.1.2"
10
10
  s.author = "David Vollbracht, Scott Conley"
11
11
  s.description = s.summary
12
12
  s.email = "scott.conley@flipstone.com"
@@ -17,7 +17,7 @@ specification = Gem::Specification.new do |s|
17
17
  s.add_dependency('daemons', '>= 1.0.10')
18
18
  s.add_dependency('rufus-scheduler', '>= 2.0.6')
19
19
 
20
- s.files = FileList['{lib,test,bin}/**/*.{rb,rake}', 'Rakefile'].to_a
20
+ s.files = FileList['{lib,test,bin}/**/*.*', 'Rakefile'].to_a
21
21
  end
22
22
 
23
23
  Rake::GemPackageTask.new(specification) do |package|
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hireling
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 1
10
- version: 0.1.1
9
+ - 2
10
+ version: 0.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - David Vollbracht, Scott Conley
@@ -61,8 +61,6 @@ extra_rdoc_files: []
61
61
  files:
62
62
  - lib/hireling/hireling.rb
63
63
  - lib/hireling/hirelings.rb
64
- - lib/new_hire/new_hire.rb
65
- - lib/new_hire/new_hires.rb
66
64
  - Rakefile
67
65
  has_rdoc: true
68
66
  homepage: ""
@@ -1,75 +0,0 @@
1
- class NewHire
2
- attr_accessor :reraise_work_item_errors
3
-
4
- class <<self
5
- attr_accessor :schedule
6
- end
7
-
8
- _name
9
- Dir[File.join(Rails.root, %w(app new_hires *.rb))].each do |hire_file|
10
- hire_name = File.basename(hire_file, '.rb')
11
- yield hire_name.to_sym
12
- end
13
- end
14
-
15
- def self.schedule_with_scheduler(scheduler)
16
- NewHire.schedule.schedule(scheduler, new)
17
- info "scheduled"
18
- end
19
-
20
- def call(job)
21
- self.class.info "starting work"
22
- work
23
- self.class.info "done working"
24
- end
25
-
26
- def work
27
- raise "#{self.class.name} doesn't know how to do their job."
28
- end
29
-
30
- def work_on_items_from(scope)
31
- scope.find_each(:batch_size => 100) do |item|
32
- begin
33
- yield item
34
- rescue Exception => e
35
- Rails.logger.error "#{e.class}: #{e.message} - #{e.backtrace.join("\n ")}"
36
- raise e if reraise_work_item_errors
37
- end
38
- end
39
- end
40
-
41
- def self.info(message)
42
- Rails.logger.info "WorkingGirl #{name} at #{Time.now}: #{message}"
43
- end
44
-
45
- class Schedule
46
- def initialize
47
- @proxies = {}
48
- end
49
- def [](new_hire_name)
50
- @proxies[new_hire_name] = SchedulerProxy.new
51
- end
52
-
53
- def schedule(rufus_scheduler, new_hire)
54
- proxy = @proxies[new_hire.class.name.underscore.to_sym]
55
- raise "No schedule found for #{new_hire.class}" unless proxy
56
- proxy.replay(rufus_scheduler,new_hire)
57
- end
58
- end
59
-
60
- class SchedulerProxy
61
- def replay(rufus_scheduler, new_hire)
62
- rufus_scheduler.send(@method, @arg, new_hire, :blocking => true)
63
- end
64
-
65
- [:at, :every, :cron].each do |scheduler_method|
66
- eval %{
67
- def #{scheduler_method}(arg)
68
- @method = #{scheduler_method.inspect}
69
- @arg = arg
70
- end
71
- }
72
- end
73
- end
74
- end
75
-
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
- #
3
- ENV["RAILS_ENV"] ||= "development"
4
-
5
- require File.dirname(__FILE__) + "/../../config/environment"
6
- require 'rufus/scheduler'
7
-
8
- scheduler = Rufus::Scheduler.start_new
9
-
10
- NewHire.each_app_hire_name do |hire_name|
11
- new_hire_class = hire_name.to_s.classify.constantize
12
- new_hire_class.schedule_with_scheduler scheduler
13
- end
14
-
15
- scheduler.join