exception_notification-squash_notifier 0.1.1.2 → 0.1.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e595cb83373abc990d47bce7578a850bc72398f
4
- data.tar.gz: fcb8da7dd0df40d685332efc05ccb160d46b188f
3
+ metadata.gz: 2b71edc1bca114c09a3f718c18e31b0ad36f2454
4
+ data.tar.gz: 2687ab743009ba8a776c7e3f9ab1dc64797e65fd
5
5
  SHA512:
6
- metadata.gz: 80c6e278a302da807e72f73bc0808b8d9fe87687d1fe1729214a0a2daf27a110b1afabf1e26ece84b8c47bcf64dee5a15448e02a2a25a682e3f9eb11e006ead7
7
- data.tar.gz: 7c41ba391581c0009a12b7bcbaa2e05bbb25e3d3e51a8308b0ec5435744bef57c964256b27bc664ed72150c8237ae2ba1690610fa346dc9b7273da5b9bbb19f6
6
+ metadata.gz: 21b4fd84ae9c1fc2b5c4d847ace7355863d6d0d827b2c54b93b69ea889da0a50133f6696df1b55946727506abd30a7470f9aad7d35c05dc450d7c08e04db8fd7
7
+ data.tar.gz: 64fec832378419250d23b5c99493268f08fcb37c807979b012a69525defbfee94808deab1e740382519e3c2fe3ab5677f30f7bc4e099aeccf5afb37cc9db7ffa
@@ -0,0 +1,50 @@
1
+ module ExceptionNotifier
2
+ class SquashNotifier
3
+ # Factory class:
4
+ def self.new(*args, &p)
5
+ return SquashRailsNotifier.new(*args, &p) if defined? Rails
6
+ SquashRubyNotifier.new(*args, &p)
7
+ end
8
+
9
+ class BaseNotifier
10
+ cattr_accessor :whitelisted_env_vars
11
+ # This accepts RegEx, so to not-whitelist, add an entry of /.*/
12
+ self.whitelisted_env_vars = []
13
+
14
+ def self.default_options
15
+ {
16
+ filter_env_vars: self.whitelist_env_filter
17
+ }
18
+ end
19
+
20
+ def default_options
21
+ self.class.default_options
22
+ end
23
+
24
+ def self.whitelist_env_filter
25
+ # Remove any entries from the 'env' var that are not in the 'whitelisted_env_var' list
26
+ lambda do |env|
27
+ env.select do |key, val|
28
+ #NB: we want to close-over `self` so we can access the class var
29
+ #NB:
30
+ # - When `allowed` is a Regexp, === is like ((a =~ b) ? true : false)
31
+ # - When `allowed` is a String, === is like (a == b.to_str)
32
+ # - When `allowed` is a Symbol, === is (a == b)
33
+ self.whitelisted_env_vars.any? {|allowed| allowed === key }
34
+ end
35
+ end
36
+ end
37
+
38
+ #####
39
+
40
+ def initialize(options)
41
+ Squash::Ruby.configure default_options.merge(options)
42
+ Squash::Ruby.configure disabled: !Squash::Ruby.configuration(:api_key)
43
+ end
44
+
45
+ def call(exception, data={})
46
+ raise NotImplementedError
47
+ end
48
+ end
49
+ end
50
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'pp'
4
4
 
5
- class ExceptionNotifier::SquashNotifier
5
+ class ExceptionNotifier::SquashNotifier::SquashRailsNotifier < ExceptionNotifier::SquashNotifier::SquashRubyNotifier
6
6
  self.whitelisted_env_vars += [
7
7
  'action_dispatch.request.parameters',
8
8
  'action_dispatch.request.path_parameters',
@@ -26,6 +26,12 @@ class ExceptionNotifier::SquashNotifier
26
26
  'SERVER_SOFTWARE',
27
27
  ]
28
28
 
29
+ def call(exception, data={})
30
+ super(exception, munge_env(data))
31
+ end
32
+
33
+ protected
34
+
29
35
  def munge_env(data)
30
36
  return data unless data.has_key?(:env)
31
37
 
@@ -45,8 +51,6 @@ class ExceptionNotifier::SquashNotifier
45
51
  ))
46
52
  end
47
53
 
48
- private
49
-
50
54
  def occurence_data(request: nil, session: nil, rack_env: {})
51
55
  #TODO: Remove when done:
52
56
  # flash_key = defined?(ActionDispatch) ? ActionDispatch::Flash::KEY : 'flash'
@@ -0,0 +1,23 @@
1
+ class ExceptionNotifier::SquashNotifier::SquashRubyNotifier < ExceptionNotifier::SquashNotifier::BaseNotifier
2
+ self.whitelisted_env_vars += [
3
+ 'BUNDLE_BIN_PATH',
4
+ 'BUNDLE_GEMFILE',
5
+ 'CONTENT_LENGTH',
6
+ 'CONTENT_TYPE',
7
+ 'DOCUMENT_ROOT',
8
+ 'GEM_HOME',
9
+ 'HOME',
10
+ 'ORIGINAL_FULLPATH',
11
+ 'PATH',
12
+ 'PATH_INFO',
13
+ 'PWD',
14
+ 'RUBYOPT',
15
+ 'TMPDIR',
16
+ 'USER',
17
+ ]
18
+
19
+ def call(exception, data={})
20
+ #NB: You can pass a `user_data` hash to #notify, and most attr's will be placed into a `user_data` field
21
+ Squash::Ruby.notify(exception, data)
22
+ end
23
+ end
@@ -1,5 +1,5 @@
1
1
  module ExceptionNotifier
2
2
  class SquashNotifier
3
- VERSION = "0.1.1.2"
3
+ VERSION = "0.1.1.3"
4
4
  end
5
5
  end
@@ -4,69 +4,9 @@ require "active_support/core_ext/module/attribute_accessors"
4
4
  require "exception_notifier"
5
5
 
6
6
  require "exception_notifier/squash_ruby"
7
-
8
- module ExceptionNotifier
9
- class SquashNotifier
10
- cattr_accessor :whitelisted_env_vars
11
- # This accepts RegEx, so to not-whitelist, add an entry of /.*/
12
- self.whitelisted_env_vars = [
13
- 'BUNDLE_BIN_PATH',
14
- 'BUNDLE_GEMFILE',
15
- 'CONTENT_LENGTH',
16
- 'CONTENT_TYPE',
17
- 'DOCUMENT_ROOT',
18
- 'GEM_HOME',
19
- 'HOME',
20
- 'ORIGINAL_FULLPATH',
21
- 'PATH',
22
- 'PATH_INFO',
23
- 'PWD',
24
- 'RUBYOPT',
25
- 'TMPDIR',
26
- 'USER',
27
- ]
28
-
29
- def self.default_options
30
- {
31
- filter_env_vars: self.whitelist_env_filter
32
- }
33
- end
34
-
35
- def default_options
36
- self.class.default_options
37
- end
38
-
39
- def self.whitelist_env_filter
40
- # Remove any entries from the 'env' var that are not in the 'whitelisted_env_var' list
41
- lambda do |env|
42
- env.select do |key, val|
43
- #NB: we want to close-over `self` so we can access the class var
44
- #NB:
45
- # - When `allowed` is a Regexp, === is like ((a =~ b) ? true : false)
46
- # - When `allowed` is a String, === is like (a == b.to_str)
47
- # - When `allowed` is a Symbol, === is (a == b)
48
- self.whitelisted_env_vars.any? {|allowed| allowed === key }
49
- end
50
- end
51
- end
52
-
53
- #####
54
-
55
- def initialize(options)
56
- Squash::Ruby.configure default_options.merge(options)
57
- Squash::Ruby.configure disabled: !Squash::Ruby.configuration(:api_key)
58
- end
59
-
60
- def call(exception, data={})
61
- #NB: You can pass a `user_data` hash to #notify, and most attr's will be placed into a `user_data` field
62
- Squash::Ruby.notify(exception, munge_env(data))
63
- end
64
-
65
- def munge_env(data)
66
- data
67
- end
68
- end
69
- end
70
-
71
7
  # Extend class if you find Rails is being used:
72
- require 'exception_notifier/squash_notifier/rails' if defined? Rails
8
+ require 'exception_notifier/squash_ruby/rails' if defined? Rails
9
+
10
+ require 'exception_notifier/squash_notifier/base'
11
+ require 'exception_notifier/squash_notifier/ruby'
12
+ require 'exception_notifier/squash_notifier/rails'
@@ -8,19 +8,21 @@ module Squash::Ruby
8
8
  params session flash cookies]
9
9
  )
10
10
 
11
- def self.client_name
12
- 'squash-notifier-rails'
13
- end
11
+ class << self
12
+ def client_name
13
+ 'squash-notifier-rails'
14
+ end
14
15
 
15
- def self.failsafe_log(tag, message)
16
- logger = Rails.respond_to?(:logger) ? Rails.logger : RAILS_DEFAULT_LOGGER
17
- if (logger.respond_to?(:tagged))
18
- logger.tagged(tag) { logger.error message }
19
- else
20
- logger.error "[#{tag}]\t#{message}"
16
+ def failsafe_log(tag, message)
17
+ logger = Rails.respond_to?(:logger) ? Rails.logger : RAILS_DEFAULT_LOGGER
18
+ if (logger.respond_to?(:tagged))
19
+ logger.tagged(tag) { logger.error message }
20
+ else
21
+ logger.error "[#{tag}]\t#{message}"
22
+ end
23
+ rescue Object => err
24
+ $stderr.puts "Couldn't write to failsafe log (#{err.to_s}); writing to stderr instead."
25
+ $stderr.puts "#{Time.now.to_s}\t[#{tag}]\t#{message}"
21
26
  end
22
- rescue Object => err
23
- $stderr.puts "Couldn't write to failsafe log (#{err.to_s}); writing to stderr instead."
24
- $stderr.puts "#{Time.now.to_s}\t[#{tag}]\t#{message}"
25
27
  end
26
28
  end
@@ -6,12 +6,12 @@ module Squash::Ruby
6
6
  # These are supposed to contain lambdas/procs that will filter the contents of these arrays before sending them up to the Squash server
7
7
 
8
8
  class << self
9
- private
10
-
11
9
  def client_name
12
10
  'squash-notifier'
13
11
  end
14
12
 
13
+ private
14
+
15
15
  alias :environment_data__original :environment_data
16
16
 
17
17
  def environment_data
@@ -27,6 +27,3 @@ module Squash::Ruby
27
27
  end
28
28
  end
29
29
  end
30
-
31
- # Extend class if you find Rails is being used:
32
- require 'exception_notifier/squash_ruby/rails' if defined? Rails
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exception_notification-squash_notifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1.2
4
+ version: 0.1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Will Robertson
@@ -154,7 +154,9 @@ files:
154
154
  - bin/exception-notifier-squash-notifier
155
155
  - exception-notification-squash-notifier.gemspec
156
156
  - lib/exception_notifier/squash_notifier.rb
157
+ - lib/exception_notifier/squash_notifier/base.rb
157
158
  - lib/exception_notifier/squash_notifier/rails.rb
159
+ - lib/exception_notifier/squash_notifier/ruby.rb
158
160
  - lib/exception_notifier/squash_notifier/version.rb
159
161
  - lib/exception_notifier/squash_ruby.rb
160
162
  - lib/exception_notifier/squash_ruby/rails.rb