cryptocoin_fanboi 0.3.2 → 0.3.3
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 +4 -4
- checksums.yaml.gz.sig +2 -3
- data.tar.gz.sig +0 -0
- data/lib/cryptocoin_fanboi.rb +28 -11
- metadata +1 -1
- metadata.gz.sig +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5c9ff9e5223a14862febf6346ea24bccac53924f
|
|
4
|
+
data.tar.gz: '09ba8bc18ab9e028b497dbbcf8d3c75f9d93d937'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c0496d4c10c1e4441c1163d0937872991615266055f8ac57421e2be023c6b26557f5d594991e5ce0fd90b49a24a9480d0d4d934ac1599803a4a710a0aecb3d9a
|
|
7
|
+
data.tar.gz: 01d715448c3e1dfa8d34842f33b9a8ed2579e9f46777c6d9b634042a475c7baf1e4fbef2fee751974223d64dd81cb3c1fd22bf91b209266600e435f1908270e2
|
checksums.yaml.gz.sig
CHANGED
|
@@ -1,3 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
����V,'љj�_k�{Gc��G|%g��
|
|
1
|
+
�`t.�W�AaV�/�87�R�Ioe4�A�V9�����e��Ԯ�Q�8?�{+���g�Y���U���&t�?n����2�v�TXL�Q߫�y�$&��w��~���0��Pd�w��2���mxݓ�cH�b)�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
|
data/lib/cryptocoin_fanboi.rb
CHANGED
|
@@ -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
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
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
metadata.gz.sig
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
�ts6����>rK0�?tت�
|