straight 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/straight/gateway.rb +13 -6
- data/straight.gemspec +3 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 04d8199335a24cd3a0c22e95a2db1cc8576e6d57
|
4
|
+
data.tar.gz: c20786d5a8b3461583df5cc9ee882ee387f5af19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 59bf81e312babcdaf4e3fb22b80c32ecdb30852484b91490adaa310aa2891c664b9812315644aa25838caa4019fd8be019e8b95b19f2f78c62d6bace037e3308
|
7
|
+
data.tar.gz: 8c9d2819814f9989d19cfbca2b4de5ef92b9bea5e6a2bca3f88cacfbb513224f97216488dca116537d0e9f6760b73de8c5021d6efdb52cfe212bdfad7018598f
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.2
|
data/lib/straight/gateway.rb
CHANGED
@@ -17,6 +17,9 @@ module Straight
|
|
17
17
|
# Straight::GatewayModule::Prependable (most likely the former).
|
18
18
|
module GatewayModule
|
19
19
|
|
20
|
+
# Raised when adapter's list (either Exchange or Blockchain adapters) is empty
|
21
|
+
class NoAdaptersAvailable < Exception;end
|
22
|
+
|
20
23
|
# Only add getters and setters for those properties in the extended class
|
21
24
|
# that don't already have them. This is very useful with ActiveRecord for example
|
22
25
|
# where we don't want to override AR getters and setters that set attributes.
|
@@ -89,15 +92,15 @@ module Straight
|
|
89
92
|
end
|
90
93
|
|
91
94
|
def fetch_transaction(tid, address: nil)
|
92
|
-
try_adapters(@blockchain_adapters) { |b| b.fetch_transaction(tid, address: address) }
|
95
|
+
try_adapters(@blockchain_adapters, type: "blockchain") { |b| b.fetch_transaction(tid, address: address) }
|
93
96
|
end
|
94
97
|
|
95
98
|
def fetch_transactions_for(address)
|
96
|
-
try_adapters(@blockchain_adapters) { |b| b.fetch_transactions_for(address) }
|
99
|
+
try_adapters(@blockchain_adapters, type: "blockchain") { |b| b.fetch_transactions_for(address) }
|
97
100
|
end
|
98
101
|
|
99
102
|
def fetch_balance_for(address)
|
100
|
-
try_adapters(@blockchain_adapters) { |b| b.fetch_balance_for(address) }
|
103
|
+
try_adapters(@blockchain_adapters, type: "blockchain") { |b| b.fetch_balance_for(address) }
|
101
104
|
end
|
102
105
|
|
103
106
|
def keychain
|
@@ -125,14 +128,14 @@ module Straight
|
|
125
128
|
return Satoshi.new(amount, from_unit: btc_denomination).to_i
|
126
129
|
end
|
127
130
|
|
128
|
-
try_adapters(@exchange_rate_adapters) do |a|
|
131
|
+
try_adapters(@exchange_rate_adapters, type: "exchange rate") do |a|
|
129
132
|
a.convert_from_currency(amount, currency: currency)
|
130
133
|
end
|
131
134
|
end
|
132
135
|
|
133
136
|
def current_exchange_rate(currency=self.default_currency)
|
134
137
|
currency = currency.to_s.upcase
|
135
|
-
try_adapters(@exchange_rate_adapters) do |a|
|
138
|
+
try_adapters(@exchange_rate_adapters, type: "exchange rate") do |a|
|
136
139
|
a.rate_for(currency)
|
137
140
|
end
|
138
141
|
end
|
@@ -141,7 +144,11 @@ module Straight
|
|
141
144
|
|
142
145
|
# Calls the block with each adapter until one of them does not fail.
|
143
146
|
# Fails with the last exception.
|
144
|
-
def try_adapters(adapters, &block)
|
147
|
+
def try_adapters(adapters, type: nil, &block)
|
148
|
+
|
149
|
+
# TODO: specify which adapters are unavailable (blockchain or exchange rate)
|
150
|
+
raise NoAdaptersAvailable, "the list of #{type} adapters is empty or nil" if adapters.nil? || adapters.empty?
|
151
|
+
|
145
152
|
last_exception = nil
|
146
153
|
adapters.each do |adapter|
|
147
154
|
begin
|
data/straight.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: straight 0.2.
|
5
|
+
# stub: straight 0.2.2 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "straight"
|
9
|
-
s.version = "0.2.
|
9
|
+
s.version = "0.2.2"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib"]
|
13
13
|
s.authors = ["Roman Snitko"]
|
14
|
-
s.date = "2015-05-
|
14
|
+
s.date = "2015-05-07"
|
15
15
|
s.description = "An engine for the Straight payment gateway software. Requires no state to be saved (that is, no storage or DB). Its responsibilities only include processing data coming from an actual gateway."
|
16
16
|
s.email = "roman.snitko@gmail.com"
|
17
17
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: straight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roman Snitko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: money-tree
|