airbrake_tools 0.0.10 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/Gemfile.lock +2 -2
- data/Readme.md +1 -0
- data/lib/airbrake_tools/version.rb +1 -1
- data/lib/airbrake_tools.rb +12 -2
- data/spec/airbrake_tools_spec.rb +22 -2
- metadata +4 -4
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/Readme.md
CHANGED
@@ -80,6 +80,7 @@ Mysql2::Error: Lost connection to MySQL server during reconnect
|
|
80
80
|
-p, --pages NUM How maybe pages to iterate over (default: hot:1 summary:5)
|
81
81
|
-c, --compare-depth NUM At what level to compare backtraces (default: 7)
|
82
82
|
-e, --environment ENV Only show errors from this environment (default: production)
|
83
|
+
--project NAME Name of project to fetch errors for
|
83
84
|
-h, --help Show this.
|
84
85
|
-v, --version Show Version
|
85
86
|
```
|
data/lib/airbrake_tools.rb
CHANGED
@@ -21,6 +21,8 @@ module AirbrakeTools
|
|
21
21
|
AirbrakeAPI.auth_token = ARGV[1]
|
22
22
|
AirbrakeAPI.secure = true
|
23
23
|
|
24
|
+
options[:project_id] = project_id(options.delete(:project_name)) if options[:project_name]
|
25
|
+
|
24
26
|
if AirbrakeAPI.account.to_s.empty? || AirbrakeAPI.auth_token.to_s.empty?
|
25
27
|
puts "Usage instructions: airbrake-tools --help"
|
26
28
|
return 1
|
@@ -124,7 +126,7 @@ module AirbrakeTools
|
|
124
126
|
|
125
127
|
def backtrace(notice)
|
126
128
|
return if notice.backtrace.is_a?(String)
|
127
|
-
notice.backtrace.first[1]
|
129
|
+
[*notice.backtrace.first[1]] # can be string or array
|
128
130
|
end
|
129
131
|
|
130
132
|
def average_first_project_line(backtraces)
|
@@ -155,7 +157,7 @@ module AirbrakeTools
|
|
155
157
|
def errors_from_pages(options)
|
156
158
|
errors = []
|
157
159
|
options[:pages].times do |i|
|
158
|
-
errors.concat(AirbrakeAPI.errors(:page => i+1) || [])
|
160
|
+
errors.concat(AirbrakeAPI.errors(:page => i+1, :project_id => options[:project_id]) || [])
|
159
161
|
end
|
160
162
|
select_env(errors, options)
|
161
163
|
end
|
@@ -205,6 +207,7 @@ module AirbrakeTools
|
|
205
207
|
opts.on("-c NUM", "--compare-depth NUM", Integer, "How deep to compare backtraces in summary (default: first line in project + #{DEFAULT_COMPARE_DEPTH_ADDITION})") {|s| options[:compare_depth] = s }
|
206
208
|
opts.on("-p NUM", "--pages NUM", Integer, "How maybe pages to iterate over (default: hot:#{DEFAULT_HOT_PAGES} new:#{DEFAULT_NEW_PAGES} summary:#{DEFAULT_SUMMARY_PAGES})") {|s| options[:pages] = s }
|
207
209
|
opts.on("-e ENV", "--environment ENV", String, "Only show errors from this environment (default: #{DEFAULT_ENVIRONMENT})") {|s| options[:env] = s }
|
210
|
+
opts.on("--project NAME", String, "Name of project to fetch errors for") {|p| options[:project_name] = p }
|
208
211
|
opts.on("-h", "--help", "Show this.") { puts opts; exit }
|
209
212
|
opts.on("-v", "--version", "Show Version"){ puts "airbrake-tools #{VERSION}"; exit }
|
210
213
|
end.parse!(argv)
|
@@ -225,5 +228,12 @@ module AirbrakeTools
|
|
225
228
|
def sparkline(notices, options)
|
226
229
|
`#{File.expand_path('../../spark.sh',__FILE__)} #{sparkline_data(notices, options).join(" ")}`.strip
|
227
230
|
end
|
231
|
+
|
232
|
+
def project_id(project_name)
|
233
|
+
@projects ||= AirbrakeAPI.projects
|
234
|
+
project = @projects.detect { |p| p.name == project_name }
|
235
|
+
raise "project with name #{name} not found try #{@projects.map(&:name).join(", ")}" unless project
|
236
|
+
project.id
|
237
|
+
end
|
228
238
|
end
|
229
239
|
end
|
data/spec/airbrake_tools_spec.rb
CHANGED
@@ -133,8 +133,8 @@ describe "airbrake-tools" do
|
|
133
133
|
end
|
134
134
|
|
135
135
|
it "adds blame if file exists" do
|
136
|
-
AirbrakeTools.send(:present_line, "[PROJECT_ROOT]/Gemfile:
|
137
|
-
"Gemfile:
|
136
|
+
AirbrakeTools.send(:present_line, "[PROJECT_ROOT]/Gemfile:2 adasdsad").should ==
|
137
|
+
"Gemfile:2 adasdsad -- ^acc8204 (<jcheatham@zendesk.com> 2012-11-06 18:45:10 -0800 )"
|
138
138
|
end
|
139
139
|
|
140
140
|
it "does not add blame to system files" do
|
@@ -193,4 +193,24 @@ describe "airbrake-tools" do
|
|
193
193
|
AirbrakeTools.send(:select_env, [stub(:rails_env => "production")], {}).size.should == 1
|
194
194
|
end
|
195
195
|
end
|
196
|
+
|
197
|
+
describe ".project_id" do
|
198
|
+
before do
|
199
|
+
AirbrakeAPI.should_receive(:projects).and_return([stub(:name => "a", :id => 123), stub(:name => "b", :id => 234)])
|
200
|
+
end
|
201
|
+
|
202
|
+
after do
|
203
|
+
AirbrakeTools.instance_variable_set(:@projects, nil) # unset stubs
|
204
|
+
end
|
205
|
+
|
206
|
+
it "returns id for a name" do
|
207
|
+
AirbrakeTools.send(:project_id, "a").should == 123
|
208
|
+
end
|
209
|
+
|
210
|
+
it "raises a nice error when project was not found" do
|
211
|
+
expect{
|
212
|
+
AirbrakeTools.send(:project_id, "c")
|
213
|
+
}.to raise_error(/not found/)
|
214
|
+
end
|
215
|
+
end
|
196
216
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: airbrake_tools
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-06-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: airbrake-api
|
@@ -62,7 +62,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
62
62
|
version: '0'
|
63
63
|
segments:
|
64
64
|
- 0
|
65
|
-
hash:
|
65
|
+
hash: 873247243575833967
|
66
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
67
|
none: false
|
68
68
|
requirements:
|
@@ -71,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
71
|
version: '0'
|
72
72
|
segments:
|
73
73
|
- 0
|
74
|
-
hash:
|
74
|
+
hash: 873247243575833967
|
75
75
|
requirements: []
|
76
76
|
rubyforge_project:
|
77
77
|
rubygems_version: 1.8.23
|