mycoins 0.2.6 → 0.2.7
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 +0 -0
- data.tar.gz.sig +0 -0
- data/lib/mycoins.rb +24 -6
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8c33d039b936cfe61a4e29a73747d922f97947a
|
4
|
+
data.tar.gz: 1b302ae8333e53073695606e24194e000fa943c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0511114a5f1f14f5e3bc4fa3c0382a04cdc41c74704f6d62f135b4bbe0fc5afbe11f5f110337f4d46560185cdf47c127888020a747522a0c2551d1b625d7ce4
|
7
|
+
data.tar.gz: e30fd3f9cabb2ae49b12c6a7fd1cf5138139191f9ff54114caf261f4f9b805e87bb72042039b950866577365424803c93b4934bf851b87f570501e8e5cb3a6bf
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/mycoins.rb
CHANGED
@@ -12,9 +12,9 @@ class MyCoins
|
|
12
12
|
attr_accessor :mycurrency
|
13
13
|
|
14
14
|
def initialize(source, date: nil, debug: false,
|
15
|
-
mycurrency: 'USD', filepath: 'mycoins')
|
15
|
+
mycurrency: 'USD', filepath: 'mycoins', colored: true)
|
16
16
|
|
17
|
-
@debug, @filepath = debug, filepath
|
17
|
+
@debug, @filepath, @color = debug, filepath, colored
|
18
18
|
|
19
19
|
@jer = JustExchangeRates.new(base: 'USD')
|
20
20
|
|
@@ -27,8 +27,6 @@ class MyCoins
|
|
27
27
|
|
28
28
|
end
|
29
29
|
|
30
|
-
|
31
|
-
|
32
30
|
puts '@dx.to_xml: ' + @dx.to_xml if @debug
|
33
31
|
|
34
32
|
@mycurrency = (@dx.currency || mycurrency).upcase
|
@@ -218,6 +216,26 @@ class MyCoins
|
|
218
216
|
|
219
217
|
end
|
220
218
|
|
219
|
+
def format_table(source, markdown: markdown, labels: [])
|
220
|
+
|
221
|
+
s = TableFormatter.new(source: source, labels: labels).display
|
222
|
+
|
223
|
+
return s if @colored == false
|
224
|
+
|
225
|
+
a = s.lines
|
226
|
+
|
227
|
+
body = a[3..-2].map do |line|
|
228
|
+
|
229
|
+
fields = line.split('|')
|
230
|
+
|
231
|
+
a2 = fields[-3..-1].map {|x| x[/^ +-/] ? x.red : x.green }
|
232
|
+
(fields[0..-4] + a2 ).join('|')
|
233
|
+
|
234
|
+
end
|
235
|
+
|
236
|
+
(a[0..2] + body + [a[-1]]).join
|
237
|
+
end
|
238
|
+
|
221
239
|
def format_portfolio(r, order_by: :rank)
|
222
240
|
|
223
241
|
coins = r.records.sort_by {|x| -x[order_by].to_f}.map {|x| x.values}
|
@@ -230,11 +248,11 @@ class MyCoins
|
|
230
248
|
|
231
249
|
puts 'labels: ' + labels.inspect if @debug
|
232
250
|
|
233
|
-
tf = TableFormatter.new(source: coins, labels: labels)
|
234
251
|
out = "# " + @dx.title + "\n\n"
|
235
252
|
out << "last_updated: %s\n\n" % r.datetime
|
236
|
-
out << tf.display
|
237
253
|
|
254
|
+
out << format_table(coins, labels: labels)
|
255
|
+
|
238
256
|
out << "\n\nInvested: %.2f %s" % [r.invested, @mycurrency]
|
239
257
|
out << "\n\nGross profit: %.2f %s (%.2f%%)" % \
|
240
258
|
[r.gross_profit, @mycurrency, r.pct_gross_profit]
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|