coingecko 0.1.1 → 0.1.2

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
  SHA256:
3
- metadata.gz: 48b4397bf74ea4b535260bce5ecd1a588443416781e84694e946d41c2107c39a
4
- data.tar.gz: 511e1abc7b062248975bafd5e5156ca745a37480454b3b7a1a8a17cc07042825
3
+ metadata.gz: '0409aa1d9675f49b4c52ed80abd5c14590a945c6e0110c9c0bc292fd25db29bc'
4
+ data.tar.gz: f28cc622c5fba816540f29a8e824ee64f08455de808ffa8ec93d5b2f14c92589
5
5
  SHA512:
6
- metadata.gz: 6c3e74300d862708ac2b2e523de55fc937f577468218f965e52e2e4499f7bdd34540109155cb0ed8183d19947ad28ad81217c16f38558cb3c9fd80e2367c7f18
7
- data.tar.gz: 26e7fd0f781ab207e60fed0e23783cd147f521bf26953032ebda3602d194265acd65ccc8ec4cab2fb1b9cb4a8b7a4401aafda4b37a68c24275782f775c999cc6
6
+ metadata.gz: 7dfff11af8eead37a2d76976a534c3dcf890309fab4feb9825c1ea91b4c059583b1cfa609d54ebd6a7b0a426ba0f4bdfd6412ef8329f45c60800aadd0336dd6c
7
+ data.tar.gz: 763cfe61c0d2d21bb6f2805810e0e231f64ac2d29127a159c15d389ec0d810164691c76568155c8f9108849c6de3dfddb0ea69dbd6287dc833691b5006856f46
@@ -0,0 +1 @@
1
+ *.gem
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- coingecko (0.1.0)
4
+ coingecko (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -48,4 +48,4 @@ DEPENDENCIES
48
48
  terminal-table (~> 1.8)
49
49
 
50
50
  BUNDLED WITH
51
- 2.0.1
51
+ 2.0.2
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # Coingecko - A CoinGecko API with CLI Interface
2
2
 
3
- Pushes all coin data from Coingecko API. Also lists top 100 coins.
3
+ Pushes all coin data from Coingecko API. Also lists top 100 coins and overall market info.
4
4
 
5
- Disclaimer: This is my first Ruby gem so any feedback is greatly welcomed!
5
+ Disclaimer: This is my first published Ruby gem so any feedback is greatly welcomed!
6
6
 
7
7
  ## Installation
8
8
 
@@ -20,7 +20,7 @@ Or install it yourself as:
20
20
 
21
21
  $ gem install coingecko
22
22
 
23
- ## Usage
23
+ ## Development Usage
24
24
 
25
25
  A CLI console is provided to lookup coins or list top 100 coins. It also provides a print feature of basic coin attributes. However, all coin attributes can be read as it pulls directly from Coingecko API. To launch the console just launch it from bin folder E.g.
26
26
 
@@ -28,7 +28,7 @@ A CLI console is provided to lookup coins or list top 100 coins. It also provide
28
28
  ruby bin/coingecko
29
29
  ```
30
30
 
31
- ## Development
31
+ ## Development Testing
32
32
 
33
33
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
34
34
 
@@ -36,7 +36,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
36
36
 
37
37
  ## Contributing
38
38
 
39
- Bug reports and pull requests are welcome on GitHub at https://github.com/'courageoustuple'/coingecko. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
39
+ Bug reports and pull requests are welcome on GitHub at https://github.com/fbohz/coingecko. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
40
40
 
41
41
  ## License
42
42
 
File without changes
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["''"]
11
11
 
12
12
  spec.summary = "tbd"
13
- spec.description = "Pushes all coin data from Coingecko API. Also lists top 100 coins. This is my first Ruby gem so any feedback is greatly welcomed!"
13
+ spec.description = "Pushes all coin data from Coingecko API. Please see my repo for usage. This is my first Ruby gem so any feedback is greatly welcomed!"
14
14
  spec.homepage = "https://github.com/fbohz/coingecko.git"
15
15
  spec.license = "MIT"
16
16
 
@@ -1,36 +1,36 @@
1
1
  class Coingecko::CLI
2
2
  @@commands = ["ls", "list", "b", "back", "menu", "m", "q", "quit", "exit", "exit!", "find", "f"]
3
-
4
- def run
3
+
4
+ def run
5
5
  welcome
6
6
  sleep 0.5
7
- selection
8
- end
9
-
10
- def welcome
7
+ selection
8
+ end
9
+
10
+ def welcome
11
11
  puts "\nWelcome to Coingecko! Powered by CoinGecko API.\n"
12
- end
13
-
14
- def selection
12
+ end
13
+
14
+ def selection
15
15
  puts "\nWhat would you like to do? For the main menu please type menu."
16
- input = gets.strip.downcase
16
+ input = gets.strip.downcase
17
17
  self.check_selection(input) #from now on self will be implicit as method receiver.
18
- end
19
-
18
+ end
19
+
20
20
  def another_selection?
21
21
  puts "Would you like make another selection?"
22
22
  input = gets.strip.downcase
23
23
  if input == "y" || input == "yes"
24
24
  main_menu
25
- elsif input == "n" || input == "no"
25
+ elsif input == "n" || input == "no"
26
26
  quit
27
27
  return
28
- else
28
+ else
29
29
  check_selection(input)
30
- end
31
- end
32
-
33
-
30
+ end
31
+ end
32
+
33
+
34
34
  def main_menu
35
35
  puts "\n-To list the top 100 coins type ls."
36
36
  puts "-To find a coin by name, type find."
@@ -38,80 +38,80 @@ class Coingecko::CLI
38
38
  puts "-To QUIT: please type q."
39
39
  sleep 1
40
40
  selection
41
- end
42
-
41
+ end
42
+
43
43
  def list_top_coins
44
44
  list = Coingecko::Coin.new_from_top_100
45
45
  print_top(list)
46
46
  end
47
-
48
- def check_selection(input)
47
+
48
+ def check_selection(input)
49
49
  case input
50
50
  when "ls", "list"
51
- list_top_coins
51
+ list_top_coins
52
52
  when "menu", "m", "back", "b"
53
53
  main_menu
54
54
  when "q", "quit", "exit", "exit!"
55
- quit
56
- when "global", "g", "gen", "general"
55
+ quit
56
+ when "global", "g", "gen", "general"
57
57
  print_global_info
58
- when "find", "f"
58
+ when "find", "f"
59
59
  find
60
- else
60
+ else
61
61
  puts "Sorry! Did not Understand that."
62
62
  sleep 1
63
63
  puts "Going back.."
64
64
  sleep 1
65
65
  selection
66
66
  end
67
- end
67
+ end
68
68
 
69
69
  def print_top(list)
70
70
  puts "Here are the Top 100 Coins!"
71
71
  sleep 1.0
72
- puts ".."
72
+ puts ".."
73
73
  sleep 1.0
74
- puts "....\n\n"
74
+ puts "....\n\n"
75
75
  sleep 0.5
76
76
  Coingecko::Coin.top_coins.each_with_index do |coin, index|
77
77
  puts "#{index + 1}. #{coin.name}"
78
- end
78
+ end
79
79
  sleep 0.5
80
80
  puts "\n\nWhich coin would you like to check out? Please type a number 1-100."
81
- answer = gets.chomp.to_i
82
-
81
+ answer = gets.chomp.to_i
82
+
83
83
  if answer > 0 #if string converted to_i will have value of 0
84
84
  id = Coingecko::Coin.top_coins[answer - 1].id
85
85
  print_coin(id)
86
86
  else
87
- check_selection(answer)
88
- end
87
+ check_selection(answer)
88
+ end
89
89
  end
90
-
90
+
91
91
  def decimal_separator(number) #Helper Method. Separates numbers with decimals or returns ∞ when NaN.
92
92
  if number.is_a? Numeric
93
93
  whole, decimal = number.to_s.split(".")
94
94
  whole_with_commas = whole.chars.to_a.reverse.each_slice(3).map(&:join).join(",").reverse
95
95
  [whole_with_commas, decimal].compact.join(".")
96
- else
96
+ else
97
97
  number = "∞"
98
98
  number
99
- end
100
- end
101
-
99
+ end
100
+ end
101
+
102
102
  def round_if_num(num)
103
103
  if num.is_a? Numeric
104
- num.round(1)
105
- else
104
+ num.round(1)
105
+ else
106
106
  "Coingecko Returned N/A"
107
- end
107
+ end
108
108
  end
109
-
109
+
110
110
  def table_printer(rows)
111
111
  table = Terminal::Table.new :rows => rows
112
112
  puts table
113
- end
114
-
113
+ end
114
+
115
115
  def print_global_info(currency="usd")
116
116
  global_info = Coingecko::Global.new_from_global
117
117
  rows = []
@@ -128,17 +128,17 @@ class Coingecko::CLI
128
128
  puts "Market Cap Share (Top 10):\n"
129
129
  sleep 1.5
130
130
  global_info.data["market_cap_percentage"].each do |k, v|
131
- rows_two << ["#{k.upcase}: #{round_if_num(v)}%"]
132
- end
131
+ rows_two << ["#{k.upcase}: #{round_if_num(v)}%"]
132
+ end
133
133
  table_printer(rows_two)
134
134
  sleep 2
135
135
  another_selection?
136
- end
137
-
138
- def find
139
- puts "Which coin would you like to find? To go back, please type back."
140
- input = gets.strip.downcase
141
-
136
+ end
137
+
138
+ def find
139
+ puts "Which coin would you like to find?"
140
+ input = gets.strip.downcase
141
+
142
142
  Coingecko::Global.get_all_coins_list
143
143
  all_coins_basic = Coingecko::Global.all_coins_list
144
144
  returned_id = ""
@@ -146,25 +146,28 @@ class Coingecko::CLI
146
146
  if coin.name.strip.downcase == input
147
147
  returned_id = coin.id
148
148
  end
149
- end
150
-
149
+ end
150
+
151
151
  if !returned_id.empty?
152
152
  sleep 1
153
153
  puts "\nCoin match found!\n\n"
154
154
  sleep 2
155
155
  print_coin(returned_id)
156
- else
157
- check_selection(input)
158
- end
159
-
160
- end
156
+ else
157
+ sleep 1
158
+ puts "\nSorry. There was no coin match for '#{input}'.\n\n"
159
+ sleep 2
160
+ another_selection?
161
+ end
162
+
163
+ end
161
164
 
162
165
  def print_coin(id, currency="usd")
163
166
  puts "Retrieving your coin."
164
167
  sleep 0.5
165
- puts ".."
168
+ puts ".."
166
169
  sleep 0.5
167
- puts "....\n\n"
170
+ puts "....\n\n"
168
171
  sleep 0.5
169
172
  coin = Coingecko::Coin.get_coin(id)
170
173
  rows = []
@@ -178,16 +181,16 @@ class Coingecko::CLI
178
181
  puts "\nDESCRIPTION:\n"
179
182
  sleep 2
180
183
  puts coin.description["en"].gsub(/<\/?[^>]*>/, "") #.gsub strips HTML tags
181
- sleep 2
184
+ sleep 2
182
185
  puts "\n----------------QUICK FACTS---------------\n"
183
- sleep 1
186
+ sleep 1
184
187
  rows_two = []
185
188
  rows_two << ["Percentage Change: \n(7 Days) =>(30 Days) =>(1 Year)"]
186
- rows_two << [ "(#{round_if_num(coin.market_data["price_change_percentage_7d_in_currency"][currency])}% #{round_if_num(coin.market_data["price_change_percentage_30d_in_currency"][currency])}% #{round_if_num(coin.market_data["price_change_percentage_1y_in_currency"][currency])}% "]
189
+ rows_two << [ "#{round_if_num(coin.market_data["price_change_percentage_7d_in_currency"][currency])}% #{round_if_num(coin.market_data["price_change_percentage_30d_in_currency"][currency])}% #{round_if_num(coin.market_data["price_change_percentage_1y_in_currency"][currency])}% "]
187
190
  rows_two << [ "\n\nAll-Time High | ATH Date | Since ATH "]
188
191
  rows_two << ["#{coin.market_data["ath"][currency]} #{coin.market_data["ath_date"][currency][0..9]} #{round_if_num(coin.market_data["ath_change_percentage"][currency])}%"]
189
192
  table_printer(rows_two)
190
- rows_three = []
193
+ rows_three = []
191
194
  rows_three << ["Website: #{coin.links["homepage"][0]}"]
192
195
  rows_three << ["Reddit: #{coin.links["subreddit_url"]}"]
193
196
  rows_three << ["Github: #{coin.links["repos_url"]["github"][0]} "]
@@ -198,38 +201,38 @@ class Coingecko::CLI
198
201
  table_printer(rows_three)
199
202
  sleep 2
200
203
  another_selection?
201
- end
202
-
204
+ end
205
+
203
206
  def quit
204
207
  sleep 0.5
205
208
  puts "\nGoodbye! See you next time."
206
209
  sleep 1
207
- system('clear')
208
- end
210
+ system('clear')
211
+ end
209
212
 
210
213
  #FOR FUTURE Feature
211
214
  # def change_base
212
215
  # puts "\nNote: The default base currency is USD. Would you like to change the base currency?"
213
- # query = gets.strip.downcase
216
+ # query = gets.strip.downcase
214
217
  # if query == "yes" || query == "y"
215
218
  # need finish...
216
-
219
+
217
220
  # puts "\nHere all the base coins."
218
221
  # base_list = Coingecko::API.supported_base
219
222
  # #call base_list or maybe printer?
220
223
  # puts "\nPlease type the coin you would like to use as a base. To go back type back."
221
- # answer = gets.strip.downcase
224
+ # answer = gets.strip.downcase
222
225
  # if @@commands.include? answer
223
226
  # check_selection(answer)
224
- # else
227
+ # else
225
228
  # list_top_coins
226
- # end
227
- # end
228
-
229
+ # end
230
+ # end
231
+
229
232
  # Change Base COMMENTS_BEGIN
230
- #current_price and price change calls class method look up to populate those.
233
+ #current_price and price change calls class method look up to populate those.
231
234
  # the following NEED base_currency:
232
235
  # current_price, ath, ath_change_percentage, price_change_24h_in_currency, price_change_percentage_7d_in_currency, price_change_percentage_30d_in_currency, price_change_percentage_1y_in_currency
233
236
 
234
-
235
- end
237
+
238
+ end
@@ -1,3 +1,3 @@
1
1
  module Coingecko
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coingecko
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - "'Felipe Bohorquez'"
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-21 00:00:00.000000000 Z
11
+ date: 2019-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -108,14 +108,15 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '1.8'
111
- description: Pushes all coin data from Coingecko API. Also lists top 100 coins. This
112
- is my first Ruby gem so any feedback is greatly welcomed!
111
+ description: Pushes all coin data from Coingecko API. Please see my repo for usage.
112
+ This is my first Ruby gem so any feedback is greatly welcomed!
113
113
  email:
114
114
  - "''"
115
115
  executables: []
116
116
  extensions: []
117
117
  extra_rdoc_files: []
118
118
  files:
119
+ - ".gitignore"
119
120
  - CODE_OF_CONDUCT.md
120
121
  - Gemfile
121
122
  - Gemfile.lock
@@ -125,7 +126,6 @@ files:
125
126
  - bin/coingecko
126
127
  - bin/console
127
128
  - bin/setup
128
- - coingecko-0.1.0.gem
129
129
  - coingecko.gemspec
130
130
  - lib/coingecko/api.rb
131
131
  - lib/coingecko/cli.rb
@@ -152,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  - !ruby/object:Gem::Version
153
153
  version: '0'
154
154
  requirements: []
155
- rubygems_version: 3.0.3
155
+ rubygems_version: 3.0.4
156
156
  signing_key:
157
157
  specification_version: 4
158
158
  summary: tbd
Binary file