mycoins 0.2.5 → 0.2.6

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: ae93a879c55d95f55070ebb8731bcf73c135498b
4
- data.tar.gz: f0bd6d46cc903407cb577effedbac04971f99981
3
+ metadata.gz: 2886e47a80e0c69bccced2115f2ce316ae81cc8c
4
+ data.tar.gz: fa2b37ffd826d4d4303bbb86db46f3e2b9a16c2d
5
5
  SHA512:
6
- metadata.gz: f4ed3d309508b0d7f2cb85072762639f646a85d8523d8f9e70081a217bfbac362aa0567f9f1f3b10ab3976bf3319d2847585fdfe8284155c8b71e9a2c342c427
7
- data.tar.gz: 90ebeec8177ccd9dc552bfe5dc2e51ece56f465bef2335c8db3ef2778e2b5e4690f03ce2a416334f10a0ee27c387bd2b1f9a1403940596e65ac988cec62a2a7e
6
+ metadata.gz: ce39c19f5d06b59d22dd929aeceed611181331357dff8a6d5bb990ba50f0dbac2d634ab07976945623ab01032a08af11d13d60ea5ad36757f22966175abf0c95
7
+ data.tar.gz: 0e7b76c134fcec9be82dbcfa440970a42e85a022eef6b30687c65d525f36b5743bfdbc2e7ff8fc76869db0aa3541ae1a3d5ed3bcda17fbf9b293365f3603a125
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -27,19 +27,36 @@ class MyCoins
27
27
 
28
28
  end
29
29
 
30
- c = CryptocoinFanboi.new
30
+
31
31
 
32
32
  puts '@dx.to_xml: ' + @dx.to_xml if @debug
33
33
 
34
34
  @mycurrency = (@dx.currency || mycurrency).upcase
35
35
  puts '@mycurrency: ' + @mycurrency.inspect if @debug
36
-
37
- mycoins = @dx.all.inject([]) do |r, mycoin|
36
+
37
+ coin_names = @dx.all.map{ |x| x.title.gsub(/\s+\[[^\]]+\]/,'')}.uniq
38
+
39
+ @cache_file = File.join(filepath, 'mycoins_lookup.yaml')
40
+
41
+ h = if File.exist? @cache_file then
42
+
43
+ puts 'reading coins symbols frome the cache' if @debug
44
+ h2 = Psych.load(File.read(@cache_file))
45
+ puts 'h2: ' + h2.inspect if @debug
46
+
47
+ if (coin_names - h2.keys).empty? then
48
+ h2
49
+ else
50
+ fetch_symbols coin_names
51
+ end
38
52
 
39
- found = c.find mycoin.title.gsub(/\s+\[[^\]]+\]/,'')
40
- found ? r << found.symbol : r
53
+ else
41
54
 
55
+ fetch_symbols coin_names
42
56
  end
57
+
58
+ puts 'h: ' + h.inspect if @debug
59
+ mycoins = h.values
43
60
 
44
61
  puts 'mycoins: ' + mycoins.inspect if @debug
45
62
  @ccf = CryptocoinFanboi.new(watch: mycoins)
@@ -184,6 +201,23 @@ class MyCoins
184
201
 
185
202
  end
186
203
 
204
+ def fetch_symbols(coin_names)
205
+
206
+ c = CryptocoinFanboi.new
207
+
208
+ h = coin_names.inject({}) do |r, name|
209
+
210
+ found = c.find name
211
+ r.merge(name => found.symbol)
212
+
213
+ end
214
+
215
+ File.write @cache_file, h.to_yaml
216
+
217
+ return h
218
+
219
+ end
220
+
187
221
  def format_portfolio(r, order_by: :rank)
188
222
 
189
223
  coins = r.records.sort_by {|x| -x[order_by].to_f}.map {|x| x.values}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mycoins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -30,7 +30,7 @@ cert_chain:
30
30
  sCz5KsiHA9vj8OfrxhYrEb+ML4+J28Umdki7V1vgnQWmnI+Ok2SWlkScgzcmGXF6
31
31
  TJ4=
32
32
  -----END CERTIFICATE-----
33
- date: 2018-01-09 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: dynarex
metadata.gz.sig CHANGED
Binary file