daemon-kit 0.1.8rc1 → 0.1.8rc2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/History.txt +4 -0
  2. data/Rakefile +1 -1
  3. data/daemon-kit.gemspec +6 -37
  4. data/lib/daemon_kit.rb +1 -1
  5. data/lib/daemon_kit/error_handlers/base.rb +3 -3
  6. data/lib/daemon_kit/error_handlers/hoptoad.rb +135 -22
  7. data/lib/daemon_kit/safety.rb +0 -1
  8. data/lib/generators/daemon_kit/app/templates/config/boot.rb +7 -3
  9. data/lib/generators/daemon_kit/app/templates/config/environment.rb.tt +5 -2
  10. metadata +3 -34
  11. data/Manifest.txt +0 -176
  12. data/lib/daemon_kit/error_handlers/mail.rb +0 -85
  13. data/vendor/tmail-1.2.3/tmail.rb +0 -5
  14. data/vendor/tmail-1.2.3/tmail/address.rb +0 -426
  15. data/vendor/tmail-1.2.3/tmail/attachments.rb +0 -46
  16. data/vendor/tmail-1.2.3/tmail/base64.rb +0 -46
  17. data/vendor/tmail-1.2.3/tmail/compat.rb +0 -41
  18. data/vendor/tmail-1.2.3/tmail/config.rb +0 -67
  19. data/vendor/tmail-1.2.3/tmail/core_extensions.rb +0 -63
  20. data/vendor/tmail-1.2.3/tmail/encode.rb +0 -581
  21. data/vendor/tmail-1.2.3/tmail/header.rb +0 -960
  22. data/vendor/tmail-1.2.3/tmail/index.rb +0 -9
  23. data/vendor/tmail-1.2.3/tmail/interface.rb +0 -1130
  24. data/vendor/tmail-1.2.3/tmail/loader.rb +0 -3
  25. data/vendor/tmail-1.2.3/tmail/mail.rb +0 -578
  26. data/vendor/tmail-1.2.3/tmail/mailbox.rb +0 -495
  27. data/vendor/tmail-1.2.3/tmail/main.rb +0 -6
  28. data/vendor/tmail-1.2.3/tmail/mbox.rb +0 -3
  29. data/vendor/tmail-1.2.3/tmail/net.rb +0 -248
  30. data/vendor/tmail-1.2.3/tmail/obsolete.rb +0 -132
  31. data/vendor/tmail-1.2.3/tmail/parser.rb +0 -1476
  32. data/vendor/tmail-1.2.3/tmail/port.rb +0 -379
  33. data/vendor/tmail-1.2.3/tmail/quoting.rb +0 -118
  34. data/vendor/tmail-1.2.3/tmail/require_arch.rb +0 -58
  35. data/vendor/tmail-1.2.3/tmail/scanner.rb +0 -49
  36. data/vendor/tmail-1.2.3/tmail/scanner_r.rb +0 -261
  37. data/vendor/tmail-1.2.3/tmail/stringio.rb +0 -280
  38. data/vendor/tmail-1.2.3/tmail/utils.rb +0 -337
  39. data/vendor/tmail-1.2.3/tmail/version.rb +0 -39
  40. data/vendor/tmail.rb +0 -13
data/History.txt CHANGED
@@ -4,6 +4,10 @@
4
4
  * Evented XMPP now handled by blather
5
5
  * Boot script fixes
6
6
  * Removed Jabber generator, deprecating Jabber class (use XMPP)
7
+ * Upgraded Hoptoad notifications to V2 of the notifier API
8
+ * Fix various argument handling bugs
9
+ * Removed support for exception emails
10
+ * Improved log rotation support [mperham]
7
11
 
8
12
  == 0.1.7.12 2009-12-04
9
13
 
data/Rakefile CHANGED
@@ -15,7 +15,7 @@ begin
15
15
  gemspec.post_install_message = IO.read('PostInstall.txt')
16
16
  gemspec.extra_rdoc_files.include '*.txt'
17
17
 
18
- gemspec.add_dependency 'eventmachine', '>=0.12.8'
18
+ gemspec.add_dependency 'eventmachine', '>=0.12.10'
19
19
  gemspec.add_development_dependency 'rspec'
20
20
  gemspec.add_development_dependency 'cucumber'
21
21
  end
data/daemon-kit.gemspec CHANGED
@@ -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.8rc1"
8
+ s.version = "0.1.8rc2"
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-13}
12
+ s.date = %q{2010-04-14}
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}
@@ -19,7 +19,6 @@ Gem::Specification.new do |s|
19
19
  "Deployment.txt",
20
20
  "History.txt",
21
21
  "Logging.txt",
22
- "Manifest.txt",
23
22
  "PostInstall.txt",
24
23
  "README.rdoc",
25
24
  "RuoteParticipants.txt",
@@ -31,7 +30,6 @@ Gem::Specification.new do |s|
31
30
  "Deployment.txt",
32
31
  "History.txt",
33
32
  "Logging.txt",
34
- "Manifest.txt",
35
33
  "PostInstall.txt",
36
34
  "README.rdoc",
37
35
  "Rakefile",
@@ -59,7 +57,6 @@ Gem::Specification.new do |s|
59
57
  "lib/daemon_kit/em.rb",
60
58
  "lib/daemon_kit/error_handlers/base.rb",
61
59
  "lib/daemon_kit/error_handlers/hoptoad.rb",
62
- "lib/daemon_kit/error_handlers/mail.rb",
63
60
  "lib/daemon_kit/exceptions.rb",
64
61
  "lib/daemon_kit/generators.rb",
65
62
  "lib/daemon_kit/generators/base.rb",
@@ -211,35 +208,7 @@ Gem::Specification.new do |s|
211
208
  "test/test_helper.rb",
212
209
  "test/test_nanite_agent_generator.rb",
213
210
  "test/test_ruote_generator.rb",
214
- "test/test_test_unit_generator.rb",
215
- "vendor/tmail-1.2.3/tmail.rb",
216
- "vendor/tmail-1.2.3/tmail/address.rb",
217
- "vendor/tmail-1.2.3/tmail/attachments.rb",
218
- "vendor/tmail-1.2.3/tmail/base64.rb",
219
- "vendor/tmail-1.2.3/tmail/compat.rb",
220
- "vendor/tmail-1.2.3/tmail/config.rb",
221
- "vendor/tmail-1.2.3/tmail/core_extensions.rb",
222
- "vendor/tmail-1.2.3/tmail/encode.rb",
223
- "vendor/tmail-1.2.3/tmail/header.rb",
224
- "vendor/tmail-1.2.3/tmail/index.rb",
225
- "vendor/tmail-1.2.3/tmail/interface.rb",
226
- "vendor/tmail-1.2.3/tmail/loader.rb",
227
- "vendor/tmail-1.2.3/tmail/mail.rb",
228
- "vendor/tmail-1.2.3/tmail/mailbox.rb",
229
- "vendor/tmail-1.2.3/tmail/main.rb",
230
- "vendor/tmail-1.2.3/tmail/mbox.rb",
231
- "vendor/tmail-1.2.3/tmail/net.rb",
232
- "vendor/tmail-1.2.3/tmail/obsolete.rb",
233
- "vendor/tmail-1.2.3/tmail/parser.rb",
234
- "vendor/tmail-1.2.3/tmail/port.rb",
235
- "vendor/tmail-1.2.3/tmail/quoting.rb",
236
- "vendor/tmail-1.2.3/tmail/require_arch.rb",
237
- "vendor/tmail-1.2.3/tmail/scanner.rb",
238
- "vendor/tmail-1.2.3/tmail/scanner_r.rb",
239
- "vendor/tmail-1.2.3/tmail/stringio.rb",
240
- "vendor/tmail-1.2.3/tmail/utils.rb",
241
- "vendor/tmail-1.2.3/tmail/version.rb",
242
- "vendor/tmail.rb"
211
+ "test/test_test_unit_generator.rb"
243
212
  ]
244
213
  s.homepage = %q{http://github.com/kennethkalmer/daemon-kit}
245
214
  s.post_install_message = %q{
@@ -279,16 +248,16 @@ To get started quickly run 'daemon-kit' without any arguments
279
248
  s.specification_version = 3
280
249
 
281
250
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
282
- s.add_runtime_dependency(%q<eventmachine>, [">= 0.12.8"])
251
+ s.add_runtime_dependency(%q<eventmachine>, [">= 0.12.10"])
283
252
  s.add_development_dependency(%q<rspec>, [">= 0"])
284
253
  s.add_development_dependency(%q<cucumber>, [">= 0"])
285
254
  else
286
- s.add_dependency(%q<eventmachine>, [">= 0.12.8"])
255
+ s.add_dependency(%q<eventmachine>, [">= 0.12.10"])
287
256
  s.add_dependency(%q<rspec>, [">= 0"])
288
257
  s.add_dependency(%q<cucumber>, [">= 0"])
289
258
  end
290
259
  else
291
- s.add_dependency(%q<eventmachine>, [">= 0.12.8"])
260
+ s.add_dependency(%q<eventmachine>, [">= 0.12.10"])
292
261
  s.add_dependency(%q<rspec>, [">= 0"])
293
262
  s.add_dependency(%q<cucumber>, [">= 0"])
294
263
  end
data/lib/daemon_kit.rb CHANGED
@@ -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.8rc1'
16
+ VERSION = '0.1.8rc2'
17
17
 
18
18
  autoload :Initializer, 'daemon_kit/initializer'
19
19
  autoload :Application, 'daemon_kit/application'
@@ -7,21 +7,21 @@ module DaemonKit
7
7
  class Base
8
8
 
9
9
  class << self
10
-
10
+
11
11
  @instance = nil
12
12
 
13
13
  def instance
14
14
  @instance ||= new
15
15
  end
16
16
  private :new
17
-
17
+
18
18
  # When we're inherited, immediately register the handler with
19
19
  # the safety net
20
20
  def inherited( child ) #:nodoc:
21
21
  Safety.register_error_handler( child )
22
22
  end
23
23
  end
24
-
24
+
25
25
  # Error handlers should overwrite this method and implement
26
26
  # their own reporting method.
27
27
  def handle_exception( exception )
@@ -5,21 +5,127 @@ module DaemonKit
5
5
  # Error reporting via Hoptoad.
6
6
  class Hoptoad < Base
7
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, %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
+
8
113
  # Your hoptoad API key
9
114
  @api_key = nil
10
115
  attr_accessor :api_key
11
116
 
12
117
  def handle_exception( exception )
13
118
  headers = {
14
- 'Content-type' => 'application/x-yaml',
119
+ 'Content-type' => 'text/xml',
15
120
  'Accept' => 'text/xml, application/xml'
16
121
  }
17
122
 
18
123
  http = Net::HTTP.new( url.host, url.port )
19
- data = clean_exception( exception )
124
+ data = format_exception( exception )
125
+ DaemonKit.logger.debug("Sending to Hoptoad: #{data}")
20
126
 
21
127
  response = begin
22
- http.post( url.path, {"notice" => data}.to_yaml, headers )
128
+ http.post( url.path, data, headers )
23
129
  rescue TimeoutError => e
24
130
  DaemonKit.logger.error("Timeout while contacting the Hoptoad server.")
25
131
  nil
@@ -33,29 +139,36 @@ module DaemonKit
33
139
  end
34
140
 
35
141
  def url
36
- URI.parse("http://hoptoadapp.com/notices/")
142
+ URI.parse("http://hoptoadapp.com/notifier_api/v2/notices")
37
143
  end
38
144
 
39
- def clean_exception( exception )
40
- data = {
41
- :api_key => self.api_key,
42
- :error_class => exception.class.name,
43
- :error_message => "#{exception.class.name}: #{exception.message}",
44
- :backtrace => exception.backtrace,
45
- :environment => ENV.to_hash,
46
- :request => {},
47
- :session => {}
48
- }
145
+ def format_exception( exception )
146
+ lines = Backtrace.parse( exception.backtrace )
49
147
 
50
- stringify_keys( data )
51
- end
52
-
53
- def stringify_keys(hash) #:nodoc:
54
- hash.inject({}) do |h, pair|
55
- h[pair.first.to_s] = pair.last.is_a?(Hash) ? stringify_keys(pair.last) : pair.last
56
- h
57
- end
148
+ <<-EOF
149
+ <?xml version="1.0" encoding="UTF-8"?>
150
+ <notice version="2.0">
151
+ <api-key>#{self.api_key}</api-key>
152
+ <notifier>
153
+ <name>daemon-kit</name>
154
+ <version>#{DaemonKit::VERSION}</version>
155
+ <url>http://github.com/kennethkalmer/daemon-kit</url>
156
+ </notifier>
157
+ <error>
158
+ <class>#{exception.class.name}</class>
159
+ <message>#{exception.message}</message>
160
+ <backtrace>
161
+ #{Backtrace.parse( exception.backtrace ).lines.inject('') { |string,line| string << line.to_xml }}
162
+ </backtrace>
163
+ </error>
164
+ <server-environment>
165
+ <project-root>#{DaemonKit.root}</project-root>
166
+ <environment-name>#{DaemonKit.env}</environment-name>
167
+ </server-environment>
168
+ </notice>
169
+ EOF
58
170
  end
59
171
  end
172
+
60
173
  end
61
174
  end
@@ -81,5 +81,4 @@ end
81
81
 
82
82
  # Load our error handlers
83
83
  require 'daemon_kit/error_handlers/base'
84
- require 'daemon_kit/error_handlers/mail'
85
84
  require 'daemon_kit/error_handlers/hoptoad'
@@ -3,9 +3,13 @@
3
3
 
4
4
  DAEMON_ROOT = "#{File.expand_path(File.dirname(__FILE__))}/.." unless defined?( DAEMON_ROOT )
5
5
 
6
- # Use bundler if available
7
- if File.exists?( File.join( DAEMON_ROOT, 'vendor', 'gems', 'environment.rb' ) )
8
- require File.join( DAEMON_ROOT, 'vendor', 'gems', 'environment' )
6
+ # Use Bundler (preferred)
7
+ begin
8
+ require File.expand_path('../../.bundle/environment', __FILE__)
9
+ rescue LoadError
10
+ require 'rubygems'
11
+ require 'bundler'
12
+ Bundler.setup
9
13
  end
10
14
 
11
15
  module DaemonKit
@@ -6,6 +6,9 @@
6
6
  # Boot up
7
7
  require File.join(File.dirname(__FILE__), 'boot')
8
8
 
9
+ # Auto-require default libraries and those for the current Rails environment.
10
+ Bundler.require :default, DaemonKit.env
11
+
9
12
  DaemonKit::Initializer.run do |config|
10
13
 
11
14
  # The name of the daemon as reported by process monitoring tools
@@ -18,6 +21,6 @@ DaemonKit::Initializer.run do |config|
18
21
  # config.backtraces = true
19
22
 
20
23
  # Configure the safety net (see DaemonKit::Safety)
21
- # config.safety_net.handler = :mail # (or :hoptoad )
22
- # config.safety_net.mail.host = 'localhost'
24
+ # config.safety_net.handler = :hoptoad
25
+ # config.safety_net.hoptoad.api_key = ''
23
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daemon-kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8rc1
4
+ version: 0.1.8rc2
5
5
  platform: ruby
6
6
  authors:
7
7
  - kenneth.kalmer@gmail.com
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-04-13 00:00:00 +02:00
12
+ date: 2010-04-14 00:00:00 +02:00
13
13
  default_executable: daemon-kit
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 0.12.8
23
+ version: 0.12.10
24
24
  version:
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
@@ -53,7 +53,6 @@ extra_rdoc_files:
53
53
  - Deployment.txt
54
54
  - History.txt
55
55
  - Logging.txt
56
- - Manifest.txt
57
56
  - PostInstall.txt
58
57
  - README.rdoc
59
58
  - RuoteParticipants.txt
@@ -64,7 +63,6 @@ files:
64
63
  - Deployment.txt
65
64
  - History.txt
66
65
  - Logging.txt
67
- - Manifest.txt
68
66
  - PostInstall.txt
69
67
  - README.rdoc
70
68
  - Rakefile
@@ -92,7 +90,6 @@ files:
92
90
  - lib/daemon_kit/em.rb
93
91
  - lib/daemon_kit/error_handlers/base.rb
94
92
  - lib/daemon_kit/error_handlers/hoptoad.rb
95
- - lib/daemon_kit/error_handlers/mail.rb
96
93
  - lib/daemon_kit/exceptions.rb
97
94
  - lib/daemon_kit/generators.rb
98
95
  - lib/daemon_kit/generators/base.rb
@@ -245,34 +242,6 @@ files:
245
242
  - test/test_nanite_agent_generator.rb
246
243
  - test/test_ruote_generator.rb
247
244
  - test/test_test_unit_generator.rb
248
- - vendor/tmail-1.2.3/tmail.rb
249
- - vendor/tmail-1.2.3/tmail/address.rb
250
- - vendor/tmail-1.2.3/tmail/attachments.rb
251
- - vendor/tmail-1.2.3/tmail/base64.rb
252
- - vendor/tmail-1.2.3/tmail/compat.rb
253
- - vendor/tmail-1.2.3/tmail/config.rb
254
- - vendor/tmail-1.2.3/tmail/core_extensions.rb
255
- - vendor/tmail-1.2.3/tmail/encode.rb
256
- - vendor/tmail-1.2.3/tmail/header.rb
257
- - vendor/tmail-1.2.3/tmail/index.rb
258
- - vendor/tmail-1.2.3/tmail/interface.rb
259
- - vendor/tmail-1.2.3/tmail/loader.rb
260
- - vendor/tmail-1.2.3/tmail/mail.rb
261
- - vendor/tmail-1.2.3/tmail/mailbox.rb
262
- - vendor/tmail-1.2.3/tmail/main.rb
263
- - vendor/tmail-1.2.3/tmail/mbox.rb
264
- - vendor/tmail-1.2.3/tmail/net.rb
265
- - vendor/tmail-1.2.3/tmail/obsolete.rb
266
- - vendor/tmail-1.2.3/tmail/parser.rb
267
- - vendor/tmail-1.2.3/tmail/port.rb
268
- - vendor/tmail-1.2.3/tmail/quoting.rb
269
- - vendor/tmail-1.2.3/tmail/require_arch.rb
270
- - vendor/tmail-1.2.3/tmail/scanner.rb
271
- - vendor/tmail-1.2.3/tmail/scanner_r.rb
272
- - vendor/tmail-1.2.3/tmail/stringio.rb
273
- - vendor/tmail-1.2.3/tmail/utils.rb
274
- - vendor/tmail-1.2.3/tmail/version.rb
275
- - vendor/tmail.rb
276
245
  has_rdoc: true
277
246
  homepage: http://github.com/kennethkalmer/daemon-kit
278
247
  licenses: []