cryptocoin_fanboi 0.4.1 → 0.4.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: bf1a8ad5d161f30013983f99a8d5a85a19092d6f
4
- data.tar.gz: 70248b238934c7e1c2de48381a82635bb2298fd9
3
+ metadata.gz: 98f848c11cba71805e0d72a61304caee942fb420
4
+ data.tar.gz: cc1a5bbfaa5c0c4db2949e0c28a34172bad45fe3
5
5
  SHA512:
6
- metadata.gz: 3c903735f66caafbf30726bfa186f7a0529d76e212e16c6b47a32ce26869236f6d21ea4b50bcaa1e2014bafaf82cbadca780303bce5c660e799ec535a666234a
7
- data.tar.gz: 7bfe0284e3bfe63cabee595be74ff1309c11e007a0e59820536928be02b44623aa78c54c6b128e7f2772ace54a7176e2ca30a9d54f7f240f7b132f989cf4ec86
6
+ metadata.gz: 9556ed28d1166b3cc49b79b1d7e0d0e102be886734c7330a2498941fca1454b957ff3681ff57e8c56d1b70b5605c0b5a04f0215e68f11d0b033b0438e625cc10
7
+ data.tar.gz: f7294af6c79c8635c46627ef7ed4630a159171ff7043b406798b6c73052734cce6b61cfcc0f8c7a073d84e374d3e2210512abdeeb21b2c1ce3a3b944c06dbb23
checksums.yaml.gz.sig CHANGED
Binary file
@@ -10,6 +10,7 @@ require 'table-formatter'
10
10
  require 'rxfhelper'
11
11
  require 'rexle'
12
12
  require 'kramdown'
13
+ require 'justexchangerates'
13
14
 
14
15
 
15
16
  =begin
@@ -104,6 +105,10 @@ class CryptocoinFanboi
104
105
  @coins.map {|x| "%s (%s)" % [x['name'], x['symbol']] }
105
106
  end
106
107
 
108
+ def coin(name)
109
+ self.find(name)
110
+ end
111
+
107
112
  def coins()
108
113
  @coins.map {|x| OpenStruct.new(x) }
109
114
  end
@@ -141,7 +146,9 @@ class CryptocoinFanboi
141
146
  # returns closing price in dollars
142
147
  # e.g. price('tron', '8th September 2017') #=> 0.001427
143
148
  #
144
- def price(coin, raw_date)
149
+ def price(coin, raw_date=nil)
150
+
151
+ return self.coin(coin).price_usd.to_f if raw_date.nil?
145
152
 
146
153
  date = Chronic.parse(raw_date.gsub('-',' ')).strftime("%Y%m%d")
147
154
  puts 'date: ' + date.inspect if @debug
@@ -149,10 +156,8 @@ class CryptocoinFanboi
149
156
  # if date is today then return today's price
150
157
 
151
158
  if date == Date.today.strftime("%Y%m%d")
152
-
153
- r = Coinmarketcap.coin(coin)
154
- return r.parsed_response.first['price_usd'].to_f
155
-
159
+ puts 'same day' if @debug
160
+ return self.coin(coin).price_usd.to_f
156
161
  end
157
162
 
158
163
 
@@ -182,6 +187,18 @@ class CryptocoinFanboi
182
187
  end
183
188
 
184
189
  end
190
+
191
+ # returns an array of the prices of Bitcoin in various currencies
192
+ #
193
+ def rates(coin='Bitcoin', currencies: %w(EUR GBP))
194
+
195
+ jeg = JustExchangeRates.new(base: 'USD')
196
+ usd = self.price(coin).round(2)
197
+ ([:USD] + currencies.map(&:to_sym)).zip(
198
+ [usd, *currencies.map {|currency| (usd * jeg.rate(currency)).round(2) }]
199
+ ).to_h
200
+
201
+ end
185
202
 
186
203
  # View the coins with the largest gains this week (past 7 days)
187
204
  #
data.tar.gz.sig CHANGED
Binary file
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.4.1
4
+ version: 0.4.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-03-07 00:00:00.000000000 Z
33
+ date: 2018-03-08 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: colored
@@ -98,20 +98,20 @@ dependencies:
98
98
  requirements:
99
99
  - - "~>"
100
100
  - !ruby/object:Gem::Version
101
- version: '0.4'
101
+ version: '0.5'
102
102
  - - ">="
103
103
  - !ruby/object:Gem::Version
104
- version: 0.4.5
104
+ version: 0.5.0
105
105
  type: :runtime
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
109
  - - "~>"
110
110
  - !ruby/object:Gem::Version
111
- version: '0.4'
111
+ version: '0.5'
112
112
  - - ">="
113
113
  - !ruby/object:Gem::Version
114
- version: 0.4.5
114
+ version: 0.5.0
115
115
  - !ruby/object:Gem::Dependency
116
116
  name: rexle
117
117
  requirement: !ruby/object:Gem::Requirement
@@ -152,6 +152,26 @@ dependencies:
152
152
  - - ">="
153
153
  - !ruby/object:Gem::Version
154
154
  version: 1.16.2
155
+ - !ruby/object:Gem::Dependency
156
+ name: justexchangerates
157
+ requirement: !ruby/object:Gem::Requirement
158
+ requirements:
159
+ - - "~>"
160
+ - !ruby/object:Gem::Version
161
+ version: '0.2'
162
+ - - ">="
163
+ - !ruby/object:Gem::Version
164
+ version: 0.2.1
165
+ type: :runtime
166
+ prerelease: false
167
+ version_requirements: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - "~>"
170
+ - !ruby/object:Gem::Version
171
+ version: '0.2'
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: 0.2.1
155
175
  description:
156
176
  email: james@jamesrobertson.eu
157
177
  executables: []
metadata.gz.sig CHANGED
Binary file