raygun4ruby 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa7ba6399d8af368de5bcffc1bf325f62210ac7e
4
- data.tar.gz: e006f29f186d76c1fc5385f51f67c6b4ff8cbb0c
3
+ metadata.gz: b8b2d236a59db88c7bec66e710483eabd9b69a04
4
+ data.tar.gz: bbc45c14ccae5463bd0adb08ebe12ad0530efaee
5
5
  SHA512:
6
- metadata.gz: f4b6bc2069544a6e41f22acc611ddee4583febacbb5815253078b8f89eb7b748968df342e03d929a2dfceadc7ae92d16a6a589bfde1a1bdf1d69976494d7eff5
7
- data.tar.gz: e53d997aa95dfd1bf590074328165c6e1b656f90b78676a23b4edb021a65b90b69f544e28fbdaca8140fa48f58816fce04f1e0a99927a17022aaf3bfe9db455e
6
+ metadata.gz: dd1c79d31a83cd4b862a58d9aced18f6499953178cbc46273259f7dff24422f0a99b99f1dc632cc2cc9f05b276280016bc44b8d51f8a58a4dd1d49fe82e61905
7
+ data.tar.gz: a985d74fc2e49892888f30fd43b8d270bb54532011f276ea727145278425cd5c9b11d6e767ebe9a2bc16083c17d69153ca4e38791ba266e7e5243c274ab807cb
data/lib/raygun.rb CHANGED
@@ -6,6 +6,7 @@ require "logger"
6
6
  require "json"
7
7
  require "socket"
8
8
  require "rack"
9
+ require "ostruct"
9
10
 
10
11
  require "raygun/version"
11
12
  require "raygun/configuration"
@@ -38,6 +39,10 @@ module Raygun
38
39
  @configuration ||= Configuration.new
39
40
  end
40
41
 
42
+ def default_configuration
43
+ configuration.defaults
44
+ end
45
+
41
46
  def track_exception(exception_instance, env = {})
42
47
  if should_report?(exception_instance)
43
48
  log("[Raygun] Tracking Exception...")
@@ -1,35 +1,45 @@
1
1
  module Raygun
2
2
  class Configuration
3
3
 
4
+ def self.config_option(name)
5
+ define_method(name) do
6
+ read_value(name)
7
+ end
8
+
9
+ define_method("#{name}=") do |value|
10
+ set_value(name, value)
11
+ end
12
+ end
13
+
4
14
  # Your Raygun API Key - this can be found on your dashboard at Raygun.io
5
- attr_accessor :api_key
15
+ config_option :api_key
6
16
 
7
17
  # Array of exception classes to ignore
8
- attr_accessor :ignore
18
+ config_option :ignore
9
19
 
10
20
  # Version to use
11
- attr_accessor :version
21
+ config_option :version
12
22
 
13
23
  # Custom Data to send with each exception
14
- attr_accessor :custom_data
24
+ config_option :custom_data
15
25
 
16
26
  # Logger to use when if we find an exception :)
17
- attr_accessor :logger
27
+ config_option :logger
18
28
 
19
- # Should we silence exception reporting (e.g in Development environments)
20
- attr_accessor :silence_reporting
29
+ # Should we actually report exceptions to Raygun? (Usually disabled in Development mode, for instance)
30
+ config_option :enable_reporting
21
31
 
22
32
  # Failsafe logger (for exceptions that happen when we're attempting to report exceptions)
23
- attr_accessor :failsafe_logger
33
+ config_option :failsafe_logger
24
34
 
25
35
  # Which controller method should we call to find out the affected user?
26
- attr_accessor :affected_user_method
36
+ config_option :affected_user_method
27
37
 
28
38
  # Which methods should we try on the affected user object in order to get an identifier
29
- attr_accessor :affected_user_identifier_methods
39
+ config_option :affected_user_identifier_methods
30
40
 
31
41
  # Which parameter keys should we filter out by default?
32
- attr_accessor :filter_parameters
42
+ config_option :filter_parameters
33
43
 
34
44
  # Exception classes to ignore by default
35
45
  IGNORE_DEFAULT = ['ActiveRecord::RecordNotFound',
@@ -42,19 +52,51 @@ module Raygun
42
52
 
43
53
  DEFAULT_FILTER_PARAMETERS = [ :password, :card_number, :cvv ]
44
54
 
55
+ attr_reader :defaults
56
+
45
57
  def initialize
58
+ @config_values = {}
59
+
46
60
  # set default attribute values
47
- @ignore = IGNORE_DEFAULT
48
- @custom_data = {}
49
- @silence_reporting = nil
50
- @affected_user_method = :current_user
51
- @affected_user_identifier_methods = [ :email, :username, :id ]
52
- @filter_parameters = DEFAULT_FILTER_PARAMETERS
61
+ @defaults = OpenStruct.new({
62
+ ignore: IGNORE_DEFAULT,
63
+ custom_data: {},
64
+ enable_reporting: true,
65
+ affected_user_method: :current_user,
66
+ affected_user_identifier_methods: [ :email, :username, :id ],
67
+ filter_parameters: DEFAULT_FILTER_PARAMETERS
68
+ })
53
69
  end
54
70
 
55
71
  def [](key)
56
- send(key)
72
+ read_value(key)
73
+ end
74
+
75
+ def []=(key, value)
76
+ set_value(key, value)
57
77
  end
58
78
 
79
+ def silence_reporting
80
+ !enable_reporting
81
+ end
82
+
83
+ def silence_reporting=(value)
84
+ self.enable_reporting = !value
85
+ end
86
+
87
+ private
88
+
89
+ def read_value(name)
90
+ if @config_values.has_key?(name)
91
+ @config_values[name]
92
+ else
93
+ @defaults.send(name)
94
+ end
95
+ end
96
+
97
+ def set_value(name, value)
98
+ @config_values[name] = value
99
+ end
100
+
59
101
  end
60
102
  end
@@ -19,8 +19,8 @@ class Raygun::Railtie < Rails::Railtie
19
19
  end
20
20
 
21
21
  config.to_prepare do
22
- Raygun.configuration.logger ||= Rails.logger
23
- Raygun.configuration.silence_reporting = !Rails.env.production? if Raygun.configuration.silence_reporting.nil?
22
+ Raygun.default_configuration.logger = Rails.logger
23
+ Raygun.default_configuration.enable_reporting = Rails.env.production?
24
24
  end
25
25
 
26
26
  rake_tasks do
@@ -1,3 +1,3 @@
1
1
  module Raygun
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raygun4ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mindscape
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-05-12 00:00:00.000000000 Z
12
+ date: 2014-05-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty