limbo 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 +4 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +21 -0
- data/lib/limbo/client.rb +54 -0
- data/lib/limbo/rails/data.rb +35 -0
- data/lib/limbo/rails/parameter_filter.rb +14 -0
- data/lib/limbo/rails/request.rb +13 -0
- data/lib/limbo/version.rb +3 -0
- data/lib/limbo.rb +24 -0
- data/limbo.gemspec +22 -0
- data/spec/cassettes/limbo_client_post.yml +40 -0
- data/spec/cassettes/limbo_client_post_invalid_uri.yml +36 -0
- data/spec/cassettes/limbo_post.yml +40 -0
- data/spec/cassettes/limbo_rails_post.yml +40 -0
- data/spec/limbo/client_spec.rb +47 -0
- data/spec/limbo/rails/data_spec.rb +68 -0
- data/spec/limbo/rails/parameter_filter_spec.rb +24 -0
- data/spec/limbo/rails/request_spec.rb +17 -0
- data/spec/limbo_spec.rb +35 -0
- data/spec/spec_helper.rb +35 -0
- metadata +141 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Anders Carlsson and Anders Törnqvist
|
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
|
+
# Limbo
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'limbo'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install limbo
|
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,21 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
|
5
|
+
desc "Run specs"
|
6
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
7
|
+
t.fail_on_error = true
|
8
|
+
t.verbose = true
|
9
|
+
t.rspec_opts ||= []
|
10
|
+
t.rspec_opts << "-r ./spec/spec_helper"
|
11
|
+
t.rspec_opts << "--color"
|
12
|
+
t.rspec_opts << "-fd"
|
13
|
+
end
|
14
|
+
|
15
|
+
task default: :spec
|
16
|
+
task test: :spec
|
17
|
+
|
18
|
+
desc "open console (require limbo)"
|
19
|
+
task :c do
|
20
|
+
system "irb -I lib -r limbo"
|
21
|
+
end
|
data/lib/limbo/client.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
module Limbo
|
5
|
+
class Client
|
6
|
+
def self.post(hash)
|
7
|
+
new(hash).post
|
8
|
+
end
|
9
|
+
|
10
|
+
def valid_data?
|
11
|
+
@valid_data
|
12
|
+
end
|
13
|
+
|
14
|
+
def posted?
|
15
|
+
200 == response.code.to_i
|
16
|
+
end
|
17
|
+
|
18
|
+
def response
|
19
|
+
@response
|
20
|
+
end
|
21
|
+
|
22
|
+
def post
|
23
|
+
headers = { "X-LIMBO-KEY" => Limbo.key,
|
24
|
+
"content-type" => "application/json"}
|
25
|
+
path = '/log'
|
26
|
+
request = Net::HTTP::Post.new(path, headers)
|
27
|
+
|
28
|
+
uri = URI(Limbo.uri)
|
29
|
+
port = uri.port || 80
|
30
|
+
@response = Net::HTTP.start(uri.host, port) do |http|
|
31
|
+
http.open_timeout = 5
|
32
|
+
http.request(request, body)
|
33
|
+
end
|
34
|
+
|
35
|
+
self
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def body
|
41
|
+
begin
|
42
|
+
JSON.generate(@body)
|
43
|
+
rescue JSON::GeneratorError
|
44
|
+
@valid_data = false
|
45
|
+
'{"client-error": "error generating JSON"}'
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def initialize(body)
|
50
|
+
@body = body
|
51
|
+
@valid_data = true
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'limbo/rails/parameter_filter'
|
2
|
+
require 'limbo/rails/request'
|
3
|
+
|
4
|
+
module Limbo
|
5
|
+
module Rails
|
6
|
+
class Data
|
7
|
+
def initialize(hash)
|
8
|
+
fail ArgumentError, 'Argument must be a hash' unless hash.is_a?(Hash)
|
9
|
+
|
10
|
+
message = 'Required keys are: :params, :session, :exception, :request'
|
11
|
+
|
12
|
+
@params = hash.delete(:params) { fail ArgumentError, message }
|
13
|
+
@session = hash.delete(:session) { fail ArgumentError, message }
|
14
|
+
@exception = hash.delete(:exception) { fail ArgumentError, message }
|
15
|
+
request = hash.delete(:request) { fail ArgumentError, message }
|
16
|
+
@request = Limbo::Rails::Request.new(request)
|
17
|
+
|
18
|
+
@hash = hash
|
19
|
+
end
|
20
|
+
|
21
|
+
def transform
|
22
|
+
{
|
23
|
+
controller: @params[:controller],
|
24
|
+
action: @params[:action],
|
25
|
+
parameters: Limbo::Rails::ParameterFilter.filter(@params),
|
26
|
+
url: @request.url,
|
27
|
+
session: Limbo::Rails::ParameterFilter.filter(@session.to_hash),
|
28
|
+
# TODO: We must filter this better.
|
29
|
+
# request_env: Limbo::RailsParameterFilter.filter(@request.env)
|
30
|
+
backtrace: @exception.backtrace
|
31
|
+
}.merge(@hash)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Limbo
|
2
|
+
module Rails
|
3
|
+
class ParameterFilter
|
4
|
+
def self.filter(hash)
|
5
|
+
if hash.is_a?(Hash)
|
6
|
+
filter = ::Rails.application.config.filter_parameters
|
7
|
+
ActionDispatch::Http::ParameterFilter.new(filter).filter(hash)
|
8
|
+
else
|
9
|
+
hash
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/limbo.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require "limbo/version"
|
2
|
+
require "limbo/rails/data"
|
3
|
+
require "limbo/client"
|
4
|
+
|
5
|
+
module Limbo
|
6
|
+
|
7
|
+
class << self
|
8
|
+
attr_accessor :uri, :key
|
9
|
+
|
10
|
+
def configure
|
11
|
+
yield self
|
12
|
+
end
|
13
|
+
|
14
|
+
def rails_post(hash)
|
15
|
+
transformed_hash = Rails::Data.new(hash).transform
|
16
|
+
post(transformed_hash)
|
17
|
+
end
|
18
|
+
|
19
|
+
def post(hash)
|
20
|
+
Client.post(hash)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
data/limbo.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/limbo/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Anders Carlsson and Anders Törnqvist"]
|
6
|
+
gem.email = ["dev+ankor+unders@elabs.se"]
|
7
|
+
gem.description = %q{Limbo exception client.}
|
8
|
+
gem.summary = %q{Limbo client post exception to the Limbo exception service.}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "limbo"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Limbo::VERSION
|
17
|
+
|
18
|
+
gem.add_development_dependency "rspec"
|
19
|
+
gem.add_development_dependency "vcr"
|
20
|
+
gem.add_development_dependency "fakeweb"
|
21
|
+
gem.add_development_dependency "rails"
|
22
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://limbo-listener-staging.herokuapp.com/log
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: ! '{"data":"info"}'
|
9
|
+
headers:
|
10
|
+
x-limbo-key:
|
11
|
+
- test-key
|
12
|
+
content-type:
|
13
|
+
- application/json
|
14
|
+
accept:
|
15
|
+
- ! '*/*'
|
16
|
+
user-agent:
|
17
|
+
- Ruby
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
content-type:
|
24
|
+
- text/html;charset=utf-8
|
25
|
+
server:
|
26
|
+
- thin 1.3.1 codename Triple Espresso
|
27
|
+
x-frame-options:
|
28
|
+
- sameorigin
|
29
|
+
x-xss-protection:
|
30
|
+
- 1; mode=block
|
31
|
+
content-length:
|
32
|
+
- '0'
|
33
|
+
connection:
|
34
|
+
- keep-alive
|
35
|
+
body:
|
36
|
+
encoding: US-ASCII
|
37
|
+
string: ''
|
38
|
+
http_version: '1.1'
|
39
|
+
recorded_at: Fri, 29 Jun 2012 15:17:12 GMT
|
40
|
+
recorded_with: VCR 2.2.2
|
@@ -0,0 +1,36 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://example.com/log
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: ! '{"data":"info"}'
|
9
|
+
headers:
|
10
|
+
x-limbo-key:
|
11
|
+
- test-key
|
12
|
+
content-type:
|
13
|
+
- application/json
|
14
|
+
accept:
|
15
|
+
- ! '*/*'
|
16
|
+
user-agent:
|
17
|
+
- Ruby
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 302
|
21
|
+
message: Found
|
22
|
+
headers:
|
23
|
+
location:
|
24
|
+
- http://www.iana.org/domains/example/
|
25
|
+
server:
|
26
|
+
- BigIP
|
27
|
+
connection:
|
28
|
+
- Keep-Alive
|
29
|
+
content-length:
|
30
|
+
- '0'
|
31
|
+
body:
|
32
|
+
encoding: US-ASCII
|
33
|
+
string: ''
|
34
|
+
http_version: '1.0'
|
35
|
+
recorded_at: Fri, 29 Jun 2012 15:17:12 GMT
|
36
|
+
recorded_with: VCR 2.2.2
|
@@ -0,0 +1,40 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://limbo-listener-staging.herokuapp.com/log
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: ! '{"a":"b"}'
|
9
|
+
headers:
|
10
|
+
x-limbo-key:
|
11
|
+
- test-key
|
12
|
+
content-type:
|
13
|
+
- application/json
|
14
|
+
accept:
|
15
|
+
- ! '*/*'
|
16
|
+
user-agent:
|
17
|
+
- Ruby
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
content-type:
|
24
|
+
- text/html;charset=utf-8
|
25
|
+
server:
|
26
|
+
- thin 1.3.1 codename Triple Espresso
|
27
|
+
x-frame-options:
|
28
|
+
- sameorigin
|
29
|
+
x-xss-protection:
|
30
|
+
- 1; mode=block
|
31
|
+
content-length:
|
32
|
+
- '0'
|
33
|
+
connection:
|
34
|
+
- keep-alive
|
35
|
+
body:
|
36
|
+
encoding: US-ASCII
|
37
|
+
string: ''
|
38
|
+
http_version: '1.1'
|
39
|
+
recorded_at: Fri, 29 Jun 2012 15:17:11 GMT
|
40
|
+
recorded_with: VCR 2.2.2
|
@@ -0,0 +1,40 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://limbo-listener-staging.herokuapp.com/log
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: ! '{"a":"b"}'
|
9
|
+
headers:
|
10
|
+
x-limbo-key:
|
11
|
+
- test-key
|
12
|
+
content-type:
|
13
|
+
- application/json
|
14
|
+
accept:
|
15
|
+
- ! '*/*'
|
16
|
+
user-agent:
|
17
|
+
- Ruby
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
content-type:
|
24
|
+
- text/html;charset=utf-8
|
25
|
+
server:
|
26
|
+
- thin 1.3.1 codename Triple Espresso
|
27
|
+
x-frame-options:
|
28
|
+
- sameorigin
|
29
|
+
x-xss-protection:
|
30
|
+
- 1; mode=block
|
31
|
+
content-length:
|
32
|
+
- '0'
|
33
|
+
connection:
|
34
|
+
- keep-alive
|
35
|
+
body:
|
36
|
+
encoding: US-ASCII
|
37
|
+
string: ''
|
38
|
+
http_version: '1.1'
|
39
|
+
recorded_at: Fri, 29 Jun 2012 15:17:12 GMT
|
40
|
+
recorded_with: VCR 2.2.2
|
@@ -0,0 +1,47 @@
|
|
1
|
+
describe Limbo::Client do
|
2
|
+
use_vcr_cassette 'limbo.client.post'
|
3
|
+
|
4
|
+
before do
|
5
|
+
Limbo.configure do |config|
|
6
|
+
config.key = "test-key"
|
7
|
+
config.uri = "http://limbo-listener-staging.herokuapp.com"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe ".post" do
|
12
|
+
it "returns a client instance" do
|
13
|
+
Limbo::Client.post(data: "info").should be_an_instance_of(Limbo::Client)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "#valid_data?" do
|
18
|
+
|
19
|
+
context "valid data" do
|
20
|
+
specify { Limbo::Client.post(data: "info").should be_valid_data }
|
21
|
+
end
|
22
|
+
|
23
|
+
context "invalid data" do
|
24
|
+
use_vcr_cassette 'limbo.client.post.invalid_data'
|
25
|
+
|
26
|
+
specify { Limbo::Client.post("info").should_not be_valid_data }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "#posted?" do
|
31
|
+
context "valid uri" do
|
32
|
+
specify { Limbo::Client.post(data: "info").should be_posted }
|
33
|
+
end
|
34
|
+
|
35
|
+
context "invalid uri" do
|
36
|
+
use_vcr_cassette 'limbo.client.post.invalid_uri'
|
37
|
+
|
38
|
+
before do
|
39
|
+
Limbo.configure do |config|
|
40
|
+
config.uri = "http://example.com"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
specify { Limbo::Client.post(data: "info").should_not be_posted }
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
describe Limbo::Rails::Data do
|
2
|
+
describe ".new" do
|
3
|
+
context "non-hash argument" do
|
4
|
+
it "raises ArgumentError" do
|
5
|
+
expect { Limbo::Rails::Data.new(nil) }.to raise_error ArgumentError
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
context "missing required key" do
|
10
|
+
it "raises ArgumentError" do
|
11
|
+
hash = { params: {}, session: {}, exception: {} }
|
12
|
+
|
13
|
+
expect { Limbo::Rails::Data.new(hash) }.to raise_error ArgumentError
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context "valid hash argument" do
|
18
|
+
it "returns an instance" do
|
19
|
+
hash = { params: {}, session: {}, exception: {}, request: {} }
|
20
|
+
|
21
|
+
rails_data = Limbo::Rails::Data.new(hash)
|
22
|
+
rails_data.should be_instance_of(Limbo::Rails::Data)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "#transform" do
|
28
|
+
let(:exception) { double("exception") }
|
29
|
+
let(:hash) do
|
30
|
+
{
|
31
|
+
params: { controller: "c", action: "a", password: "pass"},
|
32
|
+
session: { user_id: "2"},
|
33
|
+
exception: exception,
|
34
|
+
request: request,
|
35
|
+
custom: "I am added by the user"
|
36
|
+
}
|
37
|
+
end
|
38
|
+
before { exception.should_receive(:backtrace).exactly(1) { "backtrace" } }
|
39
|
+
|
40
|
+
it "returns a transformed hash" do
|
41
|
+
transformed_hash = Limbo::Rails::Data.new(hash).transform
|
42
|
+
transformed_hash[:controller].should eq("c")
|
43
|
+
transformed_hash[:action].should eq("a")
|
44
|
+
transformed_hash[:parameters].should eq({ controller: "c",
|
45
|
+
action: "a",
|
46
|
+
password: "pass"})
|
47
|
+
transformed_hash[:url].should eq("http://example.com/blog")
|
48
|
+
transformed_hash[:session].should eq({user_id: "2"})
|
49
|
+
transformed_hash[:backtrace].should eq("backtrace")
|
50
|
+
end
|
51
|
+
|
52
|
+
it "applies filter on some keys" do
|
53
|
+
Rails.application.config.filter_parameters = [:password, :user_id]
|
54
|
+
|
55
|
+
transformed_hash = Limbo::Rails::Data.new(hash).transform
|
56
|
+
transformed_hash[:parameters].should eq({ controller: "c",
|
57
|
+
action: "a",
|
58
|
+
password: "[FILTERED]" })
|
59
|
+
transformed_hash[:session].should eq({ user_id: "[FILTERED]" })
|
60
|
+
end
|
61
|
+
|
62
|
+
it "return parameters added by user" do
|
63
|
+
transformed_hash = Limbo::Rails::Data.new(hash).transform
|
64
|
+
transformed_hash[:custom].should eq("I am added by the user")
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
describe Limbo::Rails::ParameterFilter do
|
2
|
+
before do
|
3
|
+
Rails.application.config.filter_parameters = [:password, :secret]
|
4
|
+
end
|
5
|
+
|
6
|
+
describe ".filter" do
|
7
|
+
context "is a hash" do
|
8
|
+
it "filters specified parameters" do
|
9
|
+
hash = { password: "secret", other: "visible", secret: "d" }
|
10
|
+
filtered_hash = Limbo::Rails::ParameterFilter.filter(hash)
|
11
|
+
filtered_hash[:password].should == "[FILTERED]"
|
12
|
+
filtered_hash[:secret].should == "[FILTERED]"
|
13
|
+
filtered_hash[:other].should == "visible"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
context "not a hash" do
|
18
|
+
it "returns the object" do
|
19
|
+
Limbo::Rails::ParameterFilter.filter("test").should == "test"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
describe Limbo::Rails::Request do
|
2
|
+
describe "#url" do
|
3
|
+
context "URL with a standard port" do
|
4
|
+
it "returns a formatted URL without port" do
|
5
|
+
rails_request = Limbo::Rails::Request.new(request(port: 80))
|
6
|
+
rails_request.url.should == "http://example.com/blog"
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
context "URL with non-standard port" do
|
11
|
+
it "returns a formatted URL with the port included" do
|
12
|
+
rails_request = Limbo::Rails::Request.new(request(port: 1337))
|
13
|
+
rails_request.url.should == "http://example.com:1337/blog"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/spec/limbo_spec.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
describe Limbo do
|
2
|
+
before do
|
3
|
+
Limbo.configure do |config|
|
4
|
+
config.key = "test-key"
|
5
|
+
config.uri = "http://limbo-listener-staging.herokuapp.com"
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
describe ".post" do
|
10
|
+
use_vcr_cassette 'limbo.post'
|
11
|
+
|
12
|
+
it "returns a valid Client object" do
|
13
|
+
client = Limbo.post(a: "b")
|
14
|
+
client.should be_valid_data
|
15
|
+
client.should be_posted
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
describe ".rails_post" do
|
20
|
+
use_vcr_cassette 'limbo.rails_post'
|
21
|
+
|
22
|
+
before do
|
23
|
+
rails_data = double("rails_data")
|
24
|
+
rails_data.should_receive(:transform).and_return({ a: "b" })
|
25
|
+
Limbo::Rails::Data.stub(:new).and_return(rails_data)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "returns a valid Client object" do
|
29
|
+
client = Limbo.rails_post(a: "b")
|
30
|
+
client.should be_valid_data
|
31
|
+
client.should be_posted
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'limbo'
|
2
|
+
require 'rails/all'
|
3
|
+
require 'vcr'
|
4
|
+
|
5
|
+
module Dummy
|
6
|
+
class Application < Rails::Application
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
Dummy::Application.configure do
|
11
|
+
config.active_support.deprecation = :log
|
12
|
+
end
|
13
|
+
|
14
|
+
Dummy::Application.initialize!
|
15
|
+
|
16
|
+
RSpec.configure do |config|
|
17
|
+
config.fail_fast = true
|
18
|
+
config.extend VCR::RSpec::Macros
|
19
|
+
end
|
20
|
+
|
21
|
+
VCR.configure do |config|
|
22
|
+
config.cassette_library_dir = 'spec/cassettes'
|
23
|
+
config.hook_into :fakeweb
|
24
|
+
end
|
25
|
+
|
26
|
+
def request(options = {})
|
27
|
+
port = options.fetch(:port) { 80 }
|
28
|
+
env = {
|
29
|
+
'HTTP_HOST' => "example.com:#{port}",
|
30
|
+
'rack.url_scheme' => 'http',
|
31
|
+
'SCRIPT_NAME' => '',
|
32
|
+
'PATH_INFO' => '/blog'
|
33
|
+
}
|
34
|
+
ActionDispatch::Request.new(env)
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: limbo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Anders Carlsson and Anders Törnqvist
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-07-02 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: vcr
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: fakeweb
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rails
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
description: Limbo exception client.
|
79
|
+
email:
|
80
|
+
- dev+ankor+unders@elabs.se
|
81
|
+
executables: []
|
82
|
+
extensions: []
|
83
|
+
extra_rdoc_files: []
|
84
|
+
files:
|
85
|
+
- .gitignore
|
86
|
+
- Gemfile
|
87
|
+
- LICENSE
|
88
|
+
- README.md
|
89
|
+
- Rakefile
|
90
|
+
- lib/limbo.rb
|
91
|
+
- lib/limbo/client.rb
|
92
|
+
- lib/limbo/rails/data.rb
|
93
|
+
- lib/limbo/rails/parameter_filter.rb
|
94
|
+
- lib/limbo/rails/request.rb
|
95
|
+
- lib/limbo/version.rb
|
96
|
+
- limbo.gemspec
|
97
|
+
- spec/cassettes/limbo_client_post.yml
|
98
|
+
- spec/cassettes/limbo_client_post_invalid_uri.yml
|
99
|
+
- spec/cassettes/limbo_post.yml
|
100
|
+
- spec/cassettes/limbo_rails_post.yml
|
101
|
+
- spec/limbo/client_spec.rb
|
102
|
+
- spec/limbo/rails/data_spec.rb
|
103
|
+
- spec/limbo/rails/parameter_filter_spec.rb
|
104
|
+
- spec/limbo/rails/request_spec.rb
|
105
|
+
- spec/limbo_spec.rb
|
106
|
+
- spec/spec_helper.rb
|
107
|
+
homepage: ''
|
108
|
+
licenses: []
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options: []
|
111
|
+
require_paths:
|
112
|
+
- lib
|
113
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
114
|
+
none: false
|
115
|
+
requirements:
|
116
|
+
- - ! '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
none: false
|
121
|
+
requirements:
|
122
|
+
- - ! '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
requirements: []
|
126
|
+
rubyforge_project:
|
127
|
+
rubygems_version: 1.8.21
|
128
|
+
signing_key:
|
129
|
+
specification_version: 3
|
130
|
+
summary: Limbo client post exception to the Limbo exception service.
|
131
|
+
test_files:
|
132
|
+
- spec/cassettes/limbo_client_post.yml
|
133
|
+
- spec/cassettes/limbo_client_post_invalid_uri.yml
|
134
|
+
- spec/cassettes/limbo_post.yml
|
135
|
+
- spec/cassettes/limbo_rails_post.yml
|
136
|
+
- spec/limbo/client_spec.rb
|
137
|
+
- spec/limbo/rails/data_spec.rb
|
138
|
+
- spec/limbo/rails/parameter_filter_spec.rb
|
139
|
+
- spec/limbo/rails/request_spec.rb
|
140
|
+
- spec/limbo_spec.rb
|
141
|
+
- spec/spec_helper.rb
|