opentransact 0.1.0 → 0.1.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/CHANGELOG +1 -0
- data/Gemfile.lock +14 -14
- data/lib/opentransact/asset.rb +1 -1
- data/lib/opentransact/client.rb +23 -1
- data/lib/opentransact/version.rb +1 -1
- data/opentransact.gemspec +1 -1
- data/spec/opentransact/asset_spec.rb +1 -1
- metadata +6 -5
data/CHANGELOG
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.1 Better error handling
|
data/Gemfile.lock
CHANGED
@@ -9,10 +9,10 @@ PATH
|
|
9
9
|
GEM
|
10
10
|
remote: http://rubygems.org/
|
11
11
|
specs:
|
12
|
-
configuration (1.
|
12
|
+
configuration (1.2.0)
|
13
13
|
diff-lcs (1.1.2)
|
14
14
|
fakeweb (1.3.0)
|
15
|
-
fuubar (0.0.
|
15
|
+
fuubar (0.0.3)
|
16
16
|
rspec (~> 2.0)
|
17
17
|
rspec-instafail (~> 0.1.4)
|
18
18
|
ruby-progressbar (~> 0.0.9)
|
@@ -20,8 +20,8 @@ GEM
|
|
20
20
|
guard (0.2.2)
|
21
21
|
open_gem (~> 1.4.2)
|
22
22
|
thor (~> 0.14.3)
|
23
|
-
guard-rspec (0.1.
|
24
|
-
guard (>= 0.2.
|
23
|
+
guard-rspec (0.1.9)
|
24
|
+
guard (>= 0.2.2)
|
25
25
|
launchy (0.3.7)
|
26
26
|
configuration (>= 0.0.5)
|
27
27
|
rake (>= 0.8.1)
|
@@ -31,17 +31,17 @@ GEM
|
|
31
31
|
open_gem (1.4.2)
|
32
32
|
launchy (~> 0.3.5)
|
33
33
|
rake (0.8.7)
|
34
|
-
rspec (2.
|
35
|
-
rspec-core (~> 2.
|
36
|
-
rspec-expectations (~> 2.
|
37
|
-
rspec-mocks (~> 2.
|
38
|
-
rspec-core (2.
|
39
|
-
rspec-expectations (2.
|
34
|
+
rspec (2.4.0)
|
35
|
+
rspec-core (~> 2.4.0)
|
36
|
+
rspec-expectations (~> 2.4.0)
|
37
|
+
rspec-mocks (~> 2.4.0)
|
38
|
+
rspec-core (2.4.0)
|
39
|
+
rspec-expectations (2.4.0)
|
40
40
|
diff-lcs (~> 1.1.2)
|
41
|
-
rspec-instafail (0.1.
|
42
|
-
rspec-mocks (2.
|
41
|
+
rspec-instafail (0.1.5)
|
42
|
+
rspec-mocks (2.4.0)
|
43
43
|
ruby-progressbar (0.0.9)
|
44
|
-
thor (0.14.
|
44
|
+
thor (0.14.6)
|
45
45
|
|
46
46
|
PLATFORMS
|
47
47
|
ruby
|
@@ -55,4 +55,4 @@ DEPENDENCIES
|
|
55
55
|
multi_xml
|
56
56
|
oauth (~> 0.4.4)
|
57
57
|
opentransact!
|
58
|
-
rspec (~> 2.
|
58
|
+
rspec (~> 2.4.0)
|
data/lib/opentransact/asset.rb
CHANGED
@@ -25,7 +25,7 @@ module OpenTransact
|
|
25
25
|
# @asset.transfer 12, "bob@test.com", "For implementing shopping cart"
|
26
26
|
#
|
27
27
|
def transfer(amount,to,memo=nil)
|
28
|
-
client.
|
28
|
+
client.post(transaction_url,{:amount=>amount,:to=>to,:memo=>memo}) if client
|
29
29
|
end
|
30
30
|
|
31
31
|
def name
|
data/lib/opentransact/client.rb
CHANGED
@@ -79,8 +79,14 @@ module OpenTransact
|
|
79
79
|
else
|
80
80
|
true
|
81
81
|
end
|
82
|
+
elsif response.code=="401"
|
83
|
+
raise Unauthorized.new(response)
|
84
|
+
elsif response.code=="403"
|
85
|
+
raise Forbidden.new(response)
|
86
|
+
elsif response.code=="402"
|
87
|
+
raise InsufficientFunds.new(response)
|
82
88
|
else
|
83
|
-
|
89
|
+
raise HttpException.new(response)
|
84
90
|
end
|
85
91
|
|
86
92
|
end
|
@@ -94,4 +100,20 @@ module OpenTransact
|
|
94
100
|
end
|
95
101
|
|
96
102
|
end
|
103
|
+
|
104
|
+
class HttpException < Exception
|
105
|
+
attr_reader :response
|
106
|
+
def initialize(response)
|
107
|
+
@response = response
|
108
|
+
end
|
109
|
+
|
110
|
+
def message
|
111
|
+
super+(" (http response code #{@response.code})")
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
class Unauthorized < HttpException; end
|
116
|
+
class Forbidden < HttpException; end
|
117
|
+
class InsufficientFunds < HttpException; end
|
118
|
+
|
97
119
|
end
|
data/lib/opentransact/version.rb
CHANGED
data/opentransact.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
-
s.add_development_dependency "rspec", "~> 2.
|
22
|
+
s.add_development_dependency "rspec", "~> 2.4.0"
|
23
23
|
s.add_development_dependency "fakeweb"
|
24
24
|
s.add_development_dependency "fuubar"
|
25
25
|
s.add_development_dependency "guard-rspec"
|
@@ -27,7 +27,7 @@ describe OpenTransact::Asset do
|
|
27
27
|
describe "transfer" do
|
28
28
|
before(:each) do
|
29
29
|
@access_token = @asset.client.access_token
|
30
|
-
@access_token.should_receive(:post).with("https://picomoney.com",{:amount=>1123,:to=>"bob",:memo=>"2 cows"})
|
30
|
+
@access_token.should_receive(:post).with("https://picomoney.com",{:amount=>1123,:to=>"bob",:memo=>"2 cows"}, {"Accept"=>"application/json"})
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should perform transfer" do
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Pelle Braendgaard
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date:
|
17
|
+
date: 2011-01-15 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -27,9 +27,9 @@ dependencies:
|
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
segments:
|
29
29
|
- 2
|
30
|
-
-
|
30
|
+
- 4
|
31
31
|
- 0
|
32
|
-
version: 2.
|
32
|
+
version: 2.4.0
|
33
33
|
type: :development
|
34
34
|
version_requirements: *id001
|
35
35
|
- !ruby/object:Gem::Dependency
|
@@ -138,6 +138,7 @@ files:
|
|
138
138
|
- .document
|
139
139
|
- .gitignore
|
140
140
|
- .rspec
|
141
|
+
- CHANGELOG
|
141
142
|
- Gemfile
|
142
143
|
- Gemfile.lock
|
143
144
|
- Guardfile
|