cryptocoin_fanboi 0.5.5 → 0.6.0

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
- SHA1:
3
- metadata.gz: c8c01db0ba86abf6939aa6d3fb419f89fb41543d
4
- data.tar.gz: 2586baac25d7ad61c6633c317fa62e26b02c353c
2
+ SHA256:
3
+ metadata.gz: 5b9ac014b2f7cc7558b843bf2b7d7361263be34b3436048d574eeb2924fe0f6a
4
+ data.tar.gz: 6c7353c942ff0e1f52cd505fcdac863101c1cb831c01062ead4d88cf94ac5fb8
5
5
  SHA512:
6
- metadata.gz: d61ad6f22245e99e426645d89d4c628da567ab011ec4a2b7950f77520c21786f6d6ac1c53834dbf48b435b8ddd6df5a45ecee3afc4e9e89f9e22b23dc6beb329
7
- data.tar.gz: cb7967d37939570d7333f5d61f7539e61822a7b356eaf6a5d0f2eaec689cab27cfe42a5ebb09a7336833892077ae20ca9a89192b573609cf2b6c1ff2e1bb0b11
6
+ metadata.gz: 9d8820c768ed1b33ffcfdd54b249c6072d9bc6be4775b1c4d8a707f9a5f7386c13e04d426a183acfe14ecdedf372cd1045411b9fe9e25771426f2804293d875e
7
+ data.tar.gz: 131381228b4bc43b45acfad712e50eb8a119f3e7d179bbd6478dba70411be294d9d1379afb1c335c28b777b8efd25237d350eb0c949602d9005d5e0329339911
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -47,7 +47,7 @@ module Colour
47
47
 
48
48
  return x if x.to_s.strip.empty? or @colored == false
49
49
 
50
- s3 = (x.to_s.sub(/[\d\.\-]+/) {|s2| "%.2f" % s2})
50
+ s3 = (x.to_s.sub(/[\d\.\-]+/) {|s2| "%.2f" % s2.to_f})
51
51
  s = s3.length == x.to_s.length ? s3 : s3.sub(/ /,'')
52
52
 
53
53
  s[/^ *-/] ? s.red : s.green
@@ -59,25 +59,32 @@ end
59
59
 
60
60
  class CryptocoinFanboi
61
61
  include Colour
62
+ using ColouredText
62
63
 
63
64
  attr_reader :coins, :all_coins
64
65
  attr_accessor :colored
65
66
 
66
- def initialize(watch: [], ignore: [], colored: true,
67
- debug: false, filepath: '.', exchangerate_key: nil)
67
+ def initialize(watch: [], ignore: [], colored: true, debug: false,
68
+ filepath: '.', exchangerate_key: nil, cmc_apikey: nil)
68
69
 
69
- @colored, @debug, @filepath, @exchangerate_key = colored, debug, \
70
- filepath, exchangerate_key
70
+ @colored, @debug, @filepath = colored, debug, filepath
71
+ @exchangerate_key, @cmc_apikey = exchangerate_key, cmc_apikey
71
72
 
72
73
  @watch= watch.map(&:upcase)
73
74
  @ignore = ignore.map(&:upcase)
74
75
 
75
- @fields = %w(rank name price_usd price_btc percent_change_1h
76
- percent_change_24h percent_change_7d percent_change_year)
76
+
77
+ #@fields = %w(rank name price_usd price_btc percent_change_1h
78
+ # percent_change_24h percent_change_7d percent_change_year)
79
+
77
80
 
81
+ @fields = %w(price percent_change_1h percent_change_24h percent_change_7d)
82
+
78
83
  @year = Time.now.year
79
- @labels = %w(Rank Name USD BTC) + ['% 1hr:', '% 24hr:',
80
- '% 1 week:', '% ' + @year.to_s + ':']
84
+ #@labels = %w(Rank Name USD BTC) + ['% 1hr:', '% 24hr:',
85
+ # '% 1 week:', '% ' + @year.to_s + ':']
86
+ @labels = %w(Rank Name USD) + ['% 1hr:', '% 24hr:',
87
+ '% 1 week:']
81
88
  coins = fetch_coinlist()
82
89
 
83
90
  # check for the local cache file containing a record of currency
@@ -203,7 +210,8 @@ class CryptocoinFanboi
203
210
  puts 'inside find: name: ' + name.inspect
204
211
  puts 'coins: ' + @coins.inspect
205
212
  end
206
- coins.find {|coin| coin.name =~ /#{name}/i }
213
+
214
+ coins.find {|coin| coin.name =~ /#{name}/i or coin.symbol =~ /#{name}/i}
207
215
 
208
216
  end
209
217
 
@@ -225,7 +233,7 @@ class CryptocoinFanboi
225
233
 
226
234
  coin = raw_coin.downcase.split.map(&:capitalize).join(' ')
227
235
 
228
- return self.coin(coin).price_usd.to_f if raw_date.nil?
236
+ return self.coin(coin).quote['USD']['price'].to_f if raw_date.nil?
229
237
  puts 'raw_date: ' + raw_date.inspect if @debug
230
238
 
231
239
  date = if raw_date.is_a? Date then
@@ -239,7 +247,7 @@ class CryptocoinFanboi
239
247
 
240
248
  if date == Date.today.strftime("%Y%m%d")
241
249
  puts 'same day' if @debug
242
- return self.coin(coin).price_usd.to_f
250
+ return self.coin(coin).quote['USD']['price'].to_f
243
251
  end
244
252
 
245
253
 
@@ -256,7 +264,7 @@ class CryptocoinFanboi
256
264
  a = Coinmarketcap.get_historical_price(coin.gsub(/ /,'-'), date, date)
257
265
  puts 'a: ' + a.inspect if @debug
258
266
 
259
- r = a.any? ? a.first[:close] : self.coin(coin).price_usd.to_f
267
+ r = a.any? ? a.first[:close] : self.coin(coin).quote['USD']['price'].to_f
260
268
 
261
269
  @history_prices[coin] ||= {}
262
270
  @history_prices[coin][date] = r
@@ -346,16 +354,19 @@ class CryptocoinFanboi
346
354
 
347
355
  coins2 = add_year_growth(coins)
348
356
 
349
- puts 'coins2: ' + coins2.inspect
357
+ puts ('coins2: ' + coins2.inspect).debug if @debg
350
358
 
351
359
  coins3 = coins2.map do |coin|
352
360
 
353
- puts 'coin: ' + coin.inspect if @debug
354
- @fields.map {|x| coin[x] }
355
-
361
+ puts ('coin: ' + coin.inspect).debug if @debug
362
+ a2 = %w(cmc_rank name).map {|x| coin[x]}
363
+ puts 'a2: ' + a2.inspect
364
+ a3 = @fields.map {|x| coin['quote']['USD'][x] }
365
+ puts 'a3: ' + a3.inspect
366
+ a2 + a3
356
367
  end
357
368
 
358
- puts 'coins3: ' + coins3.inspect if @debug
369
+ puts ('coins3: ' + coins3.inspect).debug if @debug
359
370
 
360
371
 
361
372
  build_table coins3, markdown: markdown
@@ -422,7 +433,8 @@ class CryptocoinFanboi
422
433
 
423
434
  def fetch_coinlist(limit: nil)
424
435
 
425
- @all_coins = JSON.parse(Coinmarketcap.coins.body)\
436
+ body = CoinmarketcapLite.new(apikey: @cmc_apikey).coins.body
437
+ @all_coins = JSON.parse(body)['data']\
426
438
  .map {|x| OpenStruct.new x}
427
439
 
428
440
  if @watch.any? then
@@ -481,7 +493,7 @@ class CryptocoinFanboi
481
493
 
482
494
  if year_start_price then
483
495
 
484
- latest_day = coin.price_usd.to_f
496
+ latest_day = coin.quote['USD']['price'].to_f
485
497
  puts "latest_day: %s year_start: %s" % \
486
498
  [latest_day, year_start_price] if @debug
487
499
  r.merge({coin.name => (100.0 / (year_start_price /
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.5.5
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -10,46 +10,51 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDXjCCAkagAwIBAgIBATANBgkqhkiG9w0BAQUFADAsMSowKAYDVQQDDCFnZW1t
14
- YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMTgwMTAxMTUyOTA5WhcN
15
- MTkwMTAxMTUyOTA5WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
- cnRzb24vREM9ZXUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCpXhDL
17
- e2JxhzdO329Vgleg5uFMyOpzvGdE0DTCxEPuJI3eLHly8LlP5L5QbL52eV5nsr0h
18
- GRrhJfyFw98UzZrLy1HQGzLakcY5Bg7F9o6WSOskpr10XCbbYDhIPkghtYfXEkPW
19
- PV8p2IU9PcSuZU4hyurz0rxiiWfm+L5I4d+ic9iKg9nuoRwF7EkAPZIa2JstFNiw
20
- jNs4b3NHM5/DsCqDT4gZ9tESIxCLXYkrhEJkfcJ2hm3O3Oqp/eitz05HzrBR9P+T
21
- K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SRujMMwHo+V8R
34
+ JljNbD5oOMfl5PtG9kMRtQdiNAM0Ju37QO8MUcGtLqhChxBY9LnKZQPPyWuuw0t4
35
+ rf70OqfIBGSc7l8KgCsJdPq9sfGaqkwP5aJtKCMWYTPzHZ26Gl9HxOQDR/bfMZbt
36
+ jporVuRIHCzaaXjuFOXEPBUx
32
37
  -----END CERTIFICATE-----
33
- date: 2018-06-08 00:00:00.000000000 Z
38
+ date: 2019-05-25 00:00:00.000000000 Z
34
39
  dependencies:
35
40
  - !ruby/object:Gem::Dependency
36
41
  name: colored
37
42
  requirement: !ruby/object:Gem::Requirement
38
43
  requirements:
39
- - - "~>"
44
+ - - ">="
40
45
  - !ruby/object:Gem::Version
41
46
  version: '1.2'
42
- - - ">="
47
+ - - "~>"
43
48
  - !ruby/object:Gem::Version
44
49
  version: '1.2'
45
50
  type: :runtime
46
51
  prerelease: false
47
52
  version_requirements: !ruby/object:Gem::Requirement
48
53
  requirements:
49
- - - "~>"
54
+ - - ">="
50
55
  - !ruby/object:Gem::Version
51
56
  version: '1.2'
52
- - - ">="
57
+ - - "~>"
53
58
  - !ruby/object:Gem::Version
54
59
  version: '1.2'
55
60
  - !ruby/object:Gem::Dependency
@@ -76,82 +81,102 @@ dependencies:
76
81
  name: coinmarketcap
77
82
  requirement: !ruby/object:Gem::Requirement
78
83
  requirements:
79
- - - "~>"
80
- - !ruby/object:Gem::Version
81
- version: '0.2'
82
84
  - - ">="
83
85
  - !ruby/object:Gem::Version
84
- version: 0.2.4
86
+ version: 0.3.0
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.3'
85
90
  type: :runtime
86
91
  prerelease: false
87
92
  version_requirements: !ruby/object:Gem::Requirement
88
93
  requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 0.3.0
89
97
  - - "~>"
90
98
  - !ruby/object:Gem::Version
91
- version: '0.2'
99
+ version: '0.3'
100
+ - !ruby/object:Gem::Dependency
101
+ name: coinmarketcap_lite
102
+ requirement: !ruby/object:Gem::Requirement
103
+ requirements:
92
104
  - - ">="
93
105
  - !ruby/object:Gem::Version
94
- version: 0.2.4
106
+ version: 0.1.0
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: '0.1'
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: 0.1.0
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: '0.1'
95
120
  - !ruby/object:Gem::Dependency
96
121
  name: table-formatter
97
122
  requirement: !ruby/object:Gem::Requirement
98
123
  requirements:
99
- - - "~>"
100
- - !ruby/object:Gem::Version
101
- version: '0.5'
102
124
  - - ">="
103
125
  - !ruby/object:Gem::Version
104
- version: 0.5.0
126
+ version: 0.7.0
127
+ - - "~>"
128
+ - !ruby/object:Gem::Version
129
+ version: '0.7'
105
130
  type: :runtime
106
131
  prerelease: false
107
132
  version_requirements: !ruby/object:Gem::Requirement
108
133
  requirements:
109
- - - "~>"
110
- - !ruby/object:Gem::Version
111
- version: '0.5'
112
134
  - - ">="
113
135
  - !ruby/object:Gem::Version
114
- version: 0.5.0
136
+ version: 0.7.0
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '0.7'
115
140
  - !ruby/object:Gem::Dependency
116
141
  name: rexle
117
142
  requirement: !ruby/object:Gem::Requirement
118
143
  requirements:
119
144
  - - "~>"
120
145
  - !ruby/object:Gem::Version
121
- version: '1.4'
146
+ version: '1.5'
122
147
  - - ">="
123
148
  - !ruby/object:Gem::Version
124
- version: 1.4.12
149
+ version: 1.5.1
125
150
  type: :runtime
126
151
  prerelease: false
127
152
  version_requirements: !ruby/object:Gem::Requirement
128
153
  requirements:
129
154
  - - "~>"
130
155
  - !ruby/object:Gem::Version
131
- version: '1.4'
156
+ version: '1.5'
132
157
  - - ">="
133
158
  - !ruby/object:Gem::Version
134
- version: 1.4.12
159
+ version: 1.5.1
135
160
  - !ruby/object:Gem::Dependency
136
161
  name: kramdown
137
162
  requirement: !ruby/object:Gem::Requirement
138
163
  requirements:
139
- - - "~>"
140
- - !ruby/object:Gem::Version
141
- version: '1.16'
142
164
  - - ">="
143
165
  - !ruby/object:Gem::Version
144
- version: 1.16.2
166
+ version: 2.1.0
167
+ - - "~>"
168
+ - !ruby/object:Gem::Version
169
+ version: '2.1'
145
170
  type: :runtime
146
171
  prerelease: false
147
172
  version_requirements: !ruby/object:Gem::Requirement
148
173
  requirements:
149
- - - "~>"
150
- - !ruby/object:Gem::Version
151
- version: '1.16'
152
174
  - - ">="
153
175
  - !ruby/object:Gem::Version
154
- version: 1.16.2
176
+ version: 2.1.0
177
+ - - "~>"
178
+ - !ruby/object:Gem::Version
179
+ version: '2.1'
155
180
  - !ruby/object:Gem::Dependency
156
181
  name: justexchangerates
157
182
  requirement: !ruby/object:Gem::Requirement
@@ -161,7 +186,7 @@ dependencies:
161
186
  version: '0.3'
162
187
  - - ">="
163
188
  - !ruby/object:Gem::Version
164
- version: 0.3.2
189
+ version: 0.3.4
165
190
  type: :runtime
166
191
  prerelease: false
167
192
  version_requirements: !ruby/object:Gem::Requirement
@@ -171,7 +196,7 @@ dependencies:
171
196
  version: '0.3'
172
197
  - - ">="
173
198
  - !ruby/object:Gem::Version
174
- version: 0.3.2
199
+ version: 0.3.4
175
200
  description:
176
201
  email: james@jamesrobertson.eu
177
202
  executables: []
@@ -198,8 +223,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
223
  - !ruby/object:Gem::Version
199
224
  version: '0'
200
225
  requirements: []
201
- rubyforge_project:
202
- rubygems_version: 2.6.13
226
+ rubygems_version: 3.0.1
203
227
  signing_key:
204
228
  specification_version: 4
205
229
  summary: A coinmarketcap wrapper which makes it convenient to display the top 5 cryptocurrencies
metadata.gz.sig CHANGED
@@ -1 +1,5 @@
1
- c5��x�c��p�������j������%���.\K鋵nƼ����ai<�����G���U�+~�(�QF�$�w�މ��O��Ҋ^Fp\A�Zp�PO,��|g�'�7�"G�KʿȌؾ�p+��p~�QW�Q*��i���f�睈���痼=������Y�E��s�r�S<��uX�T�jV{�D���|�(JKn�|��]��<6���5$ܼzcO���B��
1
+
2
+ N%�Ć�@ۮUE�
3
+ x�nM �;,��W�.�#\.!�|'�nN�r(��G}��λ���|�ߔ�V7�
4
+ ��*��C�=;>�:������An�<��خ[�Xb"�w��-��؉BϺ�}m������L��F�S�ژIY� ^SU�����R�rj�9x�fy��Y(��Ĩ�����0Gů��"��#7![�Y����5%&Uf�
5
+ �H�}H4�"�^�Dn��,��r������ �&�z�