squash_ruby 1.4.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
- ---
2
- SHA1:
3
- data.tar.gz: 9195ad43d6d71778ced73b5e07ae5917ad22537d
4
- metadata.gz: 69b5051d8f134aed6849bdc79fe7c0bbad75825d
5
- SHA512:
6
- data.tar.gz: d04d3988aae11bafc93b42c695fa7d6ad6368af21ed4439cb7cfead5ff1ef23f809e635b0e56b9c7e3308f7a83bd4fb2a4effd610d38f3cc9417eabbd3f5ddf0
7
- metadata.gz: 968d1cdab38243ece16bf0ae2f35ff077403b2655256ceb9428e0446b21a4d69828bd7a869ddaf0f346ee6c4d0de71410520679165c97270b772479c4771c52d
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OGRjNTdhNGQxYzI0YzYwNTFhMGRlMmRjOWIxN2FlMTViMjRlOWFkNw==
5
+ data.tar.gz: !binary |-
6
+ YzMwOTczZmM3ZWRlZDA0OWI1OTAyZWZkZDBmM2I4OGRlMzljYTI2Zg==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ MWQwNjkxZDBiMzdhZWJjYzU3Nzk3NjQ2N2VlNGFlYWNmMjllNGZiZGVjMWFk
10
+ NTdmNmIyMTQ3Mzg5OTdjNTFiMjAyYmM4ZDk4NmE5MTZmMGYxZDg5OTZjYTgz
11
+ ZjRmMjEyMjE4ZmZlMTgxMWViYTRhNzQ2YjgzMjFjOTNkM2QyZGU=
12
+ data.tar.gz: !binary |-
13
+ ZDgyZWE0OGYyZWU3OGY3YTFiYjhjNzQyMDE4MmJjOWJlNTQ3YjViNzlmM2Iy
14
+ M2ViNmFiMTc4M2NhZjllYWY4MWU4MzZjZWQ2ZWI4NTFkYmJlZjhmMTllNGUx
15
+ YWExMzUyM2JhNWRmYTY2ZjY0MGZhOTYzNmE0MTBiMGI3NWQ5Zjk=
data/README.md CHANGED
@@ -19,8 +19,7 @@ documentation at https://github.com/SquareSquash/web.
19
19
  Compatibility
20
20
  -------------
21
21
 
22
- This library is compatible with Ruby 1.8.6 and later, including Ruby Enterprise
23
- Edition.
22
+ This library is compatible with Ruby 1.9.2 and later, including JRuby.
24
23
 
25
24
  Requirements
26
25
  ------------
@@ -38,9 +37,9 @@ Add the Squash client to your Gemfile with
38
37
  project you are recording exceptions for:
39
38
 
40
39
  ```` ruby
41
- Squash::Ruby.configure :api_key => 'YOUR_API_KEY',
42
- :api_host => 'https://your.squash.host',
43
- :environment => 'production'
40
+ Squash::Ruby.configure api_key: 'YOUR_API_KEY',
41
+ api_host: 'https://your.squash.host',
42
+ environment: 'production'
44
43
  ````
45
44
 
46
45
  To use Squash to manage your exceptions, place a `begin::rescue` statement at
@@ -86,7 +85,7 @@ You can also add user data using the {Squash::Ruby.add_user_data} method:
86
85
 
87
86
  ```` ruby
88
87
  input = gets
89
- Squash::Ruby.add_user_data(:input => input) do
88
+ Squash::Ruby.add_user_data(input: input) do
90
89
  process_input # may raise an exception
91
90
  end
92
91
  ````
@@ -98,7 +97,7 @@ data directly in the exception constructor:
98
97
  require 'squash/ruby/exception_additions'
99
98
 
100
99
  def process_value(value)
101
- raise ArgumentError.new("value must be a number", :value => value) unless value.kind_of?(Fixnum)
100
+ raise ArgumentError.new("value must be a number", value: value) unless value.kind_of?(Fixnum)
102
101
  # [...]
103
102
  end
104
103
  ````
@@ -112,7 +111,7 @@ require 'squash/ruby/exception_additions'
112
111
  begin
113
112
  do_something_with_input(input)
114
113
  rescue ArgumentError => err
115
- err.user_data :input => input
114
+ err.user_data input: input
116
115
  raise # assumed that Squash::Ruby.notify is called somewhere further up in the stack
117
116
  end
118
117
  ````
@@ -156,6 +155,11 @@ keys:
156
155
  stripped from backtrace lines. By default it's set to the working directory.
157
156
  * `mirrored_repository`: Set this option to be true if your repository root is a
158
157
  mirrored Git repository.
158
+ * `exception_behavior_when_disabled`: Set this option to customize Squash's
159
+ behavior when an exception is raised in an environment where Squash is
160
+ disabled (typically development and test). Values are `ignore` (default):
161
+ exception is ignored; `raise`: exception is raised; and `log`: exception is
162
+ logged at the error level to the failsafe log.
159
163
 
160
164
  ### Revision Information
161
165
 
@@ -182,6 +186,10 @@ options override `repository_root`.
182
186
  * `max_variable_size`: The maximum size (in bytes) of a serialized
183
187
  representation of a value that will be transmitted over the network. Values
184
188
  that serialize to larger than this size will be replaced with a placeholder.
189
+ * `timeout_protection`: a `proc { |timeout, &block| ... }` that runs the given
190
+ block, and times out after `timeout` seconds. By default this will use
191
+ `SystemTimer` if present, or else the built in `Timeout` class, but can be
192
+ overridden to provide more fine grain logic around timeouts.
185
193
 
186
194
  ### Ignored Exceptions
187
195
 
@@ -197,7 +205,7 @@ options override `repository_root`.
197
205
  client libraries (e.g., Squash Rails client); an example:
198
206
 
199
207
  ```` ruby
200
- Squash::Ruby.configure :ignored_exception_procs => lambda do |exception, user_data|
208
+ Squash::Ruby.configure ignored_exception_procs: lambda do |exception, user_data|
201
209
  exception.kind_of?(ActiveRecord::RecordNotFound) && user_data[:headers]['X-Testing'].blank?
202
210
  end
203
211
  ````
@@ -31,16 +31,19 @@ module Squash
31
31
  EXCEPTION_RESERVED_IVARS = %W( mesg bt )
32
32
  # Default values for different configuration variables.
33
33
  CONFIGURATION_DEFAULTS = {
34
- :notify_path => "/api/1.0/notify",
35
- :deploy_path => "/api/1.0/deploy",
36
- :open_timeout => 15,
37
- :transmit_timeout => 15,
38
- :ignored_exception_classes => [],
39
- :ignored_exception_messages => {},
40
- :ignored_exception_procs => [],
41
- :failsafe_log => "squash.failsafe.log",
42
- :repository_root => Dir.getwd,
43
- :project_root => Dir.getwd
34
+ notify_path: "/api/1.0/notify",
35
+ deploy_path: "/api/1.0/deploy",
36
+ open_timeout: 15,
37
+ transmit_timeout: 15,
38
+ ignored_exception_classes: [],
39
+ ignored_exception_messages: {},
40
+ ignored_exception_procs: [],
41
+ failsafe_log: "squash.failsafe.log",
42
+ repository_root: Dir.getwd,
43
+ project_root: Dir.getwd,
44
+ timeout_protection: proc { |timeout, &block|
45
+ timeout_protection(timeout, &block)
46
+ },
44
47
  }
45
48
  # Types that are serialized directly to JSON, rather than to a hash of
46
49
  # object information. Subclasses are not considered members of this array.
@@ -51,7 +54,9 @@ module Squash
51
54
  # constant to include Rails-specific fields, for example.
52
55
  TOP_LEVEL_USER_DATA = []
53
56
 
54
- # Notifies Squash of an exception.
57
+ # Notifies Squash of an exception. The behavior of this method when Squash
58
+ # is disabled is dependent on the `exception_behavior_when_disabled`
59
+ # configuration option.
55
60
  #
56
61
  # @param [Object] exception The exception. Must at least duck-type an
57
62
  # `Exception` subclass.
@@ -63,7 +68,18 @@ module Squash
63
68
  # {.configure}).
64
69
 
65
70
  def self.notify(exception, user_data={})
66
- unless configuration(:disabled)
71
+ if configuration(:disabled)
72
+ case configuration(:exception_behavior_when_disabled)
73
+ when 'log', :log
74
+ failsafe_log '[Squash::Ruby.notify]', "Exception raised: #{exception.to_s}\n" +
75
+ exception.backtrace.map { |l| " #{l}" }.join("\n")
76
+ when 'raise', :raise
77
+ raise exception
78
+ else
79
+ # ignore
80
+ end
81
+ return false
82
+ else
67
83
  raise "The :api_key configuration is required" unless configuration(:api_key)
68
84
  raise "The :api_host configuration is required" unless configuration(:api_host)
69
85
  raise "The :environment configuration is required" unless configuration(:environment)
@@ -179,6 +195,10 @@ module Squash
179
195
  # Squash. This allows you to ensure that a non-critical block of code
180
196
  # does not halt your application while still receiving exception
181
197
  # notifications in Squash.
198
+ #
199
+ # The behavior of this method when Squash is disabled is dependent on the
200
+ # `exception_behavior_when_disabled` configuration option.
201
+ #
182
202
  # @param [Array<Class>] exception_classes A list of exception classes to
183
203
  # report silently. Exceptions _not_ of these classes (or their
184
204
  # subclasses) will raise (and presumably be handled by Squash elsewhere
@@ -323,7 +343,8 @@ module Squash
323
343
 
324
344
  http_options(uri).each { |k, v| http.send :"#{k}=", v }
325
345
 
326
- block = proc do
346
+ timeout = configuration(:open_timeout) + configuration(:transmit_timeout)
347
+ configuration(:timeout_protection).call(timeout) do
327
348
  http.start do |http|
328
349
  request = Net::HTTP::Post.new(uri.request_uri)
329
350
  request.add_field 'Content-Type', 'application/json'
@@ -338,12 +359,6 @@ module Squash
338
359
  end
339
360
  end
340
361
  end
341
-
342
- if defined?(SystemTimer)
343
- SystemTimer.timeout_after((configuration(:open_timeout) + configuration(:transmit_timeout)), &block)
344
- else
345
- Timeout.timeout((configuration(:open_timeout) + configuration(:transmit_timeout)), &block)
346
- end
347
362
  end
348
363
 
349
364
  # Notifies Squash of a new deploy. Squash will then determine which bug
@@ -400,9 +415,9 @@ module Squash
400
415
  private
401
416
 
402
417
  def self.http_options(uri)
403
- options = {:use_ssl => uri.scheme == 'https',
404
- :open_timeout => configuration(:transmit_timeout),
405
- :read_timeout => configuration(:transmit_timeout)}
418
+ options = {use_ssl: uri.scheme == 'https',
419
+ open_timeout: configuration(:transmit_timeout),
420
+ read_timeout: configuration(:transmit_timeout)}
406
421
  options[:verify_mode] = OpenSSL::SSL::VERIFY_NONE if configuration(:skip_ssl_verification)
407
422
  options
408
423
  end
@@ -721,5 +736,15 @@ module Squash
721
736
 
722
737
  # @private
723
738
  def self.client_name() 'ruby' end
739
+
740
+ # @private
741
+ def self.timeout_protection(timeout, &block)
742
+ if defined?(SystemTimer)
743
+ SystemTimer.timeout_after(timeout, &block)
744
+ else
745
+ Timeout.timeout(timeout, &block)
746
+ end
747
+ end
748
+
724
749
  end
725
750
  end
@@ -16,7 +16,7 @@
16
16
  # to an exception at the time of the raise.
17
17
  #
18
18
  # @example
19
- # raise ArgumentError.new("value must be a number", :value => value) unless value.kind_of?(Fixnum)
19
+ # raise ArgumentError.new("value must be a number", value: value) unless value.kind_of?(Fixnum)
20
20
 
21
21
  class Exception
22
22
 
metadata CHANGED
@@ -1,106 +1,135 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: squash_ruby
3
- version: !ruby/object:Gem::Version
4
- version: 1.4.0
3
+ version: !ruby/object:Gem::Version
4
+ version: !binary |-
5
+ Mi4wLjA=
5
6
  platform: ruby
6
- authors:
7
+ authors:
7
8
  - Tim Morgan
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
-
12
- date: 2014-01-09 00:00:00 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- requirement: &id001 !ruby/object:Gem::Requirement
16
- requirements:
17
- - &id002
18
- - ">="
19
- - !ruby/object:Gem::Version
20
- version: "0"
21
- version_requirements: *id001
22
- prerelease: false
23
- type: :runtime
12
+ date: 2014-11-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
24
15
  name: json
25
- - !ruby/object:Gem::Dependency
26
- requirement: &id003 !ruby/object:Gem::Requirement
27
- requirements:
28
- - *id002
29
- version_requirements: *id003
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ! '>='
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
30
22
  prerelease: false
31
- type: :development
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ! '>='
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
32
29
  name: rspec
33
- - !ruby/object:Gem::Dependency
34
- requirement: &id004 !ruby/object:Gem::Requirement
35
- requirements:
36
- - *id002
37
- version_requirements: *id004
38
- prerelease: false
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
39
35
  type: :development
40
- name: fakefs
41
- - !ruby/object:Gem::Dependency
42
- requirement: &id005 !ruby/object:Gem::Requirement
43
- requirements:
44
- - *id002
45
- version_requirements: *id005
46
36
  prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: fakefs
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
47
49
  type: :development
48
- name: yard
49
- - !ruby/object:Gem::Dependency
50
- requirement: &id006 !ruby/object:Gem::Requirement
51
- requirements:
52
- - - <
53
- - !ruby/object:Gem::Version
54
- version: "3.0"
55
- version_requirements: *id006
56
50
  prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: yard
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
57
63
  type: :development
58
- name: redcarpet
59
- - !ruby/object:Gem::Dependency
60
- requirement: &id007 !ruby/object:Gem::Requirement
61
- requirements:
62
- - *id002
63
- version_requirements: *id007
64
64
  prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: redcarpet
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
65
77
  type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ! '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
66
85
  name: jeweler
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ! '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
67
98
  description: This client library records Ruby exceptions to Squash.
68
99
  email: tim@squareup.com
69
100
  executables: []
70
-
71
101
  extensions: []
72
-
73
- extra_rdoc_files:
102
+ extra_rdoc_files:
74
103
  - LICENSE.txt
75
104
  - README.md
76
- files:
105
+ files:
77
106
  - LICENSE.txt
78
107
  - README.md
79
108
  - lib/squash/ruby.rb
80
109
  - lib/squash/ruby/exception_additions.rb
81
110
  - lib/squash_ruby.rb
82
111
  homepage: http://github.com/SquareSquash/ruby
83
- licenses:
112
+ licenses:
84
113
  - Apache 2.0
85
114
  metadata: {}
86
-
87
115
  post_install_message:
88
116
  rdoc_options: []
89
-
90
- require_paths:
117
+ require_paths:
91
118
  - lib
92
- required_ruby_version: !ruby/object:Gem::Requirement
93
- requirements:
94
- - *id002
95
- required_rubygems_version: !ruby/object:Gem::Requirement
96
- requirements:
97
- - *id002
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ! '>='
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ! '>='
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
98
129
  requirements: []
99
-
100
130
  rubyforge_project:
101
- rubygems_version: 2.0.14
131
+ rubygems_version: 2.4.2
102
132
  signing_key:
103
133
  specification_version: 4
104
134
  summary: Squash client for Ruby projects
105
135
  test_files: []
106
-