undantag 0.0.2 → 0.0.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.
data/README.md CHANGED
@@ -18,7 +18,22 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ In your sinatra application add the following lines
22
+
23
+ configure :production do
24
+ set :show_exceptions, false
25
+ Undantag.configure(api_key: ENV['UNDANTAG_API_KEY']
26
+ github_user: ENV['GITHUB_USER']
27
+ github_repo: ENV['GITHUB_REPO'])
28
+ end
29
+ error do
30
+ if ENV['RACK_ENV'] == 'production'
31
+ require 'undantag'
32
+ resp = Undantag::Notifier.notify(env,
33
+ env['sinatra.error'],
34
+ Rack::Request.new(env))
35
+ end
36
+ end
22
37
 
23
38
  ## Contributing
24
39
 
@@ -1,16 +1,18 @@
1
1
  require 'net/https'
2
+ require 'pp'
2
3
 
3
4
  module Undantag
4
5
  class Notifier
5
6
  URL = "https://undantag.herokuapp.com/exception"
6
- def self.notify request, exception
7
+ def self.notify env, exception, request
7
8
  config_vars = Undantag::Configuration.to_hash
8
9
  unless config_vars[:api_key]
9
10
  raise Undantag::ConfigurationError::NoApiKey
10
11
  end
11
- post_params = config_vars.merge(env: ENV.inspect,
12
- request: request.inspect,
13
- exception: exception.inspect)
12
+ post_params = config_vars.merge(env: PP.pp(env, ""),
13
+ request: PP.pp(request, ""),
14
+ backtrace: exception.backtrace.join("\n"),
15
+ exception: PP.pp(exception, ''))
14
16
 
15
17
  uri = URI(Notifier::URL)
16
18
  http = Net::HTTP.new(uri.host, uri.port)
@@ -1,3 +1,3 @@
1
1
  module Undantag
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -11,28 +11,30 @@ describe Undantag::Notifier do
11
11
  github_user: ENV['GITHUB_USER'],
12
12
  github_repo: ENV['GITHUB_REPO']
13
13
  }
14
+ excpetion = Exception.new
14
15
  before do
15
16
  Undantag::Configuration.stub(:to_hash).and_return(config_vars)
16
17
  Undantag::Configuration.stub(:api_key).and_return(config_vars[:api_key])
17
18
  Undantag.stub(:configure)
19
+ excpetion.set_backtrace("super backtrace")
18
20
  end
19
21
  it 'makes a post to the server when notify is called' do
20
22
  VCR.use_cassette("undantag-server-authorized") do
21
23
  Undantag.configure(config_vars)
22
- Undantag::Notifier.notify(nil, Exception.to_s)
24
+ Undantag::Notifier.notify('env', excpetion, 'req')
23
25
  end
24
26
  end
25
27
  it 'throws Undantag::NotAuthorized when a 401 is returned' do
26
28
  VCR.use_cassette("undantag-server-not-authorized") do
27
29
  wrong = config_vars.merge(api_key: "this isn't right")
28
30
  Undantag::Configuration.stub(:to_hash).and_return(wrong)
29
- expect { Undantag::Notifier.notify(nil, Exception.to_s) }.to raise_error(Undantag::NotAuthorized)
31
+ expect { Undantag::Notifier.notify('env', excpetion, 'req') }.to raise_error(Undantag::NotAuthorized)
30
32
  end
31
33
  end
32
34
  it 'throws "Undantag::ConfigurationError::NoApiKey" if send is called' do
33
35
  #temp hack
34
36
  Undantag::Configuration.stub(:to_hash).and_return({})
35
- expect { Undantag::Notifier.notify(nil, Exception.to_s) }.to raise_error(Undantag::ConfigurationError::NoApiKey)
37
+ expect { Undantag::Notifier.notify('env', excpetion, 'req') }.to raise_error(Undantag::ConfigurationError::NoApiKey)
36
38
  end
37
39
  end
38
40
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: undantag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-20 00:00:00.000000000 Z
12
+ date: 2012-10-21 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Gem for the exception service UNDANTAG
15
15
  email: