squash_ruby 1.2.0 → 1.2.1
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 +7 -0
- data/lib/squash/ruby/exception_additions.rb +1 -1
- data/lib/squash/ruby.rb +71 -23
- metadata +92 -111
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 87f4cbb3b66773b1ed436e622e14dde686c9ba6c
|
4
|
+
data.tar.gz: e779e8860e2449dd71239ce600b158b94320e5aa
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9d627d981014d0126e070170a407ce42af3cbd225f19ad14df3c56d4b3868568a67f5f087135cf7ae4ea20646e005635d623a529d957e4656bd6b49f1104f31e
|
7
|
+
data.tar.gz: 0fd69893426c96de1ac4941914b108108b9beea703cb4a1ba190b10f351b7ca83bd155037fa40a0f629720d80cc12448ff2b614c6daa3073c9bfac09540bf211
|
data/lib/squash/ruby.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2013 Square Inc.
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -63,29 +63,15 @@ module Squash
|
|
63
63
|
# {.configure}).
|
64
64
|
|
65
65
|
def self.notify(exception, user_data={})
|
66
|
-
occurred = Time.now
|
67
|
-
|
68
|
-
return false if configuration(:disabled)
|
69
|
-
unless exception.respond_to?(:backtrace)
|
70
|
-
failsafe_log 'notify', "Tried to pass notify something other than an exception: #{exception.inspect}"
|
71
|
-
return false
|
72
|
-
end
|
73
|
-
unless exception.backtrace
|
74
|
-
failsafe_log 'notify', "Tried to pass notify an exception with no backtrace: #{exception}"
|
75
|
-
return false
|
76
|
-
end
|
77
|
-
|
78
66
|
raise "The :api_key configuration is required" unless configuration(:api_key)
|
79
67
|
raise "The :api_host configuration is required" unless configuration(:api_host)
|
80
68
|
raise "The :environment configuration is required" unless configuration(:environment)
|
81
69
|
|
82
70
|
begin
|
83
|
-
|
84
|
-
return false if
|
85
|
-
check_user_data user_data
|
71
|
+
blob = self.generate_exception(exception, user_data)
|
72
|
+
return false if blob.nil?
|
86
73
|
|
87
|
-
|
88
|
-
http_transmit configuration(:api_host) + configuration(:notify_path), {}, hsh.inject({}) { |h, (k, v)| h[k.to_s] = v; h }.to_json
|
74
|
+
self.transmit_exception(blob)
|
89
75
|
return true
|
90
76
|
rescue Object => nested_error
|
91
77
|
raise if configuration(:disable_failsafe)
|
@@ -249,6 +235,49 @@ module Squash
|
|
249
235
|
|
250
236
|
protected
|
251
237
|
|
238
|
+
# Generates an exception JSON blob for use with {.transmit_exception}. These
|
239
|
+
# methods are separated so that the JSON blobs can be generated separately
|
240
|
+
# from the actual transmission of exceptions, allowing each task to be
|
241
|
+
# optimized separately.
|
242
|
+
#
|
243
|
+
# @param [Object] exception The exception. Must at least duck-type an
|
244
|
+
# `Exception` subclass.
|
245
|
+
# @param [Hash] user_data Any additional context-specific information about
|
246
|
+
# the exception.
|
247
|
+
# @return [String, nil] The JSON data to transmit to Squash. If `nil`,
|
248
|
+
# no request should be made to Squash.
|
249
|
+
|
250
|
+
def self.generate_exception(exception, user_data={})
|
251
|
+
occurred = Time.now
|
252
|
+
|
253
|
+
return nil if configuration(:disabled)
|
254
|
+
unless exception.respond_to?(:backtrace)
|
255
|
+
failsafe_log 'notify', "Tried to pass notify something other than an exception: #{exception.inspect}"
|
256
|
+
return nil
|
257
|
+
end
|
258
|
+
unless exception.backtrace
|
259
|
+
failsafe_log 'notify', "Tried to pass notify an exception with no backtrace: #{exception}"
|
260
|
+
return nil
|
261
|
+
end
|
262
|
+
|
263
|
+
exception, parents = unroll(exception)
|
264
|
+
return nil if ignored?(exception, user_data)
|
265
|
+
check_user_data user_data
|
266
|
+
|
267
|
+
hsh = exception_info_hash(exception, occurred, user_data, parents)
|
268
|
+
hsh.inject({}) { |h, (k, v)| h[k.to_s] = v; h }.to_json
|
269
|
+
end
|
270
|
+
|
271
|
+
# Transmits to Squash exception data generated by {.generate_exception}.
|
272
|
+
#
|
273
|
+
# @param [String] blob Exception data.
|
274
|
+
# @return [true, false] Whether or not the response was successful.
|
275
|
+
# @see .generate_exception
|
276
|
+
|
277
|
+
def self.transmit_exception(blob)
|
278
|
+
http_transmit configuration(:api_host) + configuration(:notify_path), {}, blob
|
279
|
+
end
|
280
|
+
|
252
281
|
# Posts an exception or deploy notification to the API endpoint. Only POST
|
253
282
|
# requests are supported. This method is used internally only. It is
|
254
283
|
# documented so that, in the event you wish to use an alternative HTTP
|
@@ -258,6 +287,9 @@ module Squash
|
|
258
287
|
# contain the given headers and body. It should not eat any exceptions
|
259
288
|
# relating to HTTP connectivity issues.
|
260
289
|
#
|
290
|
+
# There is support for the Linux idiom of configuring a proxy server by
|
291
|
+
# setting the environment variables `http_proxy` and `https_proxy`.
|
292
|
+
#
|
261
293
|
# Your implementation should also respect the value of the
|
262
294
|
# `transmit_timeout` configuration, which is accessible using
|
263
295
|
# `configuration(:transmit_timeout)`.
|
@@ -269,11 +301,27 @@ module Squash
|
|
269
301
|
# @return [true, false] Whether or not the response was successful.
|
270
302
|
|
271
303
|
def self.http_transmit(url, headers, body)
|
272
|
-
uri
|
273
|
-
|
304
|
+
uri = URI.parse(url)
|
305
|
+
|
306
|
+
no_proxy = if ENV['no_proxy']
|
307
|
+
ENV['no_proxy'].split(',').any? { |ext| uri.host[-ext.length, ext.length] == ext }
|
308
|
+
else
|
309
|
+
false
|
310
|
+
end
|
311
|
+
|
312
|
+
http = if uri.scheme == 'https' && ENV['https_proxy'] && !no_proxy
|
313
|
+
proxy = URI.parse("https://#{ENV['https_proxy']}")
|
314
|
+
Net::HTTP::Proxy(proxy.host, proxy.port, proxy.user, proxy.password).new(uri.host, uri.port)
|
315
|
+
elsif uri.scheme == 'http' && ENV['http_proxy'] && !no_proxy
|
316
|
+
proxy = URI.parse("http://#{ENV['http_proxy']}")
|
317
|
+
Net::HTTP::Proxy(proxy.host, proxy.port, proxy.user, proxy.password).new(uri.host, uri.port)
|
318
|
+
else
|
319
|
+
Net::HTTP.new(uri.host, uri.port)
|
320
|
+
end
|
321
|
+
|
274
322
|
http_options(uri).each { |k, v| http.send :"#{k}=", v }
|
275
323
|
|
276
|
-
block =
|
324
|
+
block = proc do
|
277
325
|
http.start do |http|
|
278
326
|
request = Net::HTTP::Post.new(uri.request_uri)
|
279
327
|
request.add_field 'Content-Type', 'application/json'
|
@@ -290,9 +338,9 @@ module Squash
|
|
290
338
|
end
|
291
339
|
|
292
340
|
if defined?(SystemTimer)
|
293
|
-
SystemTimer.timeout_after
|
341
|
+
SystemTimer.timeout_after((configuration(:open_timeout) + configuration(:transmit_timeout)), &block)
|
294
342
|
else
|
295
|
-
block
|
343
|
+
Timeout.timeout((configuration(:open_timeout) + configuration(:transmit_timeout)), &block)
|
296
344
|
end
|
297
345
|
end
|
298
346
|
|
metadata
CHANGED
@@ -1,152 +1,133 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: squash_ruby
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 2
|
9
|
-
- 0
|
10
|
-
version: 1.2.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.2.1
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Tim Morgan
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
21
|
-
type: :runtime
|
22
|
-
version_requirements: &id001 !ruby/object:Gem::Requirement
|
23
|
-
none: false
|
24
|
-
requirements:
|
25
|
-
- - ">="
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
hash: 3
|
28
|
-
segments:
|
29
|
-
- 0
|
30
|
-
version: "0"
|
31
|
-
requirement: *id001
|
32
|
-
prerelease: false
|
11
|
+
date: 2013-09-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
33
14
|
name: json
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
hash: 3
|
42
|
-
segments:
|
43
|
-
- 0
|
44
|
-
version: "0"
|
45
|
-
requirement: *id002
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
46
21
|
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
47
28
|
name: rspec
|
48
|
-
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
49
34
|
type: :development
|
50
|
-
version_requirements: &id003 !ruby/object:Gem::Requirement
|
51
|
-
none: false
|
52
|
-
requirements:
|
53
|
-
- - ">="
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
hash: 3
|
56
|
-
segments:
|
57
|
-
- 0
|
58
|
-
version: "0"
|
59
|
-
requirement: *id003
|
60
35
|
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
61
42
|
name: fakefs
|
62
|
-
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
63
48
|
type: :development
|
64
|
-
version_requirements: &id004 !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ">="
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
hash: 3
|
70
|
-
segments:
|
71
|
-
- 0
|
72
|
-
version: "0"
|
73
|
-
requirement: *id004
|
74
49
|
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
75
56
|
name: yard
|
76
|
-
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
77
62
|
type: :development
|
78
|
-
version_requirements: &id005 !ruby/object:Gem::Requirement
|
79
|
-
none: false
|
80
|
-
requirements:
|
81
|
-
- - ">="
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
hash: 3
|
84
|
-
segments:
|
85
|
-
- 0
|
86
|
-
version: "0"
|
87
|
-
requirement: *id005
|
88
63
|
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
89
70
|
name: redcarpet
|
90
|
-
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - <
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.0'
|
91
76
|
type: :development
|
92
|
-
version_requirements: &id006 !ruby/object:Gem::Requirement
|
93
|
-
none: false
|
94
|
-
requirements:
|
95
|
-
- - ">="
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
hash: 3
|
98
|
-
segments:
|
99
|
-
- 0
|
100
|
-
version: "0"
|
101
|
-
requirement: *id006
|
102
77
|
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - <
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
103
84
|
name: jeweler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
104
97
|
description: This client library records Ruby exceptions to Squash.
|
105
98
|
email: tim@squareup.com
|
106
99
|
executables: []
|
107
|
-
|
108
100
|
extensions: []
|
109
|
-
|
110
|
-
extra_rdoc_files:
|
101
|
+
extra_rdoc_files:
|
111
102
|
- LICENSE.txt
|
112
103
|
- README.md
|
113
|
-
files:
|
104
|
+
files:
|
114
105
|
- LICENSE.txt
|
115
106
|
- README.md
|
116
107
|
- lib/squash/ruby.rb
|
117
108
|
- lib/squash/ruby/exception_additions.rb
|
118
109
|
homepage: http://github.com/SquareSquash/ruby
|
119
|
-
licenses:
|
110
|
+
licenses:
|
120
111
|
- Apache 2.0
|
112
|
+
metadata: {}
|
121
113
|
post_install_message:
|
122
114
|
rdoc_options: []
|
123
|
-
|
124
|
-
require_paths:
|
115
|
+
require_paths:
|
125
116
|
- lib
|
126
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
none: false
|
137
|
-
requirements:
|
138
|
-
- - ">="
|
139
|
-
- !ruby/object:Gem::Version
|
140
|
-
hash: 3
|
141
|
-
segments:
|
142
|
-
- 0
|
143
|
-
version: "0"
|
117
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
118
|
+
requirements:
|
119
|
+
- - '>='
|
120
|
+
- !ruby/object:Gem::Version
|
121
|
+
version: '0'
|
122
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
|
+
requirements:
|
124
|
+
- - '>='
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
144
127
|
requirements: []
|
145
|
-
|
146
128
|
rubyforge_project:
|
147
|
-
rubygems_version:
|
129
|
+
rubygems_version: 2.0.6
|
148
130
|
signing_key:
|
149
|
-
specification_version:
|
131
|
+
specification_version: 4
|
150
132
|
summary: Squash client for Ruby projects
|
151
133
|
test_files: []
|
152
|
-
|