cryptocoin_fanboi 0.3.1 → 0.3.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 721bbcf718a9fd2b387fe83c70321ad810f34f66
4
- data.tar.gz: 95b7523cc88168c442c34082b015812debeaac46
3
+ metadata.gz: a1119ca932779ecacc2207967a9dfa63431117b8
4
+ data.tar.gz: aef9f90d566d15c02ca8d6c1f0abf701a4755200
5
5
  SHA512:
6
- metadata.gz: 74119366837b3e9afa95ebaf976e3d3c5b65dd5e859d7aaa71033f35154ac5636da83c26446a6876703d94d24ffdddd4e5820339fafd57fb5ef1c2d59d2d9612
7
- data.tar.gz: '08b80d8b207131df7877cce0fcaf32bf57ff1c5809b9fbe73bbe9fd05aaa26c60605d354e7f96c960d75501b823af68fc8524799e1a32f1415bd3f72c1c516b0'
6
+ metadata.gz: 11193cbd17fddb03502878a9cc82cd2c89207c9f31cd14f58e2a1cce5f6024d440cd01b5db5468ca66f6b30716ad8943bc69e73b47938c7254aa48a9f4ab6b31
7
+ data.tar.gz: 9225a65ee47f059e8de95167f10b5d2d820d1c87e3a5cc6cf6d1c1d52630fbef69d970d99de789591e0c9dab08ed9df8cda34c1b00a7ba7e92dd2433ce4b9e23
@@ -1,2 +1,3 @@
1
- a���OR��}E
2
- ��Qn<L��]Y����Nm�„ד�g�{�t�/vLvk�\�d鑠����L0T�.�M5�MA�5�A��3D�7���[3
1
+ ��S�/��*!E⼮ʹ�Æ#�Iޱ��aڄ�2���~��F躒Fd�������u\Rf��[5G~��P���u7{
2
+ M�UC��u��?����9�m���*�����SLPJ;�cxEJ^_8���{
3
+ ����V,'љj�_k�{Gc��G|%g��
data.tar.gz.sig CHANGED
Binary file
@@ -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.to_s
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
- @growth = (h.keys.first == @year) ? h[@year] : fetch_growth(@all_coins)
74
- puts '@growth: ' + @growth.inspect if @debug
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
- @growth = fetch_growth(@all_coins)
80
- File.write cache_filename, {@year => @growth}.to_yaml
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 fetch_growth(coins)
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
- latest_day, year_start = coin.price_usd.to_f, a[0][:close]
252
- r.merge({coin.name => (100.0 / (year_start /
253
- (latest_day - year_start))).round(2)})
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.1
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-06 00:00:00.000000000 Z
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