daemon-kit 0.1.8.1 → 0.1.8.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,8 +19,8 @@ describe DaemonKit::Configuration do
19
19
  end
20
20
 
21
21
  it "should set a default umask" do
22
- File.umask.should_not be(0)
23
- File.umask.should be(18)
22
+ File.umask.should_not eq(0)
23
+ File.umask.should eq(18)
24
24
  end
25
25
 
26
26
  end
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'rubygems'
2
- gem 'rspec'
3
- require 'spec'
2
+ require 'rspec'
4
3
 
5
4
  require 'mocha'
6
5
  require 'fileutils'
@@ -11,7 +10,7 @@ DAEMON_ROOT = "#{File.dirname(__FILE__)}/../tmp"
11
10
  $:.unshift( File.dirname(__FILE__) + '/../lib' )
12
11
  require 'daemon_kit'
13
12
 
14
- Spec::Runner.configure do |config|
13
+ RSpec.configure do |config|
15
14
  # == Mock Framework
16
15
  #
17
16
  # RSpec uses it's own mocking framework by default. If you prefer to
data/tasks/rspec.rake CHANGED
@@ -1,16 +1,15 @@
1
1
  begin
2
- require 'spec'
2
+ require 'rspec'
3
3
  rescue LoadError
4
4
  require 'rubygems'
5
- require 'spec'
5
+ require 'rspec'
6
6
  end
7
7
  begin
8
- require 'spec/rake/spectask'
8
+ require 'rspec/core/rake_task'
9
9
 
10
10
  desc "Run the specs under spec/models"
11
- Spec::Rake::SpecTask.new do |t|
12
- t.spec_opts = ['--options', "spec/spec.opts"]
13
- t.spec_files = FileList['spec/**/*_spec.rb']
11
+ RSpec::Core::RakeTask.new do |t|
12
+ t.rspec_opts = ['--options', "spec/spec.opts"]
14
13
  end
15
14
  rescue LoadError
16
15
  puts <<-EOS
metadata CHANGED
@@ -1,44 +1,53 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daemon-kit
3
3
  version: !ruby/object:Gem::Version
4
- hash: 101
5
- prerelease: false
4
+ hash: 99
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
9
  - 8
10
- - 1
11
- version: 0.1.8.1
10
+ - 2
11
+ version: 0.1.8.2
12
12
  platform: ruby
13
13
  authors:
14
- - kenneth.kalmer@gmail.com
14
+ - Kenneth Kalmer
15
15
  autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-08-04 00:00:00 +02:00
20
- default_executable: daemon-kit
19
+ date: 2011-10-30 00:00:00 Z
21
20
  dependencies:
22
21
  - !ruby/object:Gem::Dependency
23
- name: eventmachine
24
- prerelease: false
25
- requirement: &id001 !ruby/object:Gem::Requirement
22
+ version_requirements: &id001 !ruby/object:Gem::Requirement
26
23
  none: false
27
24
  requirements:
28
25
  - - ">="
29
26
  - !ruby/object:Gem::Version
30
- hash: 59
27
+ hash: 3
31
28
  segments:
32
29
  - 0
33
- - 12
34
- - 10
35
- version: 0.12.10
36
- type: :runtime
37
- version_requirements: *id001
30
+ version: "0"
31
+ prerelease: false
32
+ requirement: *id001
33
+ type: :development
34
+ name: bundler
38
35
  - !ruby/object:Gem::Dependency
39
- name: rspec
36
+ version_requirements: &id002 !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ hash: 3
42
+ segments:
43
+ - 0
44
+ version: "0"
40
45
  prerelease: false
41
- requirement: &id002 !ruby/object:Gem::Requirement
46
+ requirement: *id002
47
+ type: :development
48
+ name: rake
49
+ - !ruby/object:Gem::Dependency
50
+ version_requirements: &id003 !ruby/object:Gem::Requirement
42
51
  none: false
43
52
  requirements:
44
53
  - - ">="
@@ -47,12 +56,59 @@ dependencies:
47
56
  segments:
48
57
  - 0
49
58
  version: "0"
59
+ prerelease: false
60
+ requirement: *id003
61
+ type: :development
62
+ name: rdoc
63
+ - !ruby/object:Gem::Dependency
64
+ version_requirements: &id004 !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ hash: 15
70
+ segments:
71
+ - 2
72
+ - 6
73
+ version: "2.6"
74
+ prerelease: false
75
+ requirement: *id004
50
76
  type: :development
51
- version_requirements: *id002
77
+ name: rspec
52
78
  - !ruby/object:Gem::Dependency
79
+ version_requirements: &id005 !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ~>
83
+ - !ruby/object:Gem::Version
84
+ hash: 55
85
+ segments:
86
+ - 0
87
+ - 10
88
+ - 0
89
+ version: 0.10.0
90
+ prerelease: false
91
+ requirement: *id005
92
+ type: :development
53
93
  name: cucumber
94
+ - !ruby/object:Gem::Dependency
95
+ version_requirements: &id006 !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ~>
99
+ - !ruby/object:Gem::Version
100
+ hash: 35
101
+ segments:
102
+ - 0
103
+ - 9
104
+ - 12
105
+ version: 0.9.12
54
106
  prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
107
+ requirement: *id006
108
+ type: :development
109
+ name: mocha
110
+ - !ruby/object:Gem::Dependency
111
+ version_requirements: &id007 !ruby/object:Gem::Requirement
56
112
  none: false
57
113
  requirements:
58
114
  - - ">="
@@ -61,10 +117,45 @@ dependencies:
61
117
  segments:
62
118
  - 0
63
119
  version: "0"
120
+ prerelease: false
121
+ requirement: *id007
64
122
  type: :development
65
- version_requirements: *id003
123
+ name: SyslogLogger
124
+ - !ruby/object:Gem::Dependency
125
+ version_requirements: &id008 !ruby/object:Gem::Requirement
126
+ none: false
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ hash: 59
131
+ segments:
132
+ - 0
133
+ - 12
134
+ - 10
135
+ version: 0.12.10
136
+ prerelease: false
137
+ requirement: *id008
138
+ type: :runtime
139
+ name: eventmachine
140
+ - !ruby/object:Gem::Dependency
141
+ version_requirements: &id009 !ruby/object:Gem::Requirement
142
+ none: false
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ hash: 17
147
+ segments:
148
+ - 0
149
+ - 3
150
+ - 1
151
+ version: 0.3.1
152
+ prerelease: false
153
+ requirement: *id009
154
+ type: :runtime
155
+ name: safely
66
156
  description: 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.
67
- email: kenneth.kalmer@gmail.com
157
+ email:
158
+ - kenneth.kalmer@gmail.com
68
159
  executables:
69
160
  - daemon-kit
70
161
  extensions: []
@@ -82,6 +173,8 @@ files:
82
173
  - .gitignore
83
174
  - Configuration.txt
84
175
  - Deployment.txt
176
+ - Gemfile
177
+ - Gemfile.lock
85
178
  - History.txt
86
179
  - Logging.txt
87
180
  - PostInstall.txt
@@ -89,6 +182,7 @@ files:
89
182
  - Rakefile
90
183
  - RuoteParticipants.txt
91
184
  - TODO.txt
185
+ - Upgrading.md
92
186
  - bin/daemon-kit
93
187
  - config/website.yml
94
188
  - daemon-kit.gemspec
@@ -109,8 +203,6 @@ files:
109
203
  - lib/daemon_kit/deployment/capistrano.rb
110
204
  - lib/daemon_kit/dk_amqp.rb
111
205
  - lib/daemon_kit/em.rb
112
- - lib/daemon_kit/error_handlers/base.rb
113
- - lib/daemon_kit/error_handlers/hoptoad.rb
114
206
  - lib/daemon_kit/exceptions.rb
115
207
  - lib/daemon_kit/generators.rb
116
208
  - lib/daemon_kit/generators/base.rb
@@ -122,7 +214,6 @@ files:
122
214
  - lib/daemon_kit/ruote_participants.rb
123
215
  - lib/daemon_kit/ruote_pseudo_participant.rb
124
216
  - lib/daemon_kit/ruote_workitem.rb
125
- - lib/daemon_kit/safety.rb
126
217
  - lib/daemon_kit/tasks.rb
127
218
  - lib/daemon_kit/tasks/environment.rake
128
219
  - lib/daemon_kit/tasks/framework.rake
@@ -160,6 +251,7 @@ files:
160
251
  - lib/daemon_kit/vendor/thor-0.13.6/lib/thor/task.rb
161
252
  - lib/daemon_kit/vendor/thor-0.13.6/lib/thor/util.rb
162
253
  - lib/daemon_kit/vendor/thor-0.13.6/lib/thor/version.rb
254
+ - lib/daemon_kit/version.rb
163
255
  - lib/daemon_kit/xmpp.rb
164
256
  - lib/generators/daemon_kit/amqp/USAGE
165
257
  - lib/generators/daemon_kit/amqp/amqp_generator.rb
@@ -180,6 +272,7 @@ files:
180
272
  - lib/generators/daemon_kit/app/templates/config/environments/test.rb
181
273
  - lib/generators/daemon_kit/app/templates/config/post-daemonize/readme
182
274
  - lib/generators/daemon_kit/app/templates/config/pre-daemonize/readme
275
+ - lib/generators/daemon_kit/app/templates/config/pre-daemonize/safely.rb
183
276
  - lib/generators/daemon_kit/app/templates/lib/%app_name%.rb
184
277
  - lib/generators/daemon_kit/app/templates/libexec/%app_name%-daemon.rb
185
278
  - lib/generators/daemon_kit/app/templates/script/console
@@ -242,7 +335,6 @@ files:
242
335
  - spec/config_spec.rb
243
336
  - spec/configurable_spec.rb
244
337
  - spec/daemon_kit_spec.rb
245
- - spec/error_handlers_spec.rb
246
338
  - spec/fixtures/env.yml
247
339
  - spec/fixtures/noenv.yml
248
340
  - spec/initializer_spec.rb
@@ -263,7 +355,6 @@ files:
263
355
  - test/test_nanite_agent_generator.rb
264
356
  - test/test_ruote_generator.rb
265
357
  - test/test_test_unit_generator.rb
266
- has_rdoc: true
267
358
  homepage: http://github.com/kennethkalmer/daemon-kit
268
359
  licenses: []
269
360
 
@@ -274,8 +365,8 @@ post_install_message: |+
274
365
  To get started quickly run 'daemon-kit' without any arguments
275
366
 
276
367
 
277
- rdoc_options:
278
- - --charset=UTF-8
368
+ rdoc_options: []
369
+
279
370
  require_paths:
280
371
  - lib
281
372
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -299,26 +390,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
299
390
  requirements: []
300
391
 
301
392
  rubyforge_project:
302
- rubygems_version: 1.3.7
393
+ rubygems_version: 1.8.11
303
394
  signing_key:
304
395
  specification_version: 3
305
396
  summary: Opinionated framework for Ruby daemons
306
- test_files:
307
- - spec/abstract_logger_spec.rb
308
- - spec/argument_spec.rb
309
- - spec/config_spec.rb
310
- - spec/configurable_spec.rb
311
- - spec/daemon_kit_spec.rb
312
- - spec/error_handlers_spec.rb
313
- - spec/initializer_spec.rb
314
- - spec/spec_helper.rb
315
- - test/test_amqp_generator.rb
316
- - test/test_cron_generator.rb
317
- - test/test_daemon-kit_generator.rb
318
- - test/test_daemon_kit_config.rb
319
- - test/test_deploy_capistrano_generator.rb
320
- - test/test_generator_helper.rb
321
- - test/test_helper.rb
322
- - test/test_nanite_agent_generator.rb
323
- - test/test_ruote_generator.rb
324
- - test/test_test_unit_generator.rb
397
+ test_files: []
398
+
@@ -1,32 +0,0 @@
1
- module DaemonKit
2
- module ErrorHandlers
3
- # Error handlers in DaemonKit are used by the #Safety class. Any
4
- # error handler has to support the interface provided by this
5
- # class. It's also required that safety handlers implement a
6
- # singleton approach (handled by default by #Base).
7
- class Base
8
-
9
- class << self
10
-
11
- @instance = nil
12
-
13
- def instance
14
- @instance ||= new
15
- end
16
- private :new
17
-
18
- # When we're inherited, immediately register the handler with
19
- # the safety net
20
- def inherited( child ) #:nodoc:
21
- Safety.register_error_handler( child )
22
- end
23
- end
24
-
25
- # Error handlers should overwrite this method and implement
26
- # their own reporting method.
27
- def handle_exception( exception )
28
- raise NoMethodError, "Error handler doesn't support #handle_exception"
29
- end
30
- end
31
- end
32
- end
@@ -1,180 +0,0 @@
1
- require 'net/http'
2
-
3
- module DaemonKit
4
- module ErrorHandlers
5
- # Error reporting via Hoptoad.
6
- class Hoptoad < Base
7
-
8
- # Front end to parsing the backtrace for each notice
9
- # (Graciously borrowed from http://github.com/thoughtbot/hoptoad_notifier)
10
- class Backtrace
11
-
12
- # Handles backtrace parsing line by line
13
- # (Graciously borrowed from http://github.com/thoughtbot/hoptoad_notifier)
14
- class Line
15
-
16
- INPUT_FORMAT = %r{^([^:]+):(\d+)(?::in `([^']+)')?$}.freeze
17
-
18
- # The file portion of the line (such as app/models/user.rb)
19
- attr_reader :file
20
-
21
- # The line number portion of the line
22
- attr_reader :number
23
-
24
- # The method of the line (such as index)
25
- attr_reader :method
26
-
27
- # Parses a single line of a given backtrace
28
- # @param [String] unparsed_line The raw line from +caller+ or some backtrace
29
- # @return [Line] The parsed backtrace line
30
- def self.parse(unparsed_line)
31
- _, file, number, method = unparsed_line.match(INPUT_FORMAT).to_a
32
- new(file, number, method)
33
- end
34
-
35
- def initialize(file, number, method)
36
- self.file = file
37
- self.number = number
38
- self.method = method
39
- end
40
-
41
- # Reconstructs the line in a readable fashion
42
- def to_s
43
- "#{file}:#{number}:in `#{method}'"
44
- end
45
-
46
- def ==(other)
47
- to_s == other.to_s
48
- end
49
-
50
- def inspect
51
- "<Line:#{to_s}>"
52
- end
53
-
54
- def to_xml
55
- data = [ method, file, number ].map { |s| URI.escape( s || 'unknown', %q{"'<>&} ) }
56
- %q{<line method="%s" file="%s" number="%s" />} % data
57
- end
58
-
59
- private
60
-
61
- attr_writer :file, :number, :method
62
- end
63
-
64
- # holder for an Array of Backtrace::Line instances
65
- attr_reader :lines
66
-
67
- def self.parse(ruby_backtrace, opts = {})
68
- ruby_lines = split_multiline_backtrace(ruby_backtrace)
69
-
70
- filters = opts[:filters] || []
71
- filtered_lines = ruby_lines.to_a.map do |line|
72
- filters.inject(line) do |line, proc|
73
- proc.call(line)
74
- end
75
- end.compact
76
-
77
- lines = filtered_lines.collect do |unparsed_line|
78
- Line.parse(unparsed_line)
79
- end
80
-
81
- instance = new(lines)
82
- end
83
-
84
- def initialize(lines)
85
- self.lines = lines
86
- end
87
-
88
- def inspect
89
- "<Backtrace: " + lines.collect { |line| line.inspect }.join(", ") + ">"
90
- end
91
-
92
- def ==(other)
93
- if other.respond_to?(:lines)
94
- lines == other.lines
95
- else
96
- false
97
- end
98
- end
99
-
100
- private
101
-
102
- attr_writer :lines
103
-
104
- def self.split_multiline_backtrace(backtrace)
105
- if backtrace.to_a.size == 1
106
- backtrace.to_a.first.split(/\n\s*/)
107
- else
108
- backtrace
109
- end
110
- end
111
- end
112
-
113
- # Your hoptoad API key
114
- @api_key = nil
115
- attr_accessor :api_key
116
-
117
- def handle_exception( exception )
118
- headers = {
119
- 'Content-type' => 'text/xml',
120
- 'Accept' => 'text/xml, application/xml'
121
- }
122
-
123
- http = Net::HTTP.new( url.host, url.port )
124
- data = format_exception( exception )
125
- DaemonKit.logger.debug("Sending to Hoptoad: #{data}")
126
-
127
- response = begin
128
- http.post( url.path, data, headers )
129
- rescue TimeoutError => e
130
- DaemonKit.logger.error("Timeout while contacting the Hoptoad server.")
131
- nil
132
- end
133
- case response
134
- when Net::HTTPSuccess then
135
- DaemonKit.logger.info "Hoptoad Success: #{response.class}"
136
- else
137
- DaemonKit.logger.error "Hoptoad Failure: #{response.class}\n#{response.body if response.respond_to? :body}"
138
- end
139
- end
140
-
141
- def url
142
- URI.parse("http://hoptoadapp.com/notifier_api/v2/notices")
143
- end
144
-
145
- def format_exception( exception )
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;")
153
-
154
- <<-EOF
155
- <?xml version="1.0" encoding="UTF-8"?>
156
- <notice version="2.0">
157
- <api-key>#{self.api_key}</api-key>
158
- <notifier>
159
- <name>daemon-kit</name>
160
- <version>#{DaemonKit::VERSION}</version>
161
- <url>http://github.com/kennethkalmer/daemon-kit</url>
162
- </notifier>
163
- <error>
164
- <class>#{exception.class.name}</class>
165
- <message>#{exception_message}</message>
166
- <backtrace>
167
- #{Backtrace.parse( exception.backtrace ).lines.inject('') { |string,line| string << line.to_xml }}
168
- </backtrace>
169
- </error>
170
- <server-environment>
171
- <project-root>#{DaemonKit.root}</project-root>
172
- <environment-name>#{DaemonKit.env}</environment-name>
173
- </server-environment>
174
- </notice>
175
- EOF
176
- end
177
- end
178
-
179
- end
180
- end