airbrake_symbolicate 0.1 → 0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,10 +14,10 @@ So far, I've only tried it out so far on ruby 1.9.2
14
14
 
15
15
  Install the gem:
16
16
  gem install airbrake_symbolicate
17
-
17
+
18
18
  Run the cli:
19
19
  airbrake_symbolicate airbrake_account_name airbrake_api_auth_token
20
- Where the account name is your subdomain on airbrake (as in http://airbrake_account_name.airbrakeapp.com) and the API key is the one available on the Airbrake account admin's user page (NOT the reporting API key for the project).
20
+ Where the account name is your subdomain on airbrake (as in http://airbrake_account_name.airbrake.io) and the API key is the one available on the Airbrake account admin's user page (NOT the reporting API key for the project).
21
21
  This should spit out all the errors available via the API and the symbolicated backtrace if an appropriate dSYM is found. There's not much error handling.
22
-
22
+
23
23
  See bin/airbrake_symbolicate for general usage from ruby.
@@ -29,14 +29,14 @@ begin
29
29
  errors = Error.find(:all, :params => {:page => page})
30
30
  errors.each do |e|
31
31
  e.reload
32
-
32
+
33
33
  puts DIVIDER
34
34
  puts META_FORMAT % ['message', e.error_message]
35
35
  puts META_FORMAT % ['notices count', e.notices_count]
36
- puts META_FORMAT % ['operating system', e.environment.operating_system]
37
- puts META_FORMAT % ['app version', e.environment.app_version]
36
+ puts META_FORMAT % ['operating system', e.environment.operating_system] rescue nil
38
37
  puts META_FORMAT % ['url', Error.site + Error.element_path(e.id).sub(/\.xml$/, '')]
39
-
38
+ puts META_FORMAT % ['app version', e.app_version]
39
+
40
40
  if bt = Symbolicator.symbolicated_backtrace(e)
41
41
  puts "Backtrace:"
42
42
  bt.each do |l|
@@ -52,4 +52,4 @@ begin
52
52
  end
53
53
  end
54
54
  page += 1
55
- end until errors.empty?
55
+ end until errors.empty?
@@ -2,45 +2,48 @@ require 'active_resource'
2
2
  module AirbrakeSymbolicate
3
3
  class DsymFinder
4
4
  @@dsyms = nil
5
-
5
+
6
6
  class << self
7
7
  def dsym_for_error(error)
8
8
  find_dsyms unless @@dsyms
9
-
10
- @@dsyms[error.environment.git_commit] || @@dsyms[error.environment.app_version]
9
+
10
+ @@dsyms[error.app_version]
11
11
  end
12
-
13
- private
14
-
12
+
13
+ private
14
+
15
15
  # use spotlight to find all the xcode archives
16
16
  # then use the Info.plist inside those archives to try and look up a git commit hash
17
17
  def find_dsyms
18
18
  @@dsyms = {}
19
-
20
- files = `mdfind 'kMDItemKind = "Xcode Archive"'`.split("\n")
19
+
20
+ files = `mdfind -name ".xcarchive"`.split("\n")
21
21
  files.each do |f|
22
- # puts `ls '#{f.chomp}'`
23
22
  info = `find '#{f}/Products' -name Info.plist`.chomp
24
-
25
- if commit = plist_val(info, 'GCGitCommitHash')
26
- if bin_file = Dir[File.join(f, '/dSYMs/*.dSYM/**/DWARF/*')].first
27
- @@dsyms[commit] = bin_file
28
- end
23
+
24
+ short_version = plist_val(info, 'CFBundleShortVersionString')
25
+ long_version = plist_val(info, 'CFBundleVersion')
26
+ version = if short_version
27
+ "#{short_version} (#{long_version})"
29
28
  else
30
- short_version = plist_val(info, 'CFBundleShortVersionString')
31
- long_version = plist_val(info, 'CFBundleVersion')
32
- # this is the format in HTApplicationVersion() in hoptoad-ios
33
- @@dsyms["#{CFBundleShortVersionString} (#{CFBundleVersion})"] = bin_file
29
+ long_version
34
30
  end
31
+
32
+ puts version
33
+
34
+ if bin_file = Dir[File.join(f, '/dSYMs/*.dSYM/**/DWARF/*')].first
35
+ @@dsyms[version] = bin_file
36
+ end
37
+
35
38
  end
36
39
  end
37
-
40
+
38
41
  def plist_val(plist, key)
39
42
  `/usr/libexec/PlistBuddy -c 'Print :#{key}' '#{plist}' 2>/dev/null`.chomp
40
43
  end
41
44
  end
42
45
  end
43
-
46
+
44
47
  class Symbolicator
45
48
  class << self
46
49
  def symbolicated_backtrace(error)
@@ -48,7 +51,7 @@ module AirbrakeSymbolicate
48
51
  error.backtrace.line.map {|l| Symbolicator.symbolicate_line(dsym, l)}
49
52
  end
50
53
  end
51
-
54
+
52
55
  def symbolicate_line(dsym_file, line)
53
56
  binname = File.basename(dsym_file)
54
57
  if line[/#{binname}/] && loc = line[/0x\w+/]
@@ -59,15 +62,16 @@ module AirbrakeSymbolicate
59
62
  end
60
63
  end
61
64
  end
62
-
65
+
63
66
  class Airbrake < ActiveResource::Base
64
67
  cattr_accessor :auth_token
65
68
 
66
69
  class << self
67
70
  def account=(a)
68
- self.site = "http://#{a}.airbrakeapp.com/" if a
71
+ self.site = "https://#{a}.airbrake.io/" if a
72
+ self.format = ActiveResource::Formats::XmlFormat
69
73
  end
70
-
74
+
71
75
  def find(*arguments)
72
76
  arguments = append_auth_token_to_params(*arguments)
73
77
  super(*arguments)
@@ -75,7 +79,7 @@ module AirbrakeSymbolicate
75
79
 
76
80
  def append_auth_token_to_params(*arguments)
77
81
  raise RuntimeError.new("Airbrake.auth_token must be set!") if !auth_token
78
-
82
+
79
83
  opts = arguments.last.is_a?(Hash) ? arguments.pop : {}
80
84
  opts = opts.has_key?(:params) ? opts : opts.merge(:params => {})
81
85
  opts[:params] = opts[:params].merge(:auth_token => auth_token)
@@ -83,10 +87,19 @@ module AirbrakeSymbolicate
83
87
  arguments
84
88
  end
85
89
  end
86
-
90
+
87
91
  end
88
-
89
- class Error < Airbrake
92
+
93
+ class Error < Airbrake
94
+
95
+ def app_version
96
+ if environment.respond_to?(:app_version)
97
+ environment.app_version
98
+ elsif environment.respond_to?(:application_version)
99
+ environment.application_version
100
+ end
101
+ end
102
+
90
103
  end
91
-
104
+
92
105
  end
metadata CHANGED
@@ -1,108 +1,102 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: airbrake_symbolicate
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 1
8
- version: "0.1"
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.2'
5
+ prerelease:
9
6
  platform: ruby
10
- authors:
7
+ authors:
11
8
  - Brett Gibson
12
9
  autorequire:
13
10
  bindir: bin
14
11
  cert_chain: []
15
-
16
- date: 2011-08-03 00:00:00 -07:00
17
- default_executable:
18
- dependencies:
19
- - !ruby/object:Gem::Dependency
12
+ date: 2012-10-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
20
15
  name: activeresource
21
- prerelease: false
22
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
23
17
  none: false
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- segments:
28
- - 3
29
- - 0
30
- version: "3.0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '3.0'
31
22
  type: :runtime
32
- version_requirements: *id001
33
- - !ruby/object:Gem::Dependency
34
- name: colored
35
23
  prerelease: false
36
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: colored
32
+ requirement: !ruby/object:Gem::Requirement
37
33
  none: false
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- segments:
42
- - 1
43
- - 2
44
- version: "1.2"
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '1.2'
45
38
  type: :runtime
46
- version_requirements: *id002
47
- - !ruby/object:Gem::Dependency
48
- name: bundler
49
39
  prerelease: false
50
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '1.2'
46
+ - !ruby/object:Gem::Dependency
47
+ name: bundler
48
+ requirement: !ruby/object:Gem::Requirement
51
49
  none: false
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- segments:
56
- - 0
57
- version: "0"
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
58
54
  type: :development
59
- version_requirements: *id003
60
- description: lib and cli tool to download airbrake iOS crash reports via the api and symbolicate them
61
- email:
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ description: lib and cli tool to download airbrake iOS crash reports via the api and
63
+ symbolicate them
64
+ email:
62
65
  - brettdgibson@gmail.com
63
- executables:
66
+ executables:
64
67
  - airbrake_symbolicate
65
68
  extensions: []
66
-
67
69
  extra_rdoc_files: []
68
-
69
- files:
70
- - bin/airbrake_symbolicate
70
+ files:
71
+ - !binary |-
72
+ YmluL2FpcmJyYWtlX3N5bWJvbGljYXRl
71
73
  - lib/airbrake_symbolicate.rb
72
74
  - LICENSE.txt
73
75
  - README.rdoc
74
76
  - Rakefile
75
- has_rdoc: true
76
- homepage: ""
77
- licenses:
77
+ homepage: ''
78
+ licenses:
78
79
  - MIT
79
80
  post_install_message:
80
81
  rdoc_options: []
81
-
82
- require_paths:
82
+ require_paths:
83
83
  - lib
84
- required_ruby_version: !ruby/object:Gem::Requirement
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
85
  none: false
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- segments:
90
- - 0
91
- version: "0"
92
- required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
91
  none: false
94
- requirements:
95
- - - ">="
96
- - !ruby/object:Gem::Version
97
- segments:
98
- - 0
99
- version: "0"
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
100
96
  requirements: []
101
-
102
97
  rubyforge_project:
103
- rubygems_version: 1.3.7
98
+ rubygems_version: 1.8.23
104
99
  signing_key:
105
100
  specification_version: 3
106
101
  summary: symbolicate airbrake iOS crash reports
107
102
  test_files: []
108
-