coingecko 0.1.3 → 0.2.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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +3 -3
- data/lib/coingecko/cli.rb +29 -22
- data/lib/coingecko/cli/version.rb +1 -1
- data/lib/coingecko/concerns/findable.rb +13 -0
- data/lib/environment.rb +6 -5
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aef09806691f80769a8ac2c134030e4ae6c02e9ed36aafcbfbb77e8bd6a0f457
|
4
|
+
data.tar.gz: 03334057d18f4be0604983444433eb1623e13b3649278a4503e5de79f211d2ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92a8c8eeaa6d438e6a7f5b29bef8f64bd80c283bb3318afa64754f9fc93005ead7c81bc5b0c0ac4de6c7e82dcbea3e2881ca597a62453b55da13962a1ad28a74
|
7
|
+
data.tar.gz: a1d2f32296c36207b7fbe41d3980021a5b218aaebbc1d58b4a30614fb336bee72ffb632b134a07083b9f74d56c28894cc4b969ec5b9d72ac5e54f8d905622d68
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Coingecko - A CoinGecko API with CLI
|
1
|
+
# Coingecko - A CoinGecko API with CLI
|
2
2
|
|
3
3
|
Pushes all coin data from Coingecko API. Also lists top 100 coins and overall market info.
|
4
4
|
|
@@ -31,10 +31,10 @@ Coingecko::Global.new_from_global
|
|
31
31
|
#Returns object with ALL available coins with id, symbol, name
|
32
32
|
Coingecko::Global.get_all_coins_list
|
33
33
|
|
34
|
-
#Returns top 100 coins objects only with id, symbol, name, market_cap_rank, last_updated. Default currency is "usd"
|
34
|
+
#Returns top 100 coins objects only with id, symbol, name, market_cap_rank, last_updated. Default currency is "usd" if no currency given. E.g.
|
35
35
|
Coingecko::Coin.new_from_top_100
|
36
36
|
|
37
|
-
#Returns a particular coin object with ALL avaiable data from Coingecko. It needs an id as an argument.
|
37
|
+
#Returns a particular coin object with ALL avaiable data from Coingecko. It needs an id as an argument. E.g.
|
38
38
|
Coingecko::Coin.get_coin("bitcoin")
|
39
39
|
|
40
40
|
|
data/lib/coingecko/cli.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
|
2
|
+
include Concerns::Findable
|
1
3
|
class Coingecko::CLI
|
2
4
|
@@commands = ["ls", "list", "b", "back", "menu", "m", "q", "quit", "exit", "exit!", "find", "f"]
|
3
5
|
|
@@ -137,29 +139,34 @@ class Coingecko::CLI
|
|
137
139
|
|
138
140
|
def find
|
139
141
|
puts "Which coin would you like to find?"
|
140
|
-
input = gets.
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
142
|
+
input = gets.chomp.downcase
|
143
|
+
coin = find_by_name(input) || guess_by_name(input)
|
144
|
+
case
|
145
|
+
when coin.class == Coingecko::Global #found with pry to see what class it is
|
146
|
+
sleep 1
|
147
|
+
puts "\nCoin match found!\n\n"
|
148
|
+
sleep 2
|
149
|
+
print_coin(coin.id)
|
150
|
+
when coin.class == Array && coin.length > 0
|
151
|
+
sleep 1
|
152
|
+
puts "\nMore than one possible match found. Please see below..\n\n"
|
153
|
+
sleep 2
|
154
|
+
coin.each_with_index { |o, i| puts "#{i + 1} - #{o.name}" }
|
155
|
+
puts "\nIf one of the coins provided is what you're looking for, please type 1 - #{coin.length}. Else type menu to go back.\n\n"
|
156
|
+
answer = gets.chomp
|
157
|
+
if answer.to_i > 0 #if string converted to_i will have value of 0
|
158
|
+
id = coin[answer.to_i - 1].id
|
159
|
+
print_coin(id)
|
160
|
+
else
|
161
|
+
check_selection(answer)
|
162
|
+
end
|
163
|
+
else
|
164
|
+
sleep 1
|
165
|
+
puts "\nSorry. There was no coin match for '#{input}'.\n\n"
|
166
|
+
sleep 2
|
167
|
+
another_selection?
|
162
168
|
|
169
|
+
end
|
163
170
|
end
|
164
171
|
|
165
172
|
def print_coin(id, currency="usd")
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Concerns
|
2
|
+
module Findable
|
3
|
+
def find_by_name(input)
|
4
|
+
Coingecko::Global.get_all_coins_list
|
5
|
+
Coingecko::Global.all_coins_list.detect {|coin| coin.name.strip.downcase == input }
|
6
|
+
end
|
7
|
+
|
8
|
+
def guess_by_name(input)
|
9
|
+
Coingecko::Global.get_all_coins_list
|
10
|
+
Coingecko::Global.all_coins_list.filter {|coin| coin.name.strip.downcase.include? input }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/environment.rb
CHANGED
@@ -4,8 +4,9 @@ require 'nokogiri'
|
|
4
4
|
require 'json'
|
5
5
|
require 'terminal-table'
|
6
6
|
|
7
|
-
require_relative
|
8
|
-
require_relative
|
9
|
-
require_relative
|
10
|
-
require_relative
|
11
|
-
require_relative
|
7
|
+
require_relative 'coingecko/concerns/findable'
|
8
|
+
require_relative 'coingecko/cli/version'
|
9
|
+
require_relative 'coingecko/cli'
|
10
|
+
require_relative 'coingecko/api'
|
11
|
+
require_relative 'coingecko/coin'
|
12
|
+
require_relative 'coingecko/global'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coingecko
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "'Felipe Bohorquez'"
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- lib/coingecko/cli.rb
|
133
133
|
- lib/coingecko/cli/version.rb
|
134
134
|
- lib/coingecko/coin.rb
|
135
|
+
- lib/coingecko/concerns/findable.rb
|
135
136
|
- lib/coingecko/global.rb
|
136
137
|
- lib/environment.rb
|
137
138
|
homepage: https://github.com/fbohz/coingecko.git
|