cryptocoin_fanboi 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +3 -2
- data.tar.gz.sig +0 -0
- data/lib/cryptocoin_fanboi.rb +40 -14
- metadata +2 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1119ca932779ecacc2207967a9dfa63431117b8
|
4
|
+
data.tar.gz: aef9f90d566d15c02ca8d6c1f0abf701a4755200
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11193cbd17fddb03502878a9cc82cd2c89207c9f31cd14f58e2a1cce5f6024d440cd01b5db5468ca66f6b30716ad8943bc69e73b47938c7254aa48a9f4ab6b31
|
7
|
+
data.tar.gz: 9225a65ee47f059e8de95167f10b5d2d820d1c87e3a5cc6cf6d1c1d52630fbef69d970d99de789591e0c9dab08ed9df8cda34c1b00a7ba7e92dd2433ce4b9e23
|
checksums.yaml.gz.sig
CHANGED
@@ -1,2 +1,3 @@
|
|
1
|
-
�
|
2
|
-
��
|
1
|
+
��S�/��*!E⼮ʹ�Æ#�Iޱ��aڄ�2���~��F躒F�d�������u\Rf��[5G~��P���u7{�
|
2
|
+
M�UC��u��?����9�m���*�����SL�PJ;�cxEJ^_8���{ �
|
3
|
+
����V,'љj�_k�{Gc��G|%g��
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/cryptocoin_fanboi.rb
CHANGED
@@ -54,9 +54,9 @@ class CryptocoinFanboi
|
|
54
54
|
@fields = %w(rank name price_usd price_btc percent_change_1h
|
55
55
|
percent_change_24h percent_change_7d)
|
56
56
|
|
57
|
-
@year = Time.now.year
|
57
|
+
@year = Time.now.year
|
58
58
|
@labels = %w(Rank Name USD BTC) + ['% 1hr:', '% 24hr:',
|
59
|
-
'% 1 week:', '% ' + @year + ':']
|
59
|
+
'% 1 week:', '% ' + @year.to_s + ':']
|
60
60
|
@coins = fetch_coinlist()
|
61
61
|
|
62
62
|
# check for the local cache file containing a record of currency
|
@@ -70,17 +70,20 @@ class CryptocoinFanboi
|
|
70
70
|
h = Psych.load File.read(cache_filename)
|
71
71
|
puts 'h.key.first: ' + h.keys.first.inspect if @debug
|
72
72
|
puts '@year: ' + @year.inspect if @debug
|
73
|
-
@
|
74
|
-
|
73
|
+
@coin_prices = (h.keys.first == @year) ? h[@year] : \
|
74
|
+
fetch_year_start_prices(@all_coins)
|
75
75
|
|
76
76
|
else
|
77
77
|
|
78
78
|
# fetch the currency prices from the start of the year
|
79
|
-
@
|
80
|
-
File.write cache_filename, {@year => @
|
79
|
+
@coin_prices = fetch_year_start_prices(@all_coins)
|
80
|
+
File.write cache_filename, {@year => @coin_prices}.to_yaml
|
81
81
|
|
82
82
|
end
|
83
83
|
|
84
|
+
@growth = fetch_growth(@coins, @coin_prices)
|
85
|
+
puts '@growth: ' + @growth.inspect if @debug
|
86
|
+
|
84
87
|
end
|
85
88
|
|
86
89
|
def coin_abbreviations()
|
@@ -228,14 +231,12 @@ class CryptocoinFanboi
|
|
228
231
|
end
|
229
232
|
|
230
233
|
# fetch the currency prices from the start of the year
|
231
|
-
#
|
232
|
-
def
|
233
|
-
|
234
|
-
puts 'fetching growth ...' if @debug
|
234
|
+
#
|
235
|
+
def fetch_year_start_prices(coins)
|
235
236
|
|
236
237
|
coins.inject({}) do |r, coin|
|
237
238
|
|
238
|
-
day1 = @year + '0101'
|
239
|
+
day1 = @year.to_s + '0101'
|
239
240
|
puts 'coin: ' + coin.name.inspect if @debug
|
240
241
|
|
241
242
|
begin
|
@@ -248,9 +249,34 @@ class CryptocoinFanboi
|
|
248
249
|
|
249
250
|
if a and a.any? then
|
250
251
|
|
251
|
-
|
252
|
-
|
253
|
-
|
252
|
+
r.merge({coin.name => a[0][:close].to_f})
|
253
|
+
else
|
254
|
+
r
|
255
|
+
end
|
256
|
+
|
257
|
+
end
|
258
|
+
|
259
|
+
end
|
260
|
+
|
261
|
+
|
262
|
+
# fetch the currency prices from the start of the year
|
263
|
+
#
|
264
|
+
def fetch_growth(coins, coin_prices)
|
265
|
+
|
266
|
+
puts 'fetching growth ...' if @debug
|
267
|
+
puts 'coin_prices: ' + coin_prices.inspect if @debug
|
268
|
+
|
269
|
+
coins.inject({}) do |r, coin|
|
270
|
+
|
271
|
+
year_start_price = coin_prices[coin.name]
|
272
|
+
|
273
|
+
if year_start_price then
|
274
|
+
|
275
|
+
latest_day = coin.price_usd.to_f
|
276
|
+
puts "latest_day: %s year_start: %s" % \
|
277
|
+
[latest_day, year_start_price] if @debug
|
278
|
+
r.merge({coin.name => (100.0 / (year_start_price /
|
279
|
+
(latest_day - year_start_price))).round(2)})
|
254
280
|
else
|
255
281
|
r
|
256
282
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cryptocoin_fanboi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
NgmsFfw10oaD3PWQ7UPxWJP14au2LUL+NGHkLrGHOMPphsZhYeXKugGO8NfcKukq
|
31
31
|
fps=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2018-01-
|
33
|
+
date: 2018-01-16 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: colored
|
metadata.gz.sig
CHANGED
Binary file
|