rnotifier 0.0.8 → 0.0.9

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: 50c10d0bf67e250e5ca27a71467daca164c6bdb3
4
- data.tar.gz: 7326f599dc1a0d6bdf85a51253bcf3c0931f3e96
3
+ metadata.gz: 67a2b60f6bf080a8814c12e59719bab1e080fe39
4
+ data.tar.gz: 96aeb8786e52e6fd723cb9528e6bfd78ffb0cd6f
5
5
  SHA512:
6
- metadata.gz: 94f5b55b64acfff14967da646858a232457cbd0008dbf29092b95b2c0d9b273e7420a1c087a25eacc85ef186c871bd8c88cda0cc8b8eb3263eeb053695823302
7
- data.tar.gz: 8fcfb420fd001c7a3769bcf2148b586f41ed97ed6f47553a926e1e2fb4304d63936d25274e224b4c8d96cd41049588193a75a8d822a79b5aec5d26d2ddef6cf1
6
+ metadata.gz: 8f65adfbbd5788e39ea264a5d3b84b2f0759f916ffcb002b04ac2c4ef975295b7511ca85fd126d5d2a93b30ea4d68985aaa5eea73fa765c1656b6472124e551b
7
+ data.tar.gz: 9d0f025c02c33b4558271c27838575320b48052e7e31284c561c56e7b2e5d77bc3d0395012b44f6052d02e7b09e291841f99613fcf103087d99f1fa9d2927025
data/README.md CHANGED
@@ -26,6 +26,10 @@ rnotifier install 'API-KEY' # This will create 'config/rnotifier.yaml' file.
26
26
  - capture_code: true #Default false
27
27
  - api_host: 'http://yourapp.com' #Default http://rnotifier.com
28
28
 
29
+ ### To test config
30
+
31
+ rnotifier test #This will send test exception to rnotifier.
32
+
29
33
  ## Contributing
30
34
 
31
35
  1. Fork it
data/bin/rnotifier CHANGED
@@ -11,13 +11,15 @@ test #Test rnotifier configuration is correct and send test exception.
11
11
  install api-key [environments] #Create config/rnotifier.yaml with api_key and enabled for supplied environments.environments are optionbal, default is production.
12
12
  }
13
13
  when 'test'
14
+ #$:.unshift(File.dirname(__FILE__) + '/../lib/')
15
+ require 'rack'
14
16
  require 'rnotifier'
15
-
16
- Rnotofier::Config.load_config('config/rnotifier.yml')
17
- if Rnotofier::Config.valid?
18
- #NOTE: Add test code
17
+ require 'rnotifier/config_test.rb'
18
+ Rnotifier.load_config('config/rnotifier.yaml')
19
+ if Rnotifier::Config.valid?
20
+ Rnotifier::ConfigTest.test
19
21
  else
20
- puts 'Configuration is invalid. Check api key'
22
+ puts 'Configuration is invalid. Check api key or config'
21
23
  end
22
24
  when 'install'
23
25
  if (api_key = ARGV[1]).nil?
@@ -0,0 +1,19 @@
1
+ module Rnotifier
2
+ class ConfigTest
3
+ class TestException <StandardError;
4
+ end
5
+
6
+ def self.test
7
+ begin
8
+ raise TestException.new('Test exception')
9
+ rescue Exception => e
10
+ if Rnotifier::ExceptionData.new(e, {}).notify
11
+ puts "Test Exception sent. Login to rnotifier.com and checkout."
12
+ else
13
+ puts "Problem sending exception to rnotifier.com. Check your API key or config."
14
+ end
15
+ end
16
+ end
17
+
18
+ end
19
+ end
@@ -11,7 +11,6 @@ module Rnotifier
11
11
  def find(filename, line_no, wrap_size = 1)
12
12
  s_range = [line_no - wrap_size, 1].max - 1
13
13
  e_range = line_no + wrap_size - 1
14
- #s_range, e_range = [ (line_no - wrap_size) > 0 ? line_no - wrap_size : 0, line_no + wrap_size]
15
14
  code = [s_range]
16
15
 
17
16
  begin
@@ -16,34 +16,28 @@ module Rnotifier
16
16
  return unless Config.valid?
17
17
  return if Config.ignore_exceptions && Config.ignore_exceptions.include?(exception.class.to_s)
18
18
 
19
-
20
19
  begin
21
- data = if options[:type] == :rack
22
- self.rack_exception_data
23
- else
24
- {:exception => self.exception_data, :extra => self.env }
25
- end
20
+ data = options[:type] == :rack ? self.rack_exception_data : {:extra => self.env }
26
21
 
27
- data[:exception][:code] = ExceptionCode.get(data[:exception][:backtrace]) if Config.capture_code
22
+ data[:app_env] = Rnotifier::Config.app_env
23
+ data[:occurred_at] = Time.now.to_s
24
+ data[:exception] = self.exception_data
28
25
  data[:context_data] = Thread.current[:rnotifier_context] if Thread.current[:rnotifier_context]
29
26
  data[:data_from] = options[:type]
30
27
  data[:rnotifier_client] = Config::CLIENT
31
28
 
32
- Notifier.send(data)
29
+ return Notifier.send(data)
33
30
  rescue Exception => e
34
31
  Rlogger.error("[NOTIFY] #{e.message}")
35
32
  Rlogger.error("[NOTIFY] #{e.backtrace}")
36
33
  ensure
37
34
  Rnotifier.clear_context
38
35
  end
36
+ false
39
37
  end
40
38
 
41
39
  def rack_exception_data
42
- data = {
43
- :occurred_at => Time.now.to_s,
44
- :app_env => Rnotifier::Config.app_env,
45
- :exception => self.exception_data
46
- }
40
+ data = {}
47
41
  data[:request] = {
48
42
  :url => request.url,
49
43
  :referer_url => request.referer,
@@ -58,12 +52,14 @@ module Rnotifier
58
52
  end
59
53
 
60
54
  def exception_data
61
- {
55
+ e_data = {
62
56
  :class_name => exception.class.to_s,
63
57
  :message => exception.message,
64
58
  :backtrace => exception.backtrace,
65
59
  :fingerprint => (self.fingerprint rescue nil)
66
60
  }
61
+ e_data[:code] = ExceptionCode.get(e_data[:backtrace]) if Config.capture_code
62
+ e_data
67
63
  end
68
64
 
69
65
  def fingerprint
@@ -17,7 +17,9 @@ module Rnotifier
17
17
  req.body = MultiJson.dump(data)
18
18
  end
19
19
 
20
- Rlogger.error("[RNOTIFIER SERVER] Response Status:#{response.status}") unless response.status == 200
20
+ return true if response.status == 200
21
+ Rlogger.error("[RNOTIFIER SERVER] Response Status:#{response.status}")
22
+ false
21
23
  end
22
24
  end
23
25
  end
@@ -1,3 +1,3 @@
1
1
  module Rnotifier
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -36,7 +36,7 @@ describe Rnotifier::ExceptionData do
36
36
  expect(request_data[:headers]).to eq headers
37
37
  expect(request_data[:params]).to eq({'foo' => 'bar', 'quux' => 'bla'})
38
38
 
39
- exception_data = data[:exception]
39
+ exception_data = e_data.exception_data
40
40
  expect(exception_data[:class_name]).to eq @exception.class.to_s
41
41
  expect(exception_data[:message]).to eq @exception.message
42
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rnotifier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jiren Patel
@@ -126,6 +126,7 @@ files:
126
126
  - lib/generators/rnotifier/templates/initializer.rb
127
127
  - lib/rnotifier.rb
128
128
  - lib/rnotifier/config.rb
129
+ - lib/rnotifier/config_test.rb
129
130
  - lib/rnotifier/exception_code.rb
130
131
  - lib/rnotifier/exception_data.rb
131
132
  - lib/rnotifier/notifier.rb