cryptocoin_fanboi 0.3.2 → 0.3.3

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: a1119ca932779ecacc2207967a9dfa63431117b8
4
- data.tar.gz: aef9f90d566d15c02ca8d6c1f0abf701a4755200
3
+ metadata.gz: 5c9ff9e5223a14862febf6346ea24bccac53924f
4
+ data.tar.gz: '09ba8bc18ab9e028b497dbbcf8d3c75f9d93d937'
5
5
  SHA512:
6
- metadata.gz: 11193cbd17fddb03502878a9cc82cd2c89207c9f31cd14f58e2a1cce5f6024d440cd01b5db5468ca66f6b30716ad8943bc69e73b47938c7254aa48a9f4ab6b31
7
- data.tar.gz: 9225a65ee47f059e8de95167f10b5d2d820d1c87e3a5cc6cf6d1c1d52630fbef69d970d99de789591e0c9dab08ed9df8cda34c1b00a7ba7e92dd2433ce4b9e23
6
+ metadata.gz: c0496d4c10c1e4441c1163d0937872991615266055f8ac57421e2be023c6b26557f5d594991e5ce0fd90b49a24a9480d0d4d934ac1599803a4a710a0aecb3d9a
7
+ data.tar.gz: 01d715448c3e1dfa8d34842f33b9a8ed2579e9f46777c6d9b634042a475c7baf1e4fbef2fee751974223d64dd81cb3c1fd22bf91b209266600e435f1908270e2
@@ -1,3 +1 @@
1
- ��S�/��*!E⼮ʹ�Æ#�Iޱ��aڄ�2���~��F躒Fd�������u\Rf��[5G~��P���u7{
2
- M�UC��u��?����9�m���*�����SL�PJ;�cxEJ^_8���{ �
3
- ����V,'љj�_k�{Gc��G|%g��
1
+ �`t.�W�AaV�/�8 7�R�Ioe4�A�V9�����e��Ԯ�Q�8?�{+���g�Y���U���&t�?n����2�v�TXL�Q߫�y�$&��w��~���0��Pd�w��2���mxݓ�cHb)�L�Ȉx�v����$ 5+�l��8+�`�"R1���=�</@1�����U��C��+/�^� Ӵb�E��*�5;wMj�t�"z놩ˊ �lo��4��B_
2
+ YV/�/`V?�k�6��
data.tar.gz.sig CHANGED
Binary file
@@ -44,9 +44,9 @@ class CryptocoinFanboi
44
44
  attr_accessor :colored
45
45
 
46
46
  def initialize(watch: [], ignore: [],
47
- colored: true, debug: false)
47
+ colored: true, debug: false, filepath: '.')
48
48
 
49
- @colored, @debug = colored, debug
49
+ @colored, @debug, @filepath = colored, debug, filepath
50
50
 
51
51
  @watch= watch.map(&:upcase)
52
52
  @ignore = ignore.map(&:upcase)
@@ -62,7 +62,14 @@ class CryptocoinFanboi
62
62
  # check for the local cache file containing a record of currency
63
63
  # prices from the start of the year
64
64
 
65
- cache_filename = 'cryptocoin_fanboi.yaml'
65
+ cache_filename = File.join(@filepath, 'cryptocoin_fanboi.yaml')
66
+ @historic_prices_file = File.join(@filepath, 'ccf_historic.yaml')
67
+
68
+ @history_prices = if File.exists? @historic_prices_file then
69
+ Psych.load File.read(@historic_prices_file)
70
+ else
71
+ {}
72
+ end
66
73
 
67
74
  if File.exists? cache_filename then
68
75
 
@@ -128,14 +135,24 @@ class CryptocoinFanboi
128
135
  date = Chronic.parse(raw_date.gsub('-',' ')).strftime("%Y%m%d")
129
136
  puts 'date: ' + date.inspect if @debug
130
137
 
131
- begin
132
-
133
- a = Coinmarketcap.get_historical_price(coin, date, date)
134
- puts 'a: ' + a.inspect if @debug
135
- r = a.first[:close]
136
-
137
- rescue
138
- puts ($!).inspect if @debug
138
+ if @history_prices[coin] and @history_prices[coin][date] then
139
+ @history_prices[coin][date]
140
+ else
141
+ begin
142
+
143
+ a = Coinmarketcap.get_historical_price(coin, date, date)
144
+ puts 'a: ' + a.inspect if @debug
145
+ r = a.first[:close]
146
+
147
+ @history_prices[coin] ||= {}
148
+ @history_prices[coin][date] = r
149
+ File.write @historic_prices_file, @history_prices.to_yaml
150
+
151
+ return r
152
+
153
+ rescue
154
+ puts ($!).inspect if @debug
155
+ end
139
156
  end
140
157
 
141
158
  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.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
metadata.gz.sig CHANGED
@@ -1 +1 @@
1
- w��%�2�@.���^$�і���Z��Vi���?�"&�CɆ���?��KZ���1t(�p�ϴ����X�;���M�~!w%A�ЋNT��}�֝����H��%ήil�g0,�B��k�- v�α$�H�F Չ��M�!U�l*/�[5� 1����^+���ٶ��A��!��G�+z�R`R�
1
+ �ts6����>rK0�?tت�