hockeybrake 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b4d5daa3c3f6ae1971e40f2b91ae4aa0303de410
4
+ data.tar.gz: 102820519f0775ea5a1fa34ed2eb45988e869e57
5
+ SHA512:
6
+ metadata.gz: 1231e4ab3a10bbc75051b0c13daf8c132c660cd11f12c5017839b108bdaef9771f5abfe6252b2ea0c27547e1ab3057006596446162bfbd4f183ca65bf3b597e2
7
+ data.tar.gz: b7cc2795b5fd985076f4d20283dd49fd5fa9170034a52a27fb3c239ceb6185b13547df137ce44ee5268c199f2759c5345124f1cd1407a398435bdb6983f9a35f
data/.gitignore CHANGED
@@ -10,3 +10,4 @@ ehthumbs.db
10
10
  Thumbs.db
11
11
  .gem
12
12
  .idea/
13
+ Gemfile.lock
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
5
+
6
+ gemfile:
7
+ - gemfiles/airbrake-3.1.2
8
+ - gemfiles/airbrake-3.1.3
9
+ - gemfiles/airbrake-3.1.4
10
+ - gemfiles/airbrake-3.1.5
11
+ - gemfiles/airbrake-3.1.6
12
+ - gemfiles/airbrake-3.1.16
data/Gemfile CHANGED
@@ -1,5 +1,18 @@
1
1
  source "http://rubygems.org"
2
2
 
3
+ gem 'rake'
4
+ gem 'rspec'
5
+ gem 'shoulda'
6
+ gem 'rails'
7
+
8
+ gem 'airbrake'
9
+
10
+ group :test do
11
+ gem "guard-rspec"
12
+ gem "terminal-notifier-guard"
13
+ end
14
+
3
15
  # Specify your gem's dependencies in hockeybrake.gemspec
4
16
  gemspec
5
17
 
18
+
data/Guardfile ADDED
@@ -0,0 +1,24 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec' do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+
9
+ # Rails example
10
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11
+ watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
12
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
13
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
14
+ watch('config/routes.rb') { "spec/routing" }
15
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
16
+
17
+ # Capybara request specs
18
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
19
+
20
+ # Turnip features and steps
21
+ watch(%r{^spec/acceptance/(.+)\.feature$})
22
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
23
+ end
24
+
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  An extension for the amazing airbrake gem which routes crash reports to HockeyApp
4
4
 
5
+ [![Build Status](https://secure.travis-ci.org/dei79/hockeybrake.png)](http://travis-ci.org/dei79/hockeybrake)
6
+
5
7
  ## Installation
6
8
 
7
9
  Add this to your Gemfile
@@ -44,6 +46,7 @@ Resque comes with out of the box support for Airbrake. This gem is compatible wi
44
46
 
45
47
  * Fork the project
46
48
  * Fix the issue
49
+ * Add specs
47
50
  * Create pull request on github
48
51
 
49
52
  ## More Information
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require "rake"
2
+ require "bundler/gem_tasks"
3
+ require "rspec/core/rake_task"
4
+ Dir["lib/tasks/*.rake"].each { |rake| load rake }
5
+
6
+ RSpec::Core::RakeTask.new(:spec) do |spec|
7
+ spec.pattern = 'spec/**/*_spec.rb'
8
+ spec.rspec_opts = ['--backtrace']
9
+ end
10
+
11
+ task :default => 'spec'
@@ -0,0 +1,18 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'rake'
4
+ gem 'rspec'
5
+ gem 'shoulda'
6
+ gem 'rails'
7
+
8
+ gem 'airbrake', '=3.1.16'
9
+
10
+ group :test do
11
+ gem "guard-rspec"
12
+ gem "terminal-notifier-guard"
13
+ end
14
+
15
+ # Specify your gem's dependencies in hockeybrake.gemspec
16
+ gemspec :path => '../'
17
+
18
+
@@ -0,0 +1,18 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'rake'
4
+ gem 'rspec'
5
+ gem 'shoulda'
6
+ gem 'rails'
7
+
8
+ gem 'airbrake', '=3.1.2'
9
+
10
+ group :test do
11
+ gem "guard-rspec"
12
+ gem "terminal-notifier-guard"
13
+ end
14
+
15
+ # Specify your gem's dependencies in hockeybrake.gemspec
16
+ gemspec :path => '../'
17
+
18
+
@@ -0,0 +1,18 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'rake'
4
+ gem 'rspec'
5
+ gem 'shoulda'
6
+ gem 'rails'
7
+
8
+ gem 'airbrake', '=3.1.3'
9
+
10
+ group :test do
11
+ gem "guard-rspec"
12
+ gem "terminal-notifier-guard"
13
+ end
14
+
15
+ # Specify your gem's dependencies in hockeybrake.gemspec
16
+ gemspec :path => '../'
17
+
18
+
@@ -0,0 +1,18 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'rake'
4
+ gem 'rspec'
5
+ gem 'shoulda'
6
+ gem 'rails'
7
+
8
+ gem 'airbrake', '=3.1.4'
9
+
10
+ group :test do
11
+ gem "guard-rspec"
12
+ gem "terminal-notifier-guard"
13
+ end
14
+
15
+ # Specify your gem's dependencies in hockeybrake.gemspec
16
+ gemspec :path => '../'
17
+
18
+
@@ -0,0 +1,18 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'rake'
4
+ gem 'rspec'
5
+ gem 'shoulda'
6
+ gem 'rails'
7
+
8
+ gem 'airbrake', '=3.1.5'
9
+
10
+ group :test do
11
+ gem "guard-rspec"
12
+ gem "terminal-notifier-guard"
13
+ end
14
+
15
+ # Specify your gem's dependencies in hockeybrake.gemspec
16
+ gemspec :path => '../'
17
+
18
+
@@ -0,0 +1,18 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem 'rake'
4
+ gem 'rspec'
5
+ gem 'shoulda'
6
+ gem 'rails'
7
+
8
+ gem 'airbrake', '=3.1.6'
9
+
10
+ group :test do
11
+ gem "guard-rspec"
12
+ gem "terminal-notifier-guard"
13
+ end
14
+
15
+ # Specify your gem's dependencies in hockeybrake.gemspec
16
+ gemspec :path => '../'
17
+
18
+
data/hockeybrake.gemspec CHANGED
@@ -18,4 +18,5 @@ Gem::Specification.new do |s|
18
18
 
19
19
  s.add_runtime_dependency(%q<airbrake>, [">= 3.1.2"])
20
20
  s.add_runtime_dependency(%q<multipart-post>, [">= 1.1.5"])
21
+ s.add_runtime_dependency(%q<activesupport>)
21
22
  end
@@ -1,3 +1,5 @@
1
+ require 'active_support/core_ext'
2
+
1
3
  #
2
4
  # This class converts the given Airbrake XML data to the log format of the HockeyApp server
3
5
  #
@@ -6,45 +8,55 @@ module HockeyBrake
6
8
 
7
9
  #
8
10
  # Generates a string which can be sent to the hockey service
9
- #
10
- def self.generate(data)
11
- # the output
12
- output = ""
13
-
14
- # generate our time string
15
- dtstr = Time.now.strftime("%a %b %d %H:%M:%S %Z %Y")
16
-
17
- # write the header so that we have something to send
18
- output += "Package: #{HockeyBrake.configuration.app_bundle_id}\n"
19
- output += "Version: #{HockeyBrake.configuration.app_version}\n"
20
- output += "Date: #{dtstr}\n"
21
-
22
- # add the optional values if possible
11
+ def self.generate_safe(data)
23
12
  begin
24
- output += "Android: #{RUBY_PLATFORM}\n"
25
- output += "Model: Ruby #{RUBY_VERSION} Rails #{Rails.version}\n"
26
- rescue
27
- # nothing to do
13
+ output = HockeyLog.generate(data)
14
+ rescue HockeyBrake::HockeyLogException => e
15
+ output += e.message
28
16
  end
29
17
 
30
- # add the empty line
31
- output += "\n"
18
+ # go ahead
19
+ output
20
+ end
32
21
 
33
- # parse the XML and convert them to the HockeyApp format
22
+ #
23
+ # Generates a string which can be sent to the hockey service
24
+ def self.generate(data)
34
25
  begin
26
+ # the output
27
+ output = ""
28
+
29
+ # generate our time string
30
+ dtstr = Time.now.strftime("%a %b %d %H:%M:%S %Z %Y")
31
+
32
+ # write the header so that we have something to send
33
+ output += "Package: #{HockeyBrake.configuration.app_bundle_id}\n"
34
+ output += "Version: #{HockeyBrake.configuration.app_version}\n"
35
+ output += "Date: #{dtstr}\n"
36
+
37
+ # add the optional values if possible
38
+ begin
39
+ output += "Android: #{RUBY_PLATFORM}\n"
40
+ output += "Model: Ruby #{RUBY_VERSION} Rails #{Rails.version}\n"
41
+ rescue
42
+ # nothing to do
43
+ end
44
+
45
+ # add the empty line
46
+ output += "\n"
47
+
48
+ # parse the XML and convert them to the HockeyApp format
35
49
  if ( data.is_a?(String))
36
50
  output += generate_from_xml(data)
37
51
  else
38
52
  output += generate_from_notice(data)
39
53
  end
54
+
55
+ # return the output
56
+ output
40
57
  rescue Exception => e
41
- # nothing to do
42
- output += "An exception was thrown during handling of the exception from the HockeyBrake injector\n"
43
- output += "Exception: #{e.message}"
58
+ raise HockeyLogException.new(e)
44
59
  end
45
-
46
- # return the output
47
- output
48
60
  end
49
61
 
50
62
  def self.generate_from_notice(data)
@@ -56,7 +68,12 @@ module HockeyBrake
56
68
  # generate the call stacke
57
69
  data.backtrace.lines.each do |line|
58
70
  class_name = File.basename(line.file, ".rb").classify
59
- output += " at #{class_name}##{line.method}(#{line.file}:#{line.number})\n"
71
+
72
+ begin
73
+ output += " at #{class_name}##{line.method}(#{line.file}:#{line.number})\n"
74
+ rescue
75
+ output += " at #{class_name}##{line.method_name}(#{line.file}:#{line.number})\n"
76
+ end
60
77
  end
61
78
 
62
79
  # emit
@@ -0,0 +1,14 @@
1
+ module HockeyBrake
2
+ class HockeyLogException < Exception
3
+ attr_accessor(:innerexception)
4
+
5
+ def initialize(exception)
6
+ @innerexception = exception
7
+ end
8
+
9
+ def message()
10
+ "An exception was thrown during handling of the exception from the HockeyBrake injector\n" +
11
+ "Exception: #{@innerexception.message}"
12
+ end
13
+ end
14
+ end
@@ -17,7 +17,7 @@ module HockeyBrake
17
17
  def send_to_airbrake(data)
18
18
 
19
19
  # generate the log
20
- logstr = HockeyLog.generate(data)
20
+ logstr = HockeyLog.generate_safe(data)
21
21
 
22
22
  # generate the stirng io
23
23
  logio = StringIO.new(logstr)
@@ -28,7 +28,7 @@ module HockeyBrake
28
28
  # send the request
29
29
  response = begin
30
30
 
31
- # build the request
31
+ # build the request
32
32
  req = Net::HTTP::Post::Multipart.new( url.path, "log" => UploadIO.new(logio, 'application/octet-stream', "log.txt") )
33
33
 
34
34
  # start the upload
@@ -37,15 +37,15 @@ module HockeyBrake
37
37
  end
38
38
 
39
39
  rescue *HTTP_ERRORS => e
40
- log :error, "Unable to contact the HockeyApp server. HTTP Error=#{e}"
40
+ log_internal :level => :error, :message => "Unable to contact the HockeyApp server. HTTP Error=#{e}"
41
41
  nil
42
42
  end
43
43
 
44
44
  case response
45
45
  when Net::HTTPSuccess then
46
- log :info, "Success: #{response.class}", response
46
+ log_internal :level => :info, :message => "Success: #{response.class}", :response => response
47
47
  else
48
- log :error, "Failure: #{response.class}", response
48
+ log_internal :level => :error, :message => "Failure: #{response.class}", :response => response
49
49
  end
50
50
 
51
51
  if response && response.respond_to?(:body)
@@ -53,8 +53,14 @@ module HockeyBrake
53
53
  error_id[1] if error_id
54
54
  end
55
55
  rescue Exception => e
56
- log :error, "[HockeyBrake::HockeySender#send_to_airbrake] Cannot send notification. Error: #{e.class} - #{e.message}\nBacktrace:\n#{e.backtrace.join("\n\t")}"
56
+ log_internal :level => :error, :message => "[HockeyBrake::HockeySender#send_to_airbrake] Cannot send notification. Error: #{e.class} - #{e.message}\nBacktrace:\n#{e.backtrace.join("\n\t")}"
57
57
  nil
58
58
  end
59
+
60
+ def log_internal(options = {})
61
+ log options
62
+ rescue
63
+ log options[:level], options[:message], options[:response]
64
+ end
59
65
  end
60
66
  end
@@ -1,4 +1,4 @@
1
1
  module HockeyBrake
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
4
4
 
data/lib/hockeybrake.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'hockeybrake/configuration'
2
+ require 'hockeybrake/hockey_log_exception'
2
3
  require 'hockeybrake/hockey_log'
3
4
  require 'hockeybrake/hockey_sender'
4
5
  require 'hockeybrake/hockey_sender_injector'
@@ -23,8 +24,8 @@ module HockeyBrake
23
24
 
24
25
  Resque::Failure::Multiple.classes = [Resque::Failure::Redis, Resque::Failure::Airbrake]
25
26
  Resque::Failure.backend = Resque::Failure::Multiple
26
- rescue
27
- # nothing to do
27
+ rescue LoadError
28
+ # No resquem it's ok
28
29
  end
29
30
 
30
31
  end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'Hockeybrake configuration' do
4
+
5
+ it 'accepts basic settings' do
6
+ HockeyBrake.configure do |config|
7
+ config.app_bundle_id= "com.test.app"
8
+ config.app_id="secret"
9
+ config.app_version="test"
10
+ end
11
+
12
+ HockeyBrake.configuration.app_bundle_id.should eq('com.test.app')
13
+ HockeyBrake.configuration.app_id.should eq('secret')
14
+ HockeyBrake.configuration.app_version.should eq('test')
15
+ end
16
+
17
+ it 'accepts resque specific settings' do
18
+ HockeyBrake.configure do |config|
19
+ config.no_resque_handler = true
20
+ end
21
+
22
+ HockeyBrake.configuration.no_resque_handler.should be_true
23
+ end
24
+
25
+ end
@@ -0,0 +1,26 @@
1
+ require 'spec_helper'
2
+ require 'spec_hockeybrake_configuration'
3
+
4
+ describe 'HockeyLog Exception Tracing' do
5
+ it 'trace standard exception' do
6
+ begin
7
+ raise "This is a sample exception"
8
+ rescue
9
+ notice = Airbrake.send(:build_notice_for, $!)
10
+ HockeyBrake::HockeyLog.generate(notice)
11
+ end
12
+ end
13
+
14
+ it 'raise specific exception when trace failed' do
15
+ expect {
16
+ HockeyBrake::HockeyLog.generate("Not a good exception")
17
+ }.to raise_exception(HockeyBrake::HockeyLogException) do |error|
18
+ error.message.should start_with("An exception was thrown during handling of the exception from the HockeyBrake injector")
19
+ end
20
+ end
21
+ end
22
+
23
+
24
+
25
+
26
+
@@ -0,0 +1,6 @@
1
+ ENV['RAILS_ENV'] = 'test'
2
+
3
+ require 'bundler'
4
+ Bundler.require(:default)
5
+
6
+ require 'shoulda'
@@ -0,0 +1,9 @@
1
+ Airbrake.configure do |config|
2
+ config.development_environments.delete("test")
3
+ end
4
+
5
+ HockeyBrake.configure do |config|
6
+ config.app_bundle_id= "com.test.app"
7
+ config.app_id="secret"
8
+ config.app_version="test"
9
+ end
metadata CHANGED
@@ -1,48 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hockeybrake
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
5
- prerelease:
4
+ version: 0.0.6
6
5
  platform: ruby
7
6
  authors:
8
7
  - Dirk Eisenberg
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-12-06 00:00:00.000000000 Z
11
+ date: 2014-03-16 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: airbrake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: 3.1.2
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: 3.1.2
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: multipart-post
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: 1.1.5
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: 1.1.5
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
46
55
  description: An extension for the amazing airbrake gem which routes crash reports
47
56
  to HockeyApp
48
57
  email:
@@ -52,41 +61,58 @@ extensions: []
52
61
  extra_rdoc_files: []
53
62
  files:
54
63
  - .gitignore
64
+ - .travis.yml
55
65
  - Gemfile
56
- - Gemfile.lock
66
+ - Guardfile
57
67
  - LICENSE.txt
58
68
  - README.md
69
+ - Rakefile
70
+ - gemfiles/airbrake-3.1.16
71
+ - gemfiles/airbrake-3.1.2
72
+ - gemfiles/airbrake-3.1.3
73
+ - gemfiles/airbrake-3.1.4
74
+ - gemfiles/airbrake-3.1.5
75
+ - gemfiles/airbrake-3.1.6
59
76
  - hockeybrake.gemspec
60
77
  - lib/generators/hockeybrake/hockeybrake_generator.rb
61
78
  - lib/generators/hockeybrake/templates/initializer.rb
62
79
  - lib/hockeybrake.rb
63
80
  - lib/hockeybrake/configuration.rb
64
81
  - lib/hockeybrake/hockey_log.rb
82
+ - lib/hockeybrake/hockey_log_exception.rb
65
83
  - lib/hockeybrake/hockey_sender.rb
66
84
  - lib/hockeybrake/hockey_sender_injector.rb
67
85
  - lib/hockeybrake/version.rb
86
+ - spec/hockeybrake/configuration_spec.rb
87
+ - spec/hockeybrake/hockeylog_spec.rb
88
+ - spec/spec_helper.rb
89
+ - spec/spec_hockeybrake_configuration.rb
68
90
  homepage: http://rubygems.org/gems/hockeybrake
69
91
  licenses: []
92
+ metadata: {}
70
93
  post_install_message:
71
94
  rdoc_options: []
72
95
  require_paths:
73
96
  - lib
74
97
  required_ruby_version: !ruby/object:Gem::Requirement
75
- none: false
76
98
  requirements:
77
- - - ! '>='
99
+ - - '>='
78
100
  - !ruby/object:Gem::Version
79
101
  version: '0'
80
102
  required_rubygems_version: !ruby/object:Gem::Requirement
81
- none: false
82
103
  requirements:
83
- - - ! '>='
104
+ - - '>='
84
105
  - !ruby/object:Gem::Version
85
106
  version: '0'
86
107
  requirements: []
87
108
  rubyforge_project:
88
- rubygems_version: 1.8.23
109
+ rubygems_version: 2.1.11
89
110
  signing_key:
90
- specification_version: 3
111
+ specification_version: 4
91
112
  summary: An extension for the amazing airbrake gem which routes crash reports to HockeyApp
92
- test_files: []
113
+ test_files:
114
+ - spec/hockeybrake/configuration_spec.rb
115
+ - spec/hockeybrake/hockeylog_spec.rb
116
+ - spec/spec_helper.rb
117
+ - spec/spec_hockeybrake_configuration.rb
118
+ has_rdoc:
data/Gemfile.lock DELETED
@@ -1,28 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- hockeybrake (0.0.4)
5
- airbrake (>= 3.1.2)
6
- multipart-post (>= 1.1.5)
7
-
8
- GEM
9
- remote: http://rubygems.org/
10
- specs:
11
- airbrake (3.1.6)
12
- builder
13
- girl_friday
14
- builder (3.0.4)
15
- connection_pool (0.9.2)
16
- girl_friday (0.11.1)
17
- connection_pool (~> 0.9.0)
18
- rubinius-actor
19
- multipart-post (1.1.5)
20
- rubinius-actor (0.0.2)
21
- rubinius-core-api
22
- rubinius-core-api (0.0.1)
23
-
24
- PLATFORMS
25
- ruby
26
-
27
- DEPENDENCIES
28
- hockeybrake!