undantag 0.0.1
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/.gitignore +18 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/fixtures/cassettes/undantag-server-authorized.yml +39 -0
- data/fixtures/cassettes/undantag-server-not-authorized.yml +39 -0
- data/fixtures/cassettes/undantag-server.yml +39 -0
- data/lib/undantag/configuration.rb +10 -0
- data/lib/undantag/exceptions.rb +7 -0
- data/lib/undantag/notifier.rb +21 -0
- data/lib/undantag/version.rb +3 -0
- data/lib/undantag.rb +14 -0
- data/spec/undantag/configuration_spec.rb +18 -0
- data/spec/undantag/notifier_spec.rb +34 -0
- data/spec/undantag_spec.rb +21 -0
- data/spec/vcr_helper.rb +8 -0
- data/undantag.gemspec +19 -0
- metadata +67 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Magnus Hörberg
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Undantag
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'undantag'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install undantag
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://undantag.duh.se/exception
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: api_key=<Undantag API key>&github_user&github_repo&title=test&body=Exception
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- ! '*/*'
|
12
|
+
User-Agent:
|
13
|
+
- Ruby
|
14
|
+
Content-Type:
|
15
|
+
- application/x-www-form-urlencoded
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 502
|
19
|
+
message: Bad Gateway
|
20
|
+
headers:
|
21
|
+
Server:
|
22
|
+
- nginx
|
23
|
+
Date:
|
24
|
+
- Sat, 20 Oct 2012 14:22:00 GMT
|
25
|
+
Content-Type:
|
26
|
+
- text/html
|
27
|
+
Content-Length:
|
28
|
+
- '166'
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
Keep-Alive:
|
32
|
+
- timeout=20
|
33
|
+
body:
|
34
|
+
encoding: US-ASCII
|
35
|
+
string: ! "<html>\r\n<head><title>502 Bad Gateway</title></head>\r\n<body bgcolor=\"white\">\r\n<center><h1>502
|
36
|
+
Bad Gateway</h1></center>\r\n<hr><center>nginx</center>\r\n</body>\r\n</html>\r\n"
|
37
|
+
http_version:
|
38
|
+
recorded_at: Sat, 20 Oct 2012 14:22:00 GMT
|
39
|
+
recorded_with: VCR 2.2.5
|
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://undantag.duh.se/exception
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: api_key=super+seceret+api+key&github_user&github_repo&title=test&body=Exception
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- ! '*/*'
|
12
|
+
User-Agent:
|
13
|
+
- Ruby
|
14
|
+
Content-Type:
|
15
|
+
- application/x-www-form-urlencoded
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 502
|
19
|
+
message: Bad Gateway
|
20
|
+
headers:
|
21
|
+
Server:
|
22
|
+
- nginx
|
23
|
+
Date:
|
24
|
+
- Sat, 20 Oct 2012 14:11:51 GMT
|
25
|
+
Content-Type:
|
26
|
+
- text/html
|
27
|
+
Content-Length:
|
28
|
+
- '166'
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
Keep-Alive:
|
32
|
+
- timeout=20
|
33
|
+
body:
|
34
|
+
encoding: US-ASCII
|
35
|
+
string: ! "<html>\r\n<head><title>502 Bad Gateway</title></head>\r\n<body bgcolor=\"white\">\r\n<center><h1>502
|
36
|
+
Bad Gateway</h1></center>\r\n<hr><center>nginx</center>\r\n</body>\r\n</html>\r\n"
|
37
|
+
http_version:
|
38
|
+
recorded_at: Sat, 20 Oct 2012 14:11:52 GMT
|
39
|
+
recorded_with: VCR 2.2.5
|
@@ -0,0 +1,39 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://undantag.duh.se/exception
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: api_key=super+seceret+api+key&github_user&github_repo&title=test&body=Exception
|
9
|
+
headers:
|
10
|
+
Accept:
|
11
|
+
- ! '*/*'
|
12
|
+
User-Agent:
|
13
|
+
- Ruby
|
14
|
+
Content-Type:
|
15
|
+
- application/x-www-form-urlencoded
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 502
|
19
|
+
message: Bad Gateway
|
20
|
+
headers:
|
21
|
+
Server:
|
22
|
+
- nginx
|
23
|
+
Date:
|
24
|
+
- Sat, 20 Oct 2012 14:05:17 GMT
|
25
|
+
Content-Type:
|
26
|
+
- text/html
|
27
|
+
Content-Length:
|
28
|
+
- '166'
|
29
|
+
Connection:
|
30
|
+
- keep-alive
|
31
|
+
Keep-Alive:
|
32
|
+
- timeout=20
|
33
|
+
body:
|
34
|
+
encoding: US-ASCII
|
35
|
+
string: ! "<html>\r\n<head><title>502 Bad Gateway</title></head>\r\n<body bgcolor=\"white\">\r\n<center><h1>502
|
36
|
+
Bad Gateway</h1></center>\r\n<hr><center>nginx</center>\r\n</body>\r\n</html>\r\n"
|
37
|
+
http_version:
|
38
|
+
recorded_at: Sat, 20 Oct 2012 14:05:19 GMT
|
39
|
+
recorded_with: VCR 2.2.5
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Undantag
|
2
|
+
class Notifier
|
3
|
+
URL = "https://undantag.herokuapp.com/exception"
|
4
|
+
def self.notify request, exception
|
5
|
+
unless Undantag::Configuration.api_key
|
6
|
+
raise Undantag::ConfigurationError::NoApiKey
|
7
|
+
end
|
8
|
+
uri = URI(Notifier::URL)
|
9
|
+
key = Undantag::Configuration.api_key
|
10
|
+
post_params = Undantag::Configuration.to_hash.merge(env: ENV,
|
11
|
+
request: request,
|
12
|
+
exception: exception)
|
13
|
+
|
14
|
+
resp = Net::HTTP.post_form(uri, post_params)
|
15
|
+
case resp.code
|
16
|
+
when "401"
|
17
|
+
raise Undantag::NotAuthorized
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/undantag.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "undantag/version"
|
2
|
+
require "undantag/exceptions"
|
3
|
+
require "undantag/configuration"
|
4
|
+
require "undantag/notifier"
|
5
|
+
require 'net/https'
|
6
|
+
require 'uri'
|
7
|
+
|
8
|
+
module Undantag
|
9
|
+
def self.configure(params)
|
10
|
+
Undantag::Configuration.api_key = params[:api_key]
|
11
|
+
Undantag::Configuration.github_user = params[:github_user]
|
12
|
+
Undantag::Configuration.github_repo = params[:github_repo]
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require './lib/undantag/configuration'
|
3
|
+
|
4
|
+
describe Undantag::Configuration do
|
5
|
+
it 'returns a hash when to_hash is called' do
|
6
|
+
|
7
|
+
Undantag::Configuration.api_key = 'api_key'
|
8
|
+
Undantag::Configuration.github_user = 'github_user'
|
9
|
+
Undantag::Configuration.github_repo = 'github_repo'
|
10
|
+
expected_result = {
|
11
|
+
api_key: 'api_key',
|
12
|
+
github_user: 'github_user',
|
13
|
+
github_repo: 'github_repo'
|
14
|
+
}
|
15
|
+
Undantag::Configuration.to_hash.should == expected_result
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require 'vcr'
|
3
|
+
require 'vcr_helper'
|
4
|
+
require './lib/undantag/exceptions'
|
5
|
+
require './lib/undantag/notifier'
|
6
|
+
|
7
|
+
class Undantag::Configuration; end
|
8
|
+
|
9
|
+
describe Undantag::Notifier do
|
10
|
+
before do
|
11
|
+
Undantag.stub(:configure)
|
12
|
+
Undantag::Configuration.stub(:api_key)
|
13
|
+
end
|
14
|
+
it 'makes a post to the server when notify is called' do
|
15
|
+
VCR.use_cassette("undantag-server-authorized") do
|
16
|
+
Undantag.configure(api_key: ENV['UNDANTAG_API_KEY'],
|
17
|
+
github_user: ENV['GITHUB_USER'],
|
18
|
+
github_repo: ENV['GITHUB_REPO'])
|
19
|
+
Undantag::Notifier.notify(nil, Exception.to_s)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
it 'throws Undantag::NotAuthorized when a 401 is returned' do
|
23
|
+
VCR.use_cassette("undantag-server-not-authorized") do
|
24
|
+
Undantag.configure api_key: ENV['UNDANTAG_API_KEY']
|
25
|
+
expect { Undantag::Notifier.notify(nil, Exception.to_s) }.to raise_error(Undantag::NotAuthorized)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
it 'throws "Undantag::ConfigurationError::NoApiKey" if send is called' do
|
29
|
+
#temp hack
|
30
|
+
Undantag.configure api_key: nil
|
31
|
+
expect { Undantag::Notifier.notify(nil, Exception.to_s) }.to raise_error(Undantag::ConfigurationError::NoApiKey)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rspec'
|
2
|
+
require './lib/undantag'
|
3
|
+
|
4
|
+
describe Undantag do
|
5
|
+
let api_key = 'super seceret api key'
|
6
|
+
let github_user = 'octocat'
|
7
|
+
let github_repo = 'testify'
|
8
|
+
|
9
|
+
it 'can be configured with a api key' do
|
10
|
+
Undantag.configure(api_key: api_key)
|
11
|
+
Undantag::Configuration.api_key.should == api_key
|
12
|
+
end
|
13
|
+
it 'can be configured with a github user' do
|
14
|
+
Undantag.configure(github_user: github_user)
|
15
|
+
Undantag::Configuration.github_user.should == github_user
|
16
|
+
end
|
17
|
+
it 'can be configured with a github repo' do
|
18
|
+
Undantag.configure(github_repo: github_repo)
|
19
|
+
Undantag::Configuration.github_repo.should == github_repo
|
20
|
+
end
|
21
|
+
end
|
data/spec/vcr_helper.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
VCR.configure do |config|
|
2
|
+
config.cassette_library_dir = "fixtures/cassettes"
|
3
|
+
config.hook_into :webmock
|
4
|
+
config.filter_sensitive_data("<Undantag API key>") { ENV['UNDANTAG_API_KEY'] }
|
5
|
+
config.filter_sensitive_data("<GitHub user>") { ENV['GITHUB_USER'] }
|
6
|
+
config.filter_sensitive_data("<GitHub repo>") { ENV['GITHUB_REPO'] }
|
7
|
+
end
|
8
|
+
|
data/undantag.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'undantag/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "undantag"
|
8
|
+
gem.version = Undantag::VERSION
|
9
|
+
gem.authors = ["Magnus Hörberg"]
|
10
|
+
gem.email = ["magnus.hoerberg@gmail.com"]
|
11
|
+
gem.description = %q{Gem for the exception service UNDANTAG}
|
12
|
+
gem.summary = %q{After configuration posts exceptions to https://undantag.herokuapp.com/exception}
|
13
|
+
gem.homepage = "https://undantag.herokuapp.com"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: undantag
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Magnus Hörberg
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-20 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Gem for the exception service UNDANTAG
|
15
|
+
email:
|
16
|
+
- magnus.hoerberg@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- Gemfile
|
23
|
+
- LICENSE.txt
|
24
|
+
- README.md
|
25
|
+
- Rakefile
|
26
|
+
- fixtures/cassettes/undantag-server-authorized.yml
|
27
|
+
- fixtures/cassettes/undantag-server-not-authorized.yml
|
28
|
+
- fixtures/cassettes/undantag-server.yml
|
29
|
+
- lib/undantag.rb
|
30
|
+
- lib/undantag/configuration.rb
|
31
|
+
- lib/undantag/exceptions.rb
|
32
|
+
- lib/undantag/notifier.rb
|
33
|
+
- lib/undantag/version.rb
|
34
|
+
- spec/undantag/configuration_spec.rb
|
35
|
+
- spec/undantag/notifier_spec.rb
|
36
|
+
- spec/undantag_spec.rb
|
37
|
+
- spec/vcr_helper.rb
|
38
|
+
- undantag.gemspec
|
39
|
+
homepage: https://undantag.herokuapp.com
|
40
|
+
licenses: []
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
none: false
|
47
|
+
requirements:
|
48
|
+
- - ! '>='
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '0'
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
requirements: []
|
58
|
+
rubyforge_project:
|
59
|
+
rubygems_version: 1.8.15
|
60
|
+
signing_key:
|
61
|
+
specification_version: 3
|
62
|
+
summary: After configuration posts exceptions to https://undantag.herokuapp.com/exception
|
63
|
+
test_files:
|
64
|
+
- spec/undantag/configuration_spec.rb
|
65
|
+
- spec/undantag/notifier_spec.rb
|
66
|
+
- spec/undantag_spec.rb
|
67
|
+
- spec/vcr_helper.rb
|