money-coinmarketcap-bank 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b7f916c3dbcd07a30e8cef285b219a580c63bcc6
4
- data.tar.gz: 0caefe90693b44ded4d4c36ee86b0fd5d78f5cce
3
+ metadata.gz: 83b6668ba3bb114442aa216d2c401f16d690d8b6
4
+ data.tar.gz: 46b28111fb02990f0d307a63f8beb937f2ef4a62
5
5
  SHA512:
6
- metadata.gz: aa0f3b3e94a0d3e95b5e35c0a104c1a5cacfa195cdaec0454c04b60edc12c3a931fdeb5ae792c7843ee46cd07ca486e66c2fab9a496802cbe98171135e3d40e7
7
- data.tar.gz: fc68671fb3f2a0306b50659a7dfc7c301b2aaae9d3d97d6784c2fdd1fc4461be10dbbdcf592a9e9e54a527e4c04a35911c0029caf7a3be06d43f19ff60526915
6
+ metadata.gz: fcb1a8b28f54441af37187705522bef2e618ca96dd63d6cbcd86922b3a8cbcb647c811f1dac57b31341552d297d7dc0f60f2356d9a861bc113b1e155f767828d
7
+ data.tar.gz: 1d627d488780741e5a2f65302c9f69819e4a01e9a0edaf765b37d2cc26a819cb2ada55aad6ca6083dddd5f0a74d1b504ed9b1093d78063b6ce59f047616ea5d0
data/README.md CHANGED
@@ -1,10 +1,11 @@
1
- # money-coinmarketcap-bank
2
- ## CoinMarketCap frontend for ruby-money
1
+ money-coinmarketcap-bank
2
+ ========================
3
+ CoinMarketCap frontend for ruby-money
3
4
 
4
- Attach this gem to ruby-money to use it as bank and get the exchange rate from [http://coinmarketcap.com/](coinmarketcap.com).
5
+ Attach this gem to ruby-money to use it as bank and get the exchange rate from [coinmarketcap.com](http://coinmarketcap.com/).
5
6
 
6
7
  This gem is basically a clone of [money-uphold-bank](https://github.com/subvisual/money-uphold-bank).
7
- Almost of all the credits go to its creators.
8
+ All the credits go to its creators.
8
9
 
9
10
  # Usage
10
11
 
@@ -12,13 +12,16 @@ class Money
12
12
  # Seconds after which the current rates are automatically expired
13
13
  attr_accessor :ttl_in_seconds
14
14
 
15
+ # Parsed UpholdBank result as a Hash
16
+ attr_reader :tickers
17
+
15
18
  # Rates expiration time
16
19
  attr_reader :rates_expire_at
17
20
 
18
21
  def initialize(*args, &block)
19
22
  super
20
23
 
21
- @ttl_in_seconds = 3600 # 1 hour
24
+ self.ttl_in_seconds = 3600 # 1 hour
22
25
  end
23
26
 
24
27
  def update_rates
@@ -55,17 +58,17 @@ class Money
55
58
  rate
56
59
  end
57
60
 
58
- def coins
59
- return @coins if @coins
60
-
61
+ def currencies
61
62
  response = open(EXCHANGE_URL).read
62
63
  @coins = JSON.parse(response)['markets']
64
+ @rates_expire_at = Time.now + ttl_in_seconds
65
+ @coins
63
66
  end
64
67
 
65
68
  def add_exchange_rates
66
- coins.each do |coin|
67
- iso_from = coin['symbol']
68
- coin['price'].each do |iso_to, rate|
69
+ currencies.each do |currency|
70
+ iso_from = currency['symbol']
71
+ currency['price'].each do |iso_to, rate|
69
72
  next unless Money::Currency.find(iso_from) && Money::Currency.find(iso_to)
70
73
  add_rate(iso_from, iso_to, rate)
71
74
  add_rate(iso_to, iso_from, 1.0 / rate)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new { |s|
2
2
  s.name = 'money-coinmarketcap-bank'
3
- s.version = '0.1.1'
3
+ s.version = '0.1.2'
4
4
  s.author = 'Giovanni Capuano'
5
5
  s.email = 'webmaster@giovannicapuano.net'
6
6
  s.homepage = 'https://github.com/RoxasShadow'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: money-coinmarketcap-bank
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Giovanni Capuano