cryptocoin_fanboi 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c2ea507a04381ea847547b11a0802abbc38bc884
4
- data.tar.gz: ad0444638682f8e4b7ef57845514d6a10cba6ab3
3
+ metadata.gz: b01a628c230f7ecb7ba8d3a55a2f972ef0afcacb
4
+ data.tar.gz: 00b0c8d8f6d6c223d3b9749bcd708aad41290771
5
5
  SHA512:
6
- metadata.gz: 1d21443b5a274fb3422052bc196b321e17a81d9be728e94707ccbb36ba473d0c258d68cccdeb6bae57474fdc654041b1beab3a097aeb240bc89ad64d886ab88d
7
- data.tar.gz: 16a1f4d539ed3f101df42f10597da4ef83ce8cc89630d010eeb0398552b8bbc70893ebf0eaf25face638fd9e03ce2afac608d654b38e76ac922ddf0c45e1704f
6
+ metadata.gz: 19d0075ef5991cbf4153fd4d8d5fb400fb7fcde152d0fc604214f31fa13ddb8848d21f49bdb34a160772a6d016968f7c926b7bc4022f09f4076ec6194a179499
7
+ data.tar.gz: 07ccb00344da653e5fccbf41522eef5679a6093bc621ae9e8fc65ce110f1d463e5738029678aea32d7403ac8a350c7096b04057a7a7895158e543ce4e40d1a5a
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
@@ -1 +1,3 @@
1
- �QH
1
+ q�y�IJǛ���g�k��[�c�;E�,t|n��V X�0=+p*��V�oO����;Ta'�[�%B�Q����0!EV�%��8��pnM�����K�C7��&f�s�#�8
2
+ �g�o�x�pK��=�3��si�G�i���ճ�n{ ������ᑃD)!��V�է7�J��..�
3
+ �BJB�����IK�~�H[�F�-�C��ni�S�5�GD�b�?�]�q$�=�ۉ���]��� W��H�ma�xQ
@@ -3,6 +3,7 @@
3
3
  # file: cryptocoin_fanboi.rb
4
4
 
5
5
 
6
+ require 'colored'
6
7
  require 'coinmarketcap'
7
8
  require 'table-formatter'
8
9
 
@@ -10,9 +11,11 @@ require 'table-formatter'
10
11
  class CryptocoinFanboi
11
12
 
12
13
  attr_reader :coins
14
+ attr_accessor :colored
13
15
 
14
- def initialize(watch: [])
16
+ def initialize(watch: [], colored: true)
15
17
 
18
+ @colored = colored
16
19
  @watch = watch.map(&:upcase)
17
20
 
18
21
  @fields = %w(rank name price_usd price_btc percent_change_1h
@@ -33,18 +36,17 @@ class CryptocoinFanboi
33
36
  # View the coins with the largest gains in the past hour
34
37
  #
35
38
  def now(limit: 5, markdown: false)
36
-
37
- TableFormatter.new(source: top_coins('1h', limit: limit),
38
- labels: @labels, markdown: markdown).display
39
+
40
+ build_table top_coins('1h', limit: limit), markdown: markdown
41
+
39
42
  end
40
43
 
41
44
  # View the coins with the largest gains this week (past 7 days)
42
45
  #
43
46
  def this_week(limit: 5, markdown: false)
44
47
 
45
- TableFormatter.new(source: top_coins(limit: limit),
46
- labels: @labels, markdown: markdown).display
47
- #top_coins(limit: limit)
48
+ build_table top_coins(limit: limit), markdown: markdown
49
+
48
50
  end
49
51
 
50
52
  alias week this_week
@@ -53,8 +55,8 @@ class CryptocoinFanboi
53
55
  #
54
56
  def today(limit: 5, markdown: false)
55
57
 
56
- TableFormatter.new(source: top_coins('24h', limit: limit),
57
- labels: @labels, markdown: markdown).display
58
+ build_table top_coins('24h', limit: limit), markdown: markdown
59
+
58
60
  end
59
61
 
60
62
  def to_s(limit: nil, markdown: false, watch: @watch)
@@ -65,11 +67,32 @@ class CryptocoinFanboi
65
67
 
66
68
  end
67
69
 
68
- TableFormatter.new(source: coins, labels: @labels, markdown: markdown).display
70
+ build_table coins, markdown: markdown
69
71
 
70
72
  end
71
73
 
72
74
  private
75
+
76
+ def build_table(coins, markdown: markdown)
77
+
78
+ s = TableFormatter.new(source: coins, labels: @labels, markdown: markdown)\
79
+ .display
80
+
81
+ return s if @colored == false
82
+
83
+ a = s.lines
84
+
85
+ body = a[3..-2].map do |line|
86
+
87
+ fields = line.split('|')
73
88
 
89
+ a2 = fields[5..-2].map {|x|
74
90
  x[/^ +-/] ? x.red : x.green
75
91
  }
92
+ (fields[0..4] + a2 + ["\n"]).join('|')
93
+
94
+ end
95
+
96
+ (a[0..2] + body + [a[-1]]).join
97
+
98
+ end
76
99
 
77
100
  def fetch_coinlist(limit: nil, watch: [])
78
101
 
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.1.3
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -32,6 +32,26 @@ cert_chain:
32
32
  -----END CERTIFICATE-----
33
33
  date: 2018-01-02 00:00:00.000000000 Z
34
34
  dependencies:
35
+ - !ruby/object:Gem::Dependency
36
+ name: colored
37
+ requirement: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.2'
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '1.2'
45
+ type: :runtime
46
+ prerelease: false
47
+ version_requirements: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - "~>"
50
+ - !ruby/object:Gem::Version
51
+ version: '1.2'
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '1.2'
35
55
  - !ruby/object:Gem::Dependency
36
56
  name: coinmarketcap
37
57
  requirement: !ruby/object:Gem::Requirement
@@ -102,6 +122,6 @@ rubyforge_project:
102
122
  rubygems_version: 2.6.13
103
123
  signing_key:
104
124
  specification_version: 4
105
- summary: A coinmarketcap wrapper which makes it convenient to display the top 5 crypto
106
- currencies as listed on https://coinmarketcap.com.
125
+ summary: A coinmarketcap wrapper which makes it convenient to display the top 5 cryptocurrencies
126
+ as listed on https://coinmarketcap.com.
107
127
  test_files: []
metadata.gz.sig CHANGED
Binary file