daemon-kit 0.1.8rc2 → 0.1.8rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. data/Rakefile +1 -0
  2. data/daemon-kit.gemspec +36 -36
  3. data/lib/daemon_kit.rb +1 -1
  4. data/lib/daemon_kit/amqp.rb +1 -0
  5. data/lib/daemon_kit/cron.rb +16 -0
  6. data/lib/daemon_kit/deployment/capistrano.rb +34 -0
  7. data/lib/daemon_kit/error_handlers/hoptoad.rb +8 -2
  8. data/lib/daemon_kit/generators.rb +1 -1
  9. data/lib/daemon_kit/generators/base.rb +1 -1
  10. data/lib/daemon_kit/ruote_participants.rb +7 -1
  11. data/lib/daemon_kit/ruote_workitem.rb +30 -20
  12. data/lib/daemon_kit/tasks/environment.rake +1 -0
  13. data/lib/daemon_kit/vendor/{thor-0.12.3 → thor-0.13.6}/CHANGELOG.rdoc +9 -0
  14. data/lib/daemon_kit/vendor/{thor-0.12.3 → thor-0.13.6}/LICENSE +0 -0
  15. data/lib/daemon_kit/vendor/{thor-0.12.3 → thor-0.13.6}/README.rdoc +65 -2
  16. data/lib/daemon_kit/vendor/{thor-0.12.3 → thor-0.13.6}/Thorfile +14 -9
  17. data/lib/daemon_kit/vendor/{thor-0.12.3 → thor-0.13.6}/lib/thor.rb +10 -8
  18. data/lib/daemon_kit/vendor/{thor-0.12.3 → thor-0.13.6}/lib/thor/actions.rb +34 -12
  19. data/lib/daemon_kit/vendor/{thor-0.12.3 → thor-0.13.6}/lib/thor/actions/create_file.rb +0 -0
  20. data/lib/daemon_kit/vendor/{thor-0.12.3 → thor-0.13.6}/lib/thor/actions/directory.rb +0 -0
  21. data/lib/daemon_kit/vendor/{thor-0.12.3 → thor-0.13.6}/lib/thor/actions/empty_directory.rb +0 -0
  22. data/lib/daemon_kit/vendor/{thor-0.12.3 → thor-0.13.6}/lib/thor/actions/file_manipulation.rb +1 -1
  23. data/lib/daemon_kit/vendor/{thor-0.12.3 → thor-0.13.6}/lib/thor/actions/inject_into_file.rb +9 -6
  24. data/lib/daemon_kit/vendor/{thor-0.12.3 → thor-0.13.6}/lib/thor/base.rb +45 -20
  25. data/lib/daemon_kit/vendor/{thor-0.12.3 → thor-0.13.6}/lib/thor/core_ext/file_binary_read.rb +0 -0
  26. data/lib/daemon_kit/vendor/{thor-0.12.3 → thor-0.13.6}/lib/thor/core_ext/hash_with_indifferent_access.rb +0 -0
  27. data/lib/daemon_kit/vendor/{thor-0.12.3 → thor-0.13.6}/lib/thor/core_ext/ordered_hash.rb +0 -0
  28. data/lib/daemon_kit/vendor/{thor-0.12.3 → thor-0.13.6}/lib/thor/error.rb +3 -0
  29. data/lib/daemon_kit/vendor/{thor-0.12.3 → thor-0.13.6}/lib/thor/group.rb +21 -21
  30. data/lib/daemon_kit/vendor/{thor-0.12.3 → thor-0.13.6}/lib/thor/invocation.rb +19 -17
  31. data/lib/daemon_kit/vendor/{thor-0.12.3 → thor-0.13.6}/lib/thor/parser.rb +0 -0
  32. data/lib/daemon_kit/vendor/{thor-0.12.3 → thor-0.13.6}/lib/thor/parser/argument.rb +0 -0
  33. data/lib/daemon_kit/vendor/{thor-0.12.3 → thor-0.13.6}/lib/thor/parser/arguments.rb +9 -4
  34. data/lib/daemon_kit/vendor/{thor-0.12.3 → thor-0.13.6}/lib/thor/parser/option.rb +0 -4
  35. data/lib/daemon_kit/vendor/{thor-0.12.3 → thor-0.13.6}/lib/thor/parser/options.rb +41 -14
  36. data/lib/daemon_kit/vendor/{thor-0.12.3 → thor-0.13.6}/lib/thor/rake_compat.rb +0 -0
  37. data/lib/daemon_kit/vendor/{thor-0.12.3 → thor-0.13.6}/lib/thor/runner.rb +20 -9
  38. data/lib/daemon_kit/vendor/{thor-0.12.3 → thor-0.13.6}/lib/thor/shell.rb +8 -3
  39. data/lib/daemon_kit/vendor/{thor-0.12.3 → thor-0.13.6}/lib/thor/shell/basic.rb +0 -0
  40. data/lib/daemon_kit/vendor/{thor-0.12.3 → thor-0.13.6}/lib/thor/shell/color.rb +0 -0
  41. data/lib/daemon_kit/vendor/{thor-0.12.3 → thor-0.13.6}/lib/thor/task.rb +24 -33
  42. data/lib/daemon_kit/vendor/{thor-0.12.3 → thor-0.13.6}/lib/thor/util.rb +9 -18
  43. data/lib/daemon_kit/vendor/thor-0.13.6/lib/thor/version.rb +3 -0
  44. data/lib/generators/daemon_kit/amqp/amqp_generator.rb +1 -1
  45. data/lib/generators/daemon_kit/amqp/templates/config/pre-daemonize/amqp.rb +1 -1
  46. data/lib/generators/daemon_kit/app/app_generator.rb +1 -1
  47. data/lib/generators/daemon_kit/app/templates/README.tt +58 -0
  48. data/lib/generators/daemon_kit/capistrano/capistrano_generator.rb +5 -0
  49. data/lib/generators/daemon_kit/cron/cron_generator.rb +1 -1
  50. data/lib/generators/daemon_kit/cron/templates/config/pre-daemonize/cron.rb +1 -1
  51. data/lib/generators/daemon_kit/nanite_agent/nanite_agent_generator.rb +1 -1
  52. data/lib/generators/daemon_kit/nanite_agent/templates/config/pre-daemonize/nanite_agent.rb +1 -1
  53. data/lib/generators/daemon_kit/ruote/ruote_generator.rb +2 -2
  54. data/lib/generators/daemon_kit/ruote/templates/config/pre-daemonize/ruote.rb +2 -2
  55. data/lib/generators/daemon_kit/xmpp/templates/config/pre-daemonize/xmpp.rb +1 -1
  56. data/lib/generators/daemon_kit/xmpp/xmpp_generator.rb +1 -1
  57. data/tasks/rspec.rake +6 -7
  58. metadata +77 -49
  59. data/lib/daemon_kit/vendor/thor-0.12.3/lib/thor/version.rb +0 -3
  60. data/lib/generators/daemon_kit/app/templates/README +0 -48
data/Rakefile CHANGED
@@ -14,6 +14,7 @@ begin
14
14
  gemspec.authors = ['kenneth.kalmer@gmail.com']
15
15
  gemspec.post_install_message = IO.read('PostInstall.txt')
16
16
  gemspec.extra_rdoc_files.include '*.txt'
17
+ gemspec.files.include("lib/generators/**/*", "lib/daemon_kit/vendor/**/*")
17
18
 
18
19
  gemspec.add_dependency 'eventmachine', '>=0.12.10'
19
20
  gemspec.add_development_dependency 'rspec'
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{daemon-kit}
8
- s.version = "0.1.8rc2"
8
+ s.version = "0.1.8rc3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["kenneth.kalmer@gmail.com"]
12
- s.date = %q{2010-04-14}
12
+ s.date = %q{2010-08-02}
13
13
  s.default_executable = %q{daemon-kit}
14
14
  s.description = %q{daemon-kit aims to simplify creating Ruby daemons by providing a sound application skeleton (through a generator), task specific generators (jabber bot, etc) and robust environment management code.}
15
15
  s.email = %q{kenneth.kalmer@gmail.com}
@@ -75,37 +75,37 @@ Gem::Specification.new do |s|
75
75
  "lib/daemon_kit/tasks/god.rake",
76
76
  "lib/daemon_kit/tasks/log.rake",
77
77
  "lib/daemon_kit/tasks/monit.rake",
78
- "lib/daemon_kit/vendor/thor-0.12.3/CHANGELOG.rdoc",
79
- "lib/daemon_kit/vendor/thor-0.12.3/LICENSE",
80
- "lib/daemon_kit/vendor/thor-0.12.3/README.rdoc",
81
- "lib/daemon_kit/vendor/thor-0.12.3/Thorfile",
82
- "lib/daemon_kit/vendor/thor-0.12.3/lib/thor.rb",
83
- "lib/daemon_kit/vendor/thor-0.12.3/lib/thor/actions.rb",
84
- "lib/daemon_kit/vendor/thor-0.12.3/lib/thor/actions/create_file.rb",
85
- "lib/daemon_kit/vendor/thor-0.12.3/lib/thor/actions/directory.rb",
86
- "lib/daemon_kit/vendor/thor-0.12.3/lib/thor/actions/empty_directory.rb",
87
- "lib/daemon_kit/vendor/thor-0.12.3/lib/thor/actions/file_manipulation.rb",
88
- "lib/daemon_kit/vendor/thor-0.12.3/lib/thor/actions/inject_into_file.rb",
89
- "lib/daemon_kit/vendor/thor-0.12.3/lib/thor/base.rb",
90
- "lib/daemon_kit/vendor/thor-0.12.3/lib/thor/core_ext/file_binary_read.rb",
91
- "lib/daemon_kit/vendor/thor-0.12.3/lib/thor/core_ext/hash_with_indifferent_access.rb",
92
- "lib/daemon_kit/vendor/thor-0.12.3/lib/thor/core_ext/ordered_hash.rb",
93
- "lib/daemon_kit/vendor/thor-0.12.3/lib/thor/error.rb",
94
- "lib/daemon_kit/vendor/thor-0.12.3/lib/thor/group.rb",
95
- "lib/daemon_kit/vendor/thor-0.12.3/lib/thor/invocation.rb",
96
- "lib/daemon_kit/vendor/thor-0.12.3/lib/thor/parser.rb",
97
- "lib/daemon_kit/vendor/thor-0.12.3/lib/thor/parser/argument.rb",
98
- "lib/daemon_kit/vendor/thor-0.12.3/lib/thor/parser/arguments.rb",
99
- "lib/daemon_kit/vendor/thor-0.12.3/lib/thor/parser/option.rb",
100
- "lib/daemon_kit/vendor/thor-0.12.3/lib/thor/parser/options.rb",
101
- "lib/daemon_kit/vendor/thor-0.12.3/lib/thor/rake_compat.rb",
102
- "lib/daemon_kit/vendor/thor-0.12.3/lib/thor/runner.rb",
103
- "lib/daemon_kit/vendor/thor-0.12.3/lib/thor/shell.rb",
104
- "lib/daemon_kit/vendor/thor-0.12.3/lib/thor/shell/basic.rb",
105
- "lib/daemon_kit/vendor/thor-0.12.3/lib/thor/shell/color.rb",
106
- "lib/daemon_kit/vendor/thor-0.12.3/lib/thor/task.rb",
107
- "lib/daemon_kit/vendor/thor-0.12.3/lib/thor/util.rb",
108
- "lib/daemon_kit/vendor/thor-0.12.3/lib/thor/version.rb",
78
+ "lib/daemon_kit/vendor/thor-0.13.6/CHANGELOG.rdoc",
79
+ "lib/daemon_kit/vendor/thor-0.13.6/LICENSE",
80
+ "lib/daemon_kit/vendor/thor-0.13.6/README.rdoc",
81
+ "lib/daemon_kit/vendor/thor-0.13.6/Thorfile",
82
+ "lib/daemon_kit/vendor/thor-0.13.6/lib/thor.rb",
83
+ "lib/daemon_kit/vendor/thor-0.13.6/lib/thor/actions.rb",
84
+ "lib/daemon_kit/vendor/thor-0.13.6/lib/thor/actions/create_file.rb",
85
+ "lib/daemon_kit/vendor/thor-0.13.6/lib/thor/actions/directory.rb",
86
+ "lib/daemon_kit/vendor/thor-0.13.6/lib/thor/actions/empty_directory.rb",
87
+ "lib/daemon_kit/vendor/thor-0.13.6/lib/thor/actions/file_manipulation.rb",
88
+ "lib/daemon_kit/vendor/thor-0.13.6/lib/thor/actions/inject_into_file.rb",
89
+ "lib/daemon_kit/vendor/thor-0.13.6/lib/thor/base.rb",
90
+ "lib/daemon_kit/vendor/thor-0.13.6/lib/thor/core_ext/file_binary_read.rb",
91
+ "lib/daemon_kit/vendor/thor-0.13.6/lib/thor/core_ext/hash_with_indifferent_access.rb",
92
+ "lib/daemon_kit/vendor/thor-0.13.6/lib/thor/core_ext/ordered_hash.rb",
93
+ "lib/daemon_kit/vendor/thor-0.13.6/lib/thor/error.rb",
94
+ "lib/daemon_kit/vendor/thor-0.13.6/lib/thor/group.rb",
95
+ "lib/daemon_kit/vendor/thor-0.13.6/lib/thor/invocation.rb",
96
+ "lib/daemon_kit/vendor/thor-0.13.6/lib/thor/parser.rb",
97
+ "lib/daemon_kit/vendor/thor-0.13.6/lib/thor/parser/argument.rb",
98
+ "lib/daemon_kit/vendor/thor-0.13.6/lib/thor/parser/arguments.rb",
99
+ "lib/daemon_kit/vendor/thor-0.13.6/lib/thor/parser/option.rb",
100
+ "lib/daemon_kit/vendor/thor-0.13.6/lib/thor/parser/options.rb",
101
+ "lib/daemon_kit/vendor/thor-0.13.6/lib/thor/rake_compat.rb",
102
+ "lib/daemon_kit/vendor/thor-0.13.6/lib/thor/runner.rb",
103
+ "lib/daemon_kit/vendor/thor-0.13.6/lib/thor/shell.rb",
104
+ "lib/daemon_kit/vendor/thor-0.13.6/lib/thor/shell/basic.rb",
105
+ "lib/daemon_kit/vendor/thor-0.13.6/lib/thor/shell/color.rb",
106
+ "lib/daemon_kit/vendor/thor-0.13.6/lib/thor/task.rb",
107
+ "lib/daemon_kit/vendor/thor-0.13.6/lib/thor/util.rb",
108
+ "lib/daemon_kit/vendor/thor-0.13.6/lib/thor/version.rb",
109
109
  "lib/daemon_kit/xmpp.rb",
110
110
  "lib/generators/daemon_kit/amqp/USAGE",
111
111
  "lib/generators/daemon_kit/amqp/amqp_generator.rb",
@@ -115,7 +115,7 @@ Gem::Specification.new do |s|
115
115
  "lib/generators/daemon_kit/app/USAGE",
116
116
  "lib/generators/daemon_kit/app/app_generator.rb",
117
117
  "lib/generators/daemon_kit/app/templates/Gemfile",
118
- "lib/generators/daemon_kit/app/templates/README",
118
+ "lib/generators/daemon_kit/app/templates/README.tt",
119
119
  "lib/generators/daemon_kit/app/templates/Rakefile",
120
120
  "lib/generators/daemon_kit/app/templates/bin/daemon.tt",
121
121
  "lib/generators/daemon_kit/app/templates/config/arguments.rb",
@@ -220,7 +220,7 @@ To get started quickly run 'daemon-kit' without any arguments
220
220
  }
221
221
  s.rdoc_options = ["--charset=UTF-8"]
222
222
  s.require_paths = ["lib"]
223
- s.rubygems_version = %q{1.3.5}
223
+ s.rubygems_version = %q{1.3.7}
224
224
  s.summary = %q{Opinionated framework for Ruby daemons}
225
225
  s.test_files = [
226
226
  "spec/abstract_logger_spec.rb",
@@ -247,7 +247,7 @@ To get started quickly run 'daemon-kit' without any arguments
247
247
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
248
248
  s.specification_version = 3
249
249
 
250
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
250
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
251
251
  s.add_runtime_dependency(%q<eventmachine>, [">= 0.12.10"])
252
252
  s.add_development_dependency(%q<rspec>, [">= 0"])
253
253
  s.add_development_dependency(%q<cucumber>, [">= 0"])
@@ -13,7 +13,7 @@ $:.unshift( File.dirname(__FILE__).to_absolute_path ) unless
13
13
  $:.include?( File.dirname(__FILE__).to_absolute_path )
14
14
 
15
15
  module DaemonKit
16
- VERSION = '0.1.8rc2'
16
+ VERSION = '0.1.8rc3'
17
17
 
18
18
  autoload :Initializer, 'daemon_kit/initializer'
19
19
  autoload :Application, 'daemon_kit/application'
@@ -1,4 +1,5 @@
1
1
  require 'yaml'
2
+ require 'mq'
2
3
 
3
4
  module DaemonKit
4
5
  # Thin wrapper around the amqp gem, specifically designed to ease
@@ -11,8 +11,10 @@ module DaemonKit
11
11
  class Cron
12
12
 
13
13
  @instance = nil
14
+ @exception_handler = nil
14
15
 
15
16
  attr_reader :scheduler
17
+ attr_accessor :exception_handler
16
18
 
17
19
  class << self
18
20
 
@@ -25,6 +27,10 @@ module DaemonKit
25
27
  instance.scheduler
26
28
  end
27
29
 
30
+ def handle_exception( &block )
31
+ instance.exception_handler = block
32
+ end
33
+
28
34
  private :new
29
35
 
30
36
  # Once the scheduler has been configured, call #run to block the
@@ -43,6 +49,16 @@ module DaemonKit
43
49
 
44
50
  def initialize
45
51
  @scheduler = Rufus::Scheduler.start_new
52
+
53
+ def @scheduler.handle_exception( job, exception )
54
+ DaemonKit::Cron.instance.handle_exception( job, exception )
55
+ end
56
+ end
57
+
58
+ def handle_exception( job, exception )
59
+ DaemonKit.logger.error( "Cron: job #{job.job_id} caught exception: '#{exception}'" )
60
+ DaemonKit.logger.exception( exception )
61
+ @exception_handler.call( job, exception ) unless @exception_handler.nil?
46
62
  end
47
63
  end
48
64
  end
@@ -67,6 +67,11 @@ _cset(:run_method) { fetch(:use_sudo, true) ? :sudo : :run }
67
67
  # standalone case, or during deployment.
68
68
  _cset(:latest_release) { exists?(:deploy_timestamped) ? release_path : current_release }
69
69
 
70
+ # =========================================================================
71
+ # Variables for bundler
72
+ # =========================================================================
73
+ _cset(:use_bundler, true)
74
+
70
75
  # =========================================================================
71
76
  # These are helper methods that will be available to your recipes.
72
77
  # =========================================================================
@@ -198,11 +203,16 @@ namespace :deploy do
198
203
  control software you are using (it defaults to :subversion), and the \
199
204
  :deploy_via variable to the strategy you want to use to deploy (it \
200
205
  defaults to :checkout).
206
+
207
+ Your bundles will also be installed/updated as part of this step. \
208
+ You can disable bundler on remote reployments with the :user_bundler \
209
+ variable.
201
210
  DESC
202
211
  task :update_code, :except => { :no_release => true } do
203
212
  on_rollback { run "rm -rf #{release_path}; true" }
204
213
  strategy.deploy!
205
214
  finalize_update
215
+ bundler.bundle_new_release if fetch(:use_bundler, true)
206
216
  end
207
217
 
208
218
  desc <<-DESC
@@ -398,6 +408,8 @@ namespace :deploy do
398
408
  task :check, :except => { :no_release => true } do
399
409
  dependencies = strategy.check!
400
410
 
411
+ depend( :remote, :gem, "bundler", ">= 0.9.26" ) if fetch(:use_bundler, true)
412
+
401
413
  other = fetch(:dependencies, {})
402
414
  other.each do |location, types|
403
415
  types.each do |type, calls|
@@ -480,3 +492,25 @@ namespace :deploy do
480
492
  end
481
493
  end
482
494
  end
495
+
496
+ namespace :bundler do
497
+ task :create_symlink, :roles => :app do
498
+ shared_dir = File.join(shared_path, 'bundle')
499
+ release_dir = File.join(current_release, '.bundle')
500
+ run("mkdir -p #{shared_dir} && ln -s #{shared_dir} #{release_dir}")
501
+ end
502
+
503
+ task :bundle_new_release, :roles => :app do
504
+ bundler.create_symlink
505
+ run "cd #{release_path} && bundle install .bundle --without test"
506
+ end
507
+
508
+ task :lock, :roles => :app do
509
+ run "cd #{current_release} && bundle lock;"
510
+ end
511
+
512
+ task :unlock, :roles => :app do
513
+ run "cd #{current_release} && bundle unlock;"
514
+ end
515
+ end
516
+
@@ -52,7 +52,7 @@ module DaemonKit
52
52
  end
53
53
 
54
54
  def to_xml
55
- data = [ method, file, number ].map { |s| URI.escape( s, %q{"'<>&} ) }
55
+ data = [ method, file, number ].map { |s| URI.escape( s || 'unknown', %q{"'<>&} ) }
56
56
  %q{<line method="%s" file="%s" number="%s" />} % data
57
57
  end
58
58
 
@@ -144,6 +144,12 @@ module DaemonKit
144
144
 
145
145
  def format_exception( exception )
146
146
  lines = Backtrace.parse( exception.backtrace )
147
+ exception_message= exception.message
148
+ exception_message.gsub!("\"","&quot;")
149
+ exception_message.gsub!("'","&apos;")
150
+ exception_message.gsub!("&","&amp;")
151
+ exception_message.gsub!("<","&lt;")
152
+ exception_message.gsub!(">","&gt;")
147
153
 
148
154
  <<-EOF
149
155
  <?xml version="1.0" encoding="UTF-8"?>
@@ -156,7 +162,7 @@ module DaemonKit
156
162
  </notifier>
157
163
  <error>
158
164
  <class>#{exception.class.name}</class>
159
- <message>#{exception.message}</message>
165
+ <message>#{exception_message}</message>
160
166
  <backtrace>
161
167
  #{Backtrace.parse( exception.backtrace ).lines.inject('') { |string,line| string << line.to_xml }}
162
168
  </backtrace>
@@ -1,5 +1,5 @@
1
1
  # TODO: Don't always depend on bundled thor
2
- $:.unshift File.dirname(__FILE__) + '/vendor/thor-0.12.3/lib'
2
+ $:.unshift File.dirname(__FILE__) + '/vendor/thor-0.13.6/lib'
3
3
 
4
4
  require 'daemon_kit/generators/base'
5
5
 
@@ -1,4 +1,4 @@
1
- require 'thor'
1
+ require 'thor/group'
2
2
 
3
3
  module DaemonKit
4
4
  module Generators
@@ -35,6 +35,7 @@ module DaemonKit
35
35
  def initialize
36
36
  @transports = []
37
37
  @participants = {}
38
+ @runtime_queues = []
38
39
 
39
40
  @configuration = Config.load('ruote')
40
41
  end
@@ -80,12 +81,17 @@ module DaemonKit
80
81
  run_amqp! if @transports.include?( :amqp )
81
82
  end
82
83
 
84
+ # Subscribe to additional queues not specified in ruote.yml
85
+ def subscribe_to( queue )
86
+ @runtime_queues << queue
87
+ end
88
+
83
89
  private
84
90
 
85
91
  def run_amqp!
86
92
  AMQP.run do
87
93
  mq = ::MQ.new
88
- queues = @configuration['amqp']['queues'].to_a
94
+ queues = @configuration['amqp']['queues'].to_a | @runtime_queues
89
95
 
90
96
  queues.each do |q|
91
97
  DaemonKit.logger.debug("Subscribing to #{q} for workitems")
@@ -7,10 +7,10 @@ module DaemonKit
7
7
 
8
8
  class << self
9
9
 
10
- # = Process incoming commands via an AMQP queue
10
+ # = Process incoming commands via an AMQP queue
11
11
  #
12
12
  # Expects a JSON workitem from ruote that has these fields set in
13
- # attributes key:
13
+ # fields key:
14
14
  #
15
15
  # {
16
16
  # 'reply_queue' => 'queue to send replies to',
@@ -52,15 +52,16 @@ module DaemonKit
52
52
  if target.nil? || method.nil?
53
53
  msg = "Missing target/method in command parameter, or command parameter missing"
54
54
  DaemonKit.logger.error( msg )
55
- work["daemon_kit"] = { "error" => msg }
55
+ work["__error__"] = msg
56
56
 
57
- elsif target.public_methods.include?( method )
58
- target.perform( method, work )
57
+ elsif target.public_methods.map { |m| m.to_s }.include?( method ) # 1.8.x => [ 'foo' ]
58
+ target.perform( method, work ) # 1.9.x => [ :foo ]
59
59
 
60
60
  else
61
- msg = "Workitem cannot be processes: #{method} not exposed by #{target.inspect}"
61
+ msg = "Workitem cannot be processes: '#{method}' not exposed by #{target.inspect}"
62
62
  DaemonKit.logger.error( msg )
63
- work["daemon_kit"] = { "error" => msg }
63
+ p [ :work, work.inspect ]
64
+ work["__error__"] = msg
64
65
  end
65
66
 
66
67
  reply_to_engine( transport, work )
@@ -90,8 +91,7 @@ module DaemonKit
90
91
 
91
92
  def reply_via_amqp( response )
92
93
  DaemonKit.logger.debug("Replying to engine via AMQP with #{response.inspect}")
93
-
94
- ::MQ.queue( response['reply_queue'] ).publish( response.to_json )
94
+ ::MQ.queue( response['params']['reply_queue'] ).publish( response.to_json )
95
95
 
96
96
  response
97
97
  end
@@ -111,7 +111,7 @@ module DaemonKit
111
111
  end
112
112
 
113
113
  def fei
114
- @workitem['flow_expression_id']
114
+ @workitem['fei']
115
115
  end
116
116
 
117
117
  def short_fei
@@ -119,8 +119,8 @@ module DaemonKit
119
119
  '(' + [
120
120
  'fei', self.fei['owfe_version'], self.fei['engine_id'],
121
121
  self.fei['workflow_definition_url'], self.fei['workflow_definition_name'],
122
- self.fei['workflow_definition_revision'], self.fei['workflow_instance_id'],
123
- self.fei['expression_name'], self.fei['expression_id']
122
+ self.fei['workflow_definition_revision'], self.fei['wfid'],
123
+ self.fei['expression_name'], self.fei['expid']
124
124
  ].join(' ') + ')'
125
125
  end
126
126
 
@@ -136,16 +136,26 @@ module DaemonKit
136
136
  @workitem['participant_name']
137
137
  end
138
138
 
139
- def attributes
140
- @workitem['attributes']
139
+ def has_field?(a)
140
+ self.fields.keys.include?( a )
141
+ end
142
+
143
+ def fields
144
+ @workitem['fields'] ||= @workitem['attributes']
141
145
  end
142
146
 
147
+ # backwards compatible..
148
+
149
+ alias :attributes :fields
150
+ alias :has_attribute? :has_field?
151
+
152
+
143
153
  def []( key )
144
- self.attributes[ key ]
154
+ self.fields[ key ]
145
155
  end
146
156
 
147
157
  def []=( key, value )
148
- self.attributes[ key ] = value
158
+ self.fields[ key ] = value
149
159
  end
150
160
 
151
161
  def to_json
@@ -156,9 +166,9 @@ module DaemonKit
156
166
  # has timed out or not. This method will only ever work if you used the
157
167
  # +:timeout: parameter was set for the expression.
158
168
  def timed_out?
159
- key = fei['workflow_instance_id'] + '__' + fei['expression_id']
169
+ key = fei['wfid'] + '__' + fei['expid']
160
170
 
161
- if self.attributes["__timeouts__"] && timeout = self.attributes["__timeouts__"][ key ]
171
+ if self.fields["__timeouts__"] && timeout = self.fields["__timeouts__"][ key ]
162
172
  return Time.at( timeout.last ) < Time.now
163
173
  end
164
174
 
@@ -166,8 +176,8 @@ module DaemonKit
166
176
  end
167
177
 
168
178
  def method_missing( method_name, *args )
169
- if self.attributes.keys.include?( method_name.to_s )
170
- return self.attributes[ method_name.to_s ]
179
+ if self.fields.keys.include?( method_name.to_s )
180
+ return self.fields[ method_name.to_s ]
171
181
  end
172
182
 
173
183
  super
@@ -2,6 +2,7 @@ task :environment do
2
2
  $daemon_kit_rake_task = true
3
3
 
4
4
  require 'config/environment'
5
+ DaemonKit::Application.running!
5
6
  end
6
7
 
7
8
  task "Execute system commands in other tasks with sudo"
@@ -1,5 +1,14 @@
1
+ == 0.13, released 2010-02-03
2
+
3
+ * Several bug fixes
4
+ * Decoupled Thor::Group and Thor, so it's easier to vendor
5
+ * Added check_unknown_options! in case you want error messages to be raised in valid switches.
6
+ * run(command) should return the results of command
7
+
1
8
  == 0.12, released 2010-01-02
2
9
 
10
+ * Methods generated by attr_* are automatically not marked as tasks
11
+ * inject_into_file does not add the same content twice, unless :force is set
3
12
  * Removed rr in favor to rspec mock framework
4
13
  * Improved output for thor -T
5
14
  * [#7] Do not force white color on status