opentransact 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +4 -0
- data/.rspec +3 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +52 -0
- data/Guardfile +8 -0
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +2 -0
- data/lib/opentransact.rb +5 -0
- data/lib/opentransact/asset.rb +20 -0
- data/lib/opentransact/client.rb +27 -0
- data/lib/opentransact/server.rb +15 -0
- data/lib/opentransact/version.rb +3 -0
- data/opentransact.gemspec +28 -0
- data/spec/opentransact/asset_spec.rb +40 -0
- data/spec/opentransact/client_spec.rb +74 -0
- data/spec/opentransact/server_spec.rb +32 -0
- data/spec/spec_helper.rb +9 -0
- metadata +167 -0
data/.document
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
opentransact (0.0.2)
|
5
|
+
oauth (~> 0.4.4)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
configuration (1.1.0)
|
11
|
+
diff-lcs (1.1.2)
|
12
|
+
fakeweb (1.3.0)
|
13
|
+
fuubar (0.0.2)
|
14
|
+
rspec (~> 2.0)
|
15
|
+
rspec-instafail (~> 0.1.4)
|
16
|
+
ruby-progressbar (~> 0.0.9)
|
17
|
+
growl (1.0.3)
|
18
|
+
guard (0.2.2)
|
19
|
+
open_gem (~> 1.4.2)
|
20
|
+
thor (~> 0.14.3)
|
21
|
+
guard-rspec (0.1.8)
|
22
|
+
guard (>= 0.2.0)
|
23
|
+
launchy (0.3.7)
|
24
|
+
configuration (>= 0.0.5)
|
25
|
+
rake (>= 0.8.1)
|
26
|
+
oauth (0.4.4)
|
27
|
+
open_gem (1.4.2)
|
28
|
+
launchy (~> 0.3.5)
|
29
|
+
rake (0.8.7)
|
30
|
+
rspec (2.1.0)
|
31
|
+
rspec-core (~> 2.1.0)
|
32
|
+
rspec-expectations (~> 2.1.0)
|
33
|
+
rspec-mocks (~> 2.1.0)
|
34
|
+
rspec-core (2.1.0)
|
35
|
+
rspec-expectations (2.1.0)
|
36
|
+
diff-lcs (~> 1.1.2)
|
37
|
+
rspec-instafail (0.1.4)
|
38
|
+
rspec-mocks (2.1.0)
|
39
|
+
ruby-progressbar (0.0.9)
|
40
|
+
thor (0.14.4)
|
41
|
+
|
42
|
+
PLATFORMS
|
43
|
+
ruby
|
44
|
+
|
45
|
+
DEPENDENCIES
|
46
|
+
fakeweb
|
47
|
+
fuubar
|
48
|
+
growl
|
49
|
+
guard-rspec
|
50
|
+
oauth (~> 0.4.4)
|
51
|
+
opentransact!
|
52
|
+
rspec (~> 2.1.0)
|
data/Guardfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Pelle Braendgaard
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
= OpenTransact Ruby Client
|
2
|
+
|
3
|
+
This library provides an easy to use client for interacting with OpenTransact financial service providers.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
+
* Send me a pull request. Bonus points for topic branches.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2010 Pelle Braendgaard. See LICENSE for details.
|
data/Rakefile
ADDED
data/lib/opentransact.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module OpenTransact
|
2
|
+
class Asset
|
3
|
+
attr_accessor :url, :transaction_url, :options
|
4
|
+
|
5
|
+
def initialize(url,options={})
|
6
|
+
@url = url
|
7
|
+
@transaction_url = options[:transaction_url]||@url
|
8
|
+
@options = options||{}
|
9
|
+
end
|
10
|
+
|
11
|
+
def server
|
12
|
+
@server ||= Server.new :key=>@options[:key], :secret=>@options[:secret], :url=>@url
|
13
|
+
end
|
14
|
+
|
15
|
+
def consumer
|
16
|
+
server && server.consumer || nil
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'oauth/tokens/access_token'
|
2
|
+
module OpenTransact
|
3
|
+
class Client
|
4
|
+
attr_accessor :asset,:server, :token, :secret, :options
|
5
|
+
|
6
|
+
def initialize(options={})
|
7
|
+
@asset=options.delete(:asset)
|
8
|
+
@server=options.delete(:server)
|
9
|
+
@token=options.delete(:token)
|
10
|
+
@secret=options.delete(:secret)
|
11
|
+
@options = options||{}
|
12
|
+
end
|
13
|
+
|
14
|
+
def transfer(amount,to,memo=nil)
|
15
|
+
access_token.post(asset.transaction_url,{:amount=>amount,:to=>to,:memo=>memo})
|
16
|
+
end
|
17
|
+
|
18
|
+
def access_token
|
19
|
+
@access_token ||= OAuth::AccessToken.new @asset.consumer, @token, @secret
|
20
|
+
end
|
21
|
+
|
22
|
+
def server
|
23
|
+
@server ||=( @asset && @asset.server || nil)
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'oauth/consumer'
|
2
|
+
module OpenTransact
|
3
|
+
class Server
|
4
|
+
attr_accessor :url, :options
|
5
|
+
|
6
|
+
def initialize(options={})
|
7
|
+
@options=options||{}
|
8
|
+
@url=options[:url]
|
9
|
+
end
|
10
|
+
|
11
|
+
def consumer
|
12
|
+
@consumer ||= OAuth::Consumer.new @options[:key], @options[:secret], :site=>@url
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "opentransact/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "opentransact"
|
7
|
+
s.version = OpenTransact::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Pelle Braendgaard"]
|
10
|
+
s.email = ["pelle@stakeventures.com"]
|
11
|
+
s.homepage = "http://opentransact.org"
|
12
|
+
s.summary = %q{OpenTransact client for Ruby}
|
13
|
+
s.description = %q{OpenTransact client for Ruby}
|
14
|
+
|
15
|
+
s.rubyforge_project = "opentransact"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_development_dependency "rspec", "~> 2.1.0"
|
23
|
+
s.add_development_dependency "fakeweb"
|
24
|
+
s.add_development_dependency "fuubar"
|
25
|
+
s.add_development_dependency "guard-rspec"
|
26
|
+
s.add_development_dependency "growl"
|
27
|
+
s.add_dependency "oauth", "~> 0.4.4"
|
28
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe OpenTransact::Asset do
|
4
|
+
describe "defaults" do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@asset = OpenTransact::Asset.new "http://nubux.heroku.com"
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should have url" do
|
11
|
+
@asset.url.should == "http://nubux.heroku.com"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should have transaction url" do
|
15
|
+
@asset.transaction_url.should == "http://nubux.heroku.com"
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "Server" do
|
19
|
+
before(:each) do
|
20
|
+
@server = @asset.server
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should have site" do
|
24
|
+
@server.url.should=="http://nubux.heroku.com"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should have key" do
|
28
|
+
@server.consumer.key.should be_nil
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should have secret" do
|
32
|
+
@server.consumer.secret.should be_nil
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should have a consumer" do
|
36
|
+
@asset.consumer.should == @server.consumer
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe OpenTransact::Client do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
@asset = OpenTransact::Asset.new "http://nubux.heroku.com", :key => "key", :secret => "secret"
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "defaults" do
|
10
|
+
|
11
|
+
before(:each) do
|
12
|
+
@client = OpenTransact::Client.new
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should not have asset" do
|
16
|
+
@client.asset.should be_nil
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
describe "with token" do
|
22
|
+
|
23
|
+
before(:each) do
|
24
|
+
@client = OpenTransact::Client.new :asset=>@asset, :token=>"my token", :secret=>"my secret"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should have token" do
|
28
|
+
@client.token.should=="my token"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should have secret" do
|
32
|
+
@client.secret.should=="my secret"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should have asset" do
|
36
|
+
@client.asset.should == @asset
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should have server" do
|
40
|
+
@client.server.should == @asset.server
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "access token" do
|
44
|
+
before(:each) do
|
45
|
+
@access_token = @client.access_token
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should have assets consumer" do
|
49
|
+
@access_token.consumer.should == @asset.consumer
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should have token" do
|
53
|
+
@access_token.token.should=="my token"
|
54
|
+
end
|
55
|
+
|
56
|
+
it "should have secret" do
|
57
|
+
@access_token.secret.should=="my secret"
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
describe "transfer" do
|
62
|
+
before(:each) do
|
63
|
+
@access_token.should_receive(:post).with("http://nubux.heroku.com",{:amount=>1123,:to=>"bob",:memo=>"2 cows"})
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should perform transfer" do
|
67
|
+
@client.transfer 1123, "bob", "2 cows"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
|
74
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe OpenTransact::Server do
|
4
|
+
describe "defaults" do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
@server = OpenTransact::Server.new :url => "http://nubux.heroku.com", :key=>"consumer_key", :secret=>"consumer_secret"
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should have url" do
|
11
|
+
@server.url.should == "http://nubux.heroku.com"
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "Consumer" do
|
15
|
+
before(:each) do
|
16
|
+
@consumer = @server.consumer
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should have site" do
|
20
|
+
@consumer.site.should=="http://nubux.heroku.com"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should have key" do
|
24
|
+
@consumer.key.should=="consumer_key"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should have secret" do
|
28
|
+
@consumer.secret.should=="consumer_secret"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: opentransact
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Pelle Braendgaard
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-11-18 00:00:00 -05:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: rspec
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ~>
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 2
|
30
|
+
- 1
|
31
|
+
- 0
|
32
|
+
version: 2.1.0
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: fakeweb
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: fuubar
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
segments:
|
57
|
+
- 0
|
58
|
+
version: "0"
|
59
|
+
type: :development
|
60
|
+
version_requirements: *id003
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: guard-rspec
|
63
|
+
prerelease: false
|
64
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
segments:
|
70
|
+
- 0
|
71
|
+
version: "0"
|
72
|
+
type: :development
|
73
|
+
version_requirements: *id004
|
74
|
+
- !ruby/object:Gem::Dependency
|
75
|
+
name: growl
|
76
|
+
prerelease: false
|
77
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
segments:
|
83
|
+
- 0
|
84
|
+
version: "0"
|
85
|
+
type: :development
|
86
|
+
version_requirements: *id005
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: oauth
|
89
|
+
prerelease: false
|
90
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ~>
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
segments:
|
96
|
+
- 0
|
97
|
+
- 4
|
98
|
+
- 4
|
99
|
+
version: 0.4.4
|
100
|
+
type: :runtime
|
101
|
+
version_requirements: *id006
|
102
|
+
description: OpenTransact client for Ruby
|
103
|
+
email:
|
104
|
+
- pelle@stakeventures.com
|
105
|
+
executables: []
|
106
|
+
|
107
|
+
extensions: []
|
108
|
+
|
109
|
+
extra_rdoc_files: []
|
110
|
+
|
111
|
+
files:
|
112
|
+
- .document
|
113
|
+
- .gitignore
|
114
|
+
- .rspec
|
115
|
+
- Gemfile
|
116
|
+
- Gemfile.lock
|
117
|
+
- Guardfile
|
118
|
+
- LICENSE
|
119
|
+
- README.rdoc
|
120
|
+
- Rakefile
|
121
|
+
- lib/opentransact.rb
|
122
|
+
- lib/opentransact/asset.rb
|
123
|
+
- lib/opentransact/client.rb
|
124
|
+
- lib/opentransact/server.rb
|
125
|
+
- lib/opentransact/version.rb
|
126
|
+
- opentransact.gemspec
|
127
|
+
- spec/opentransact/asset_spec.rb
|
128
|
+
- spec/opentransact/client_spec.rb
|
129
|
+
- spec/opentransact/server_spec.rb
|
130
|
+
- spec/spec_helper.rb
|
131
|
+
has_rdoc: true
|
132
|
+
homepage: http://opentransact.org
|
133
|
+
licenses: []
|
134
|
+
|
135
|
+
post_install_message:
|
136
|
+
rdoc_options: []
|
137
|
+
|
138
|
+
require_paths:
|
139
|
+
- lib
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
none: false
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
segments:
|
146
|
+
- 0
|
147
|
+
version: "0"
|
148
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
149
|
+
none: false
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
segments:
|
154
|
+
- 0
|
155
|
+
version: "0"
|
156
|
+
requirements: []
|
157
|
+
|
158
|
+
rubyforge_project: opentransact
|
159
|
+
rubygems_version: 1.3.7
|
160
|
+
signing_key:
|
161
|
+
specification_version: 3
|
162
|
+
summary: OpenTransact client for Ruby
|
163
|
+
test_files:
|
164
|
+
- spec/opentransact/asset_spec.rb
|
165
|
+
- spec/opentransact/client_spec.rb
|
166
|
+
- spec/opentransact/server_spec.rb
|
167
|
+
- spec/spec_helper.rb
|