exception_resource 0.0.2 → 0.1.0

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.
@@ -1,3 +1,3 @@
1
1
  module ExceptionResource
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -10,31 +10,27 @@ module ExceptionResource
10
10
  @site
11
11
  end
12
12
 
13
- module Base
14
- def save
15
- url = URI.parse(ExceptionResource.site) rescue nil
16
- return false unless url
13
+ def self.create(exception)
14
+ url = URI.parse(site) rescue nil
15
+ return false unless url
17
16
 
18
- url.path = "/" if url.path.empty?
19
- url.path += "exceptions"
17
+ url.path = "/" if url.path.empty?
18
+ url.path += "exceptions"
20
19
 
21
- if url
22
- response = nil
23
- Net::HTTP.start(url.host, url.port) do |request|
24
- response = request.post(url.request_uri, to_hash.map { |k, v| "#{k}=#{v}" }.join("&"))
25
- end
26
- response.code == "201"
27
- else
28
- false
20
+ if url
21
+ response = nil
22
+ Net::HTTP.start(url.host, url.port) do |request|
23
+ response = request.post(url.request_uri, exception.to_hash.map { |k, v| "#{k}=#{v}" }.join("&"))
29
24
  end
25
+ response.code == "201"
26
+ else
27
+ false
30
28
  end
29
+ end
31
30
 
32
- def save!
33
- save
34
- raise self
35
- end
31
+ def self.create!(exception)
32
+ create(exception)
33
+ raise exception
36
34
  end
37
35
  end
38
36
 
39
- Exception.send(:include, ExceptionResource::Base)
40
-
@@ -8,17 +8,17 @@ describe ExceptionResource do
8
8
  it "should send the exception to configured url" do
9
9
  with_exception do |ex|
10
10
  Artifice.activate_with(ExceptionApp.new) do
11
- ex.save.should == true
11
+ ExceptionResource.create(ex).should == true
12
12
  end
13
13
  end
14
14
  end
15
15
 
16
- it "should re-raise itself" do
16
+ it "should re-raise the exception" do
17
17
  ExceptionResource.site = "http://google.com"
18
18
 
19
19
  with_exception do |ex|
20
20
  Artifice.activate_with(ExceptionApp.new) do
21
- lambda { ex.save! }.should raise_error(ex)
21
+ lambda { ExceptionResource.create!(ex) }.should raise_error(ex)
22
22
  end
23
23
  end
24
24
  end
@@ -28,7 +28,7 @@ describe ExceptionResource do
28
28
  Net::HTTP.should_receive(:post_form).never
29
29
 
30
30
  with_exception do |ex|
31
- ex.save.should == false
31
+ ExceptionResource.create(ex).should == false
32
32
  end
33
33
  end
34
34
 
@@ -37,7 +37,7 @@ describe ExceptionResource do
37
37
 
38
38
  with_exception do |ex|
39
39
  Artifice.activate_with(SiteWithQueryStringApp.new) do
40
- ex.save.should == true
40
+ ExceptionResource.create(ex).should == true
41
41
  end
42
42
  end
43
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exception_resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-07-27 00:00:00.000000000 -03:00
12
+ date: 2011-07-28 00:00:00.000000000 -03:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: exception-hashify
17
- requirement: &2153268440 !ruby/object:Gem::Requirement
17
+ requirement: &2154099280 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 0.0.1
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2153268440
25
+ version_requirements: *2154099280
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rspec
28
- requirement: &2153267940 !ruby/object:Gem::Requirement
28
+ requirement: &2154098780 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 2.6.0
34
34
  type: :development
35
35
  prerelease: false
36
- version_requirements: *2153267940
36
+ version_requirements: *2154098780
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: artifice
39
- requirement: &2153267480 !ruby/object:Gem::Requirement
39
+ requirement: &2154098320 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '0.6'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *2153267480
47
+ version_requirements: *2154098320
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: rack
50
- requirement: &2153267020 !ruby/object:Gem::Requirement
50
+ requirement: &2154097860 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,7 +55,7 @@ dependencies:
55
55
  version: '1.0'
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *2153267020
58
+ version_requirements: *2154097860
59
59
  description: Save your exceptions
60
60
  email:
61
61
  - me@rafaelss.com