hodlmoon 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +65 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +74 -0
- data/LICENSE.txt +21 -0
- data/README.md +93 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/hodlmoon +4 -0
- data/bin/setup +8 -0
- data/hodlmoon.gemspec +33 -0
- data/lib/hodlmoon.rb +6 -0
- data/lib/hodlmoon/cli.rb +31 -0
- data/lib/hodlmoon/client/base.rb +23 -0
- data/lib/hodlmoon/client/retrieve_list.rb +17 -0
- data/lib/hodlmoon/client/retrieve_price.rb +17 -0
- data/lib/hodlmoon/table.rb +76 -0
- data/lib/hodlmoon/version.rb +3 -0
- metadata +194 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5dbd46e18146b18c514d102192e4f20c54b13b7c
|
4
|
+
data.tar.gz: b5fa12823b49e4ebe1617dcbf4c22008839a5db0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b9ff052fc4cf7de32a1ab8555fbe82004c2e0a11ffda7b1203bf3105300536d295b201a6dd06a86e9b4de5d955a156ed0fd2d8b9d68021b2816658a80b4c8883
|
7
|
+
data.tar.gz: f29bd40982ff474a1da57fed51dcc08bd3c6f424733f266340c7e7c1b6668289ca7be64df052f7b7f6a3cfc81f4b1598755b80e37b96b69170969644bb00565c
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.3
|
3
|
+
|
4
|
+
Documentation:
|
5
|
+
Enabled: false
|
6
|
+
|
7
|
+
Layout/DotPosition:
|
8
|
+
Enabled: false
|
9
|
+
|
10
|
+
Metrics/ClassLength:
|
11
|
+
Enabled: false
|
12
|
+
|
13
|
+
Metrics/LineLength:
|
14
|
+
Max: 120
|
15
|
+
Enabled: true
|
16
|
+
|
17
|
+
Metrics/MethodLength:
|
18
|
+
Max: 15
|
19
|
+
CountComments: false
|
20
|
+
Enabled: true
|
21
|
+
|
22
|
+
StringLiterals:
|
23
|
+
Enabled: true
|
24
|
+
|
25
|
+
Style/AsciiComments:
|
26
|
+
Enabled: false
|
27
|
+
|
28
|
+
Style/ClassAndModuleChildren:
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
Style/EmptyMethod:
|
32
|
+
Enabled: false
|
33
|
+
|
34
|
+
Style/FrozenStringLiteralComment:
|
35
|
+
Enabled: false
|
36
|
+
|
37
|
+
Style/Lambda:
|
38
|
+
Enabled: false
|
39
|
+
|
40
|
+
Style/MethodCallWithoutArgsParentheses:
|
41
|
+
Enabled: true
|
42
|
+
|
43
|
+
Style/MethodDefParentheses:
|
44
|
+
Enabled: true
|
45
|
+
|
46
|
+
Style/PercentLiteralDelimiters:
|
47
|
+
PreferredDelimiters:
|
48
|
+
default: ()
|
49
|
+
'%i': '()'
|
50
|
+
'%I': '()'
|
51
|
+
'%r': '{}'
|
52
|
+
'%w': '()'
|
53
|
+
'%W': '()'
|
54
|
+
|
55
|
+
Style/RegexpLiteral:
|
56
|
+
Enabled: false
|
57
|
+
|
58
|
+
Style/StructInheritance:
|
59
|
+
Enabled: false
|
60
|
+
|
61
|
+
Style/SymbolArray:
|
62
|
+
Enabled: false
|
63
|
+
|
64
|
+
Style/WordArray:
|
65
|
+
Enabled: false
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at richard.bates@babylonhealth.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: http://contributor-covenant.org
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
hodlmoon (0.1.0)
|
5
|
+
httparty
|
6
|
+
terminal-table
|
7
|
+
thor
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
addressable (2.5.2)
|
13
|
+
public_suffix (>= 2.0.2, < 4.0)
|
14
|
+
ast (2.4.0)
|
15
|
+
crack (0.4.3)
|
16
|
+
safe_yaml (~> 1.0.0)
|
17
|
+
diff-lcs (1.3)
|
18
|
+
hashdiff (0.3.7)
|
19
|
+
httparty (0.15.7)
|
20
|
+
multi_xml (>= 0.5.2)
|
21
|
+
multi_xml (0.6.0)
|
22
|
+
parallel (1.12.0)
|
23
|
+
parser (2.4.0.2)
|
24
|
+
ast (~> 2.3)
|
25
|
+
powerpack (0.1.1)
|
26
|
+
public_suffix (3.0.1)
|
27
|
+
rainbow (3.0.0)
|
28
|
+
rake (10.5.0)
|
29
|
+
rspec (3.7.0)
|
30
|
+
rspec-core (~> 3.7.0)
|
31
|
+
rspec-expectations (~> 3.7.0)
|
32
|
+
rspec-mocks (~> 3.7.0)
|
33
|
+
rspec-core (3.7.1)
|
34
|
+
rspec-support (~> 3.7.0)
|
35
|
+
rspec-expectations (3.7.0)
|
36
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
37
|
+
rspec-support (~> 3.7.0)
|
38
|
+
rspec-mocks (3.7.0)
|
39
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
40
|
+
rspec-support (~> 3.7.0)
|
41
|
+
rspec-support (3.7.1)
|
42
|
+
rubocop (0.52.1)
|
43
|
+
parallel (~> 1.10)
|
44
|
+
parser (>= 2.4.0.2, < 3.0)
|
45
|
+
powerpack (~> 0.1)
|
46
|
+
rainbow (>= 2.2.2, < 4.0)
|
47
|
+
ruby-progressbar (~> 1.7)
|
48
|
+
unicode-display_width (~> 1.0, >= 1.0.1)
|
49
|
+
ruby-progressbar (1.9.0)
|
50
|
+
safe_yaml (1.0.4)
|
51
|
+
terminal-table (1.8.0)
|
52
|
+
unicode-display_width (~> 1.1, >= 1.1.1)
|
53
|
+
thor (0.20.0)
|
54
|
+
unicode-display_width (1.3.0)
|
55
|
+
vcr (3.0.3)
|
56
|
+
webmock (3.2.1)
|
57
|
+
addressable (>= 2.3.6)
|
58
|
+
crack (>= 0.3.2)
|
59
|
+
hashdiff
|
60
|
+
|
61
|
+
PLATFORMS
|
62
|
+
ruby
|
63
|
+
|
64
|
+
DEPENDENCIES
|
65
|
+
bundler (~> 1.16)
|
66
|
+
hodlmoon!
|
67
|
+
rake (~> 10.0)
|
68
|
+
rspec (~> 3.0)
|
69
|
+
rubocop (~> 0.52.1)
|
70
|
+
vcr
|
71
|
+
webmock
|
72
|
+
|
73
|
+
BUNDLED WITH
|
74
|
+
1.16.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Richard Bates
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
# Hodlmoon
|
2
|
+
|
3
|
+
Quickly find the price of your crypto portfolio from the comfort of your command line.
|
4
|
+
|
5
|
+
When moon?
|
6
|
+
|
7
|
+
![ethereum moon](https://user-images.githubusercontent.com/18379191/36102847-787a365a-1005-11e8-9121-ce3a477d3184.jpg)
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Install it yourself:
|
12
|
+
|
13
|
+
$ gem install hodlmoon
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
The gem comes with two methods that can be run : `price` and `list`.
|
18
|
+
|
19
|
+
### List
|
20
|
+
|
21
|
+
Lists market data for the top coins in a specific currency. If no limit is given, the top 5 will be shown. If no currency is given, the CLI will default to `gbp`:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
hodlmoon list
|
25
|
+
#
|
26
|
+
O==============O========O===============O================O===================O====================O===================O
|
27
|
+
| ☾ ☾ ☾ Hodlmoon ☽ ☽ ☽ |
|
28
|
+
O==============O========O===============O================O===================O====================O===================O
|
29
|
+
| name | symbol | price_gbp | market_cap_gbp | percent_change_1h | percent_change_24h | percent_change_7d |
|
30
|
+
O==============O========O===============O================O===================O====================O===================O
|
31
|
+
| Bitcoin | BTC | 6194.31180144 | 104438958744 | -1.69 | +2.13 | +14.56 |
|
32
|
+
O==============O========O===============O================O===================O====================O===================O
|
33
|
+
| Ethereum | ETH | 611.451838746 | 59659761394.0 | -1.66 | +0.14 | +13.49 |
|
34
|
+
O==============O========O===============O================O===================O====================O===================O
|
35
|
+
| Ripple | XRP | 0.7614421057 | 29703259449.0 | -1.33 | +0.51 | +42.23 |
|
36
|
+
O==============O========O===============O================O===================O====================O===================O
|
37
|
+
| Bitcoin Cash | BCH | 905.989224 | 15368940724.0 | -1.75 | -0.82 | +28.42 |
|
38
|
+
O==============O========O===============O================O===================O====================O===================O
|
39
|
+
| Cardano | ADA | 0.2704738498 | 7012594583.0 | -1.64 | -2.15 | +10.23 |
|
40
|
+
O==============O========O===============O================O===================O====================O===================O
|
41
|
+
|
42
|
+
hodlmoon list 2 eur
|
43
|
+
#
|
44
|
+
O==========O========O===============O================O===================O====================O===================O
|
45
|
+
| ☾ ☾ ☾ Hodlmoon ☽ ☽ ☽ |
|
46
|
+
O==========O========O===============O================O===================O====================O===================O
|
47
|
+
| name | symbol | price_eur | market_cap_eur | percent_change_1h | percent_change_24h | percent_change_7d |
|
48
|
+
O==========O========O===============O================O===================O====================O===================O
|
49
|
+
| Bitcoin | BTC | 6999.59148544 | 118016346256 | -1.69 | +2.13 | +14.56 |
|
50
|
+
O==========O========O===============O================O===================O====================O===================O
|
51
|
+
| Ethereum | ETH | 690.942468096 | 67415714814.0 | -1.66 | +0.14 | +13.49 |
|
52
|
+
O==========O========O===============O================O===================O====================O===================O
|
53
|
+
```
|
54
|
+
|
55
|
+
### Price
|
56
|
+
|
57
|
+
Gets the current price of a coin in a specific currency. If no currency is given, the CLI will default to `gbp`:
|
58
|
+
|
59
|
+
```ruby
|
60
|
+
hodlmoon price ethereum
|
61
|
+
#
|
62
|
+
O==========O========O===============O================O===================O====================O===================O
|
63
|
+
| ☾ ☾ ☾ Hodlmoon ☽ ☽ ☽ |
|
64
|
+
O==========O========O===============O================O===================O====================O===================O
|
65
|
+
| name | symbol | price_gbp | market_cap_gbp | percent_change_1h | percent_change_24h | percent_change_7d |
|
66
|
+
O==========O========O===============O================O===================O====================O===================O
|
67
|
+
| Ethereum | ETH | 608.540996151 | 59387446060.0 | +0.54 | -1.76 | +26.1 |
|
68
|
+
O==========O========O===============O================O===================O====================O===================O
|
69
|
+
|
70
|
+
hodlmoon price neo usd
|
71
|
+
#
|
72
|
+
O======O========O===========O================O===================O====================O===================O
|
73
|
+
| ☾ ☾ ☾ Hodlmoon ☽ ☽ ☽ |
|
74
|
+
O======O========O===========O================O===================O====================O===================O
|
75
|
+
| name | symbol | price_usd | market_cap_usd | percent_change_1h | percent_change_24h | percent_change_7d |
|
76
|
+
O======O========O===========O================O===================O====================O===================O
|
77
|
+
| NEO | NEO | 111.91 | 7274150000.0 | +0.17 | -0.72 | +35.47 |
|
78
|
+
O======O========O===========O================O===================O====================O===================O
|
79
|
+
```
|
80
|
+
|
81
|
+
## Contributing
|
82
|
+
|
83
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/richo225/hodlmoon. 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.
|
84
|
+
|
85
|
+
## License
|
86
|
+
|
87
|
+
Image by [@onedigitalartist](https://steemit.com/@onedigitalartist)
|
88
|
+
|
89
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
90
|
+
|
91
|
+
## Code of Conduct
|
92
|
+
|
93
|
+
Everyone interacting in the Hodlmoon project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/richo225/hodlmoon/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'bundler/setup'
|
4
|
+
require 'hodlmoon'
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require 'irb'
|
14
|
+
IRB.start(__FILE__)
|
data/bin/hodlmoon
ADDED
data/bin/setup
ADDED
data/hodlmoon.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'hodlmoon/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'hodlmoon'
|
8
|
+
spec.version = Hodlmoon::VERSION
|
9
|
+
spec.authors = ['Richard Bates']
|
10
|
+
spec.email = ['richo225@gmail.com']
|
11
|
+
|
12
|
+
spec.description = 'A command line tool for crytocurrency data. When moon?'
|
13
|
+
spec.summary = spec.description
|
14
|
+
spec.homepage = 'https://github.com/richo225/hodlmoon'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
|
+
f.match(%r{^(test|spec|features)/})
|
19
|
+
end
|
20
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
21
|
+
spec.require_paths = ['lib']
|
22
|
+
|
23
|
+
spec.add_dependency 'httparty'
|
24
|
+
spec.add_dependency 'terminal-table'
|
25
|
+
spec.add_dependency 'thor'
|
26
|
+
|
27
|
+
spec.add_development_dependency 'bundler', '~> 1.16'
|
28
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
29
|
+
spec.add_development_dependency 'rspec', '~> 3.0'
|
30
|
+
spec.add_development_dependency 'rubocop', '~> 0.52.1'
|
31
|
+
spec.add_development_dependency 'vcr'
|
32
|
+
spec.add_development_dependency 'webmock'
|
33
|
+
end
|
data/lib/hodlmoon.rb
ADDED
data/lib/hodlmoon/cli.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'hodlmoon/client/retrieve_price'
|
3
|
+
require 'hodlmoon/client/retrieve_list'
|
4
|
+
require 'hodlmoon/table'
|
5
|
+
|
6
|
+
module Hodlmoon
|
7
|
+
class Cli < Thor
|
8
|
+
CURRENCY = {
|
9
|
+
gbp: '£',
|
10
|
+
usd: '$',
|
11
|
+
eur: '€'
|
12
|
+
}.freeze
|
13
|
+
|
14
|
+
desc 'hello NAME', 'say hello to NAME'
|
15
|
+
def hello(name)
|
16
|
+
puts "Hello #{name}"
|
17
|
+
end
|
18
|
+
|
19
|
+
desc 'price COIN CURRENCY', 'get current price of COIN in CURRENCY(optional)'
|
20
|
+
def price(coin, currency = 'gbp')
|
21
|
+
info = Hodlmoon::Client::RetrievePrice.call(coin, currency)
|
22
|
+
puts Hodlmoon::Table.build(info, currency)
|
23
|
+
end
|
24
|
+
|
25
|
+
desc 'list LIMIT CURRENCY', 'get LIMIT of top coins in CURRENCY(optional)'
|
26
|
+
def list(limit = 8, currency = 'gbp')
|
27
|
+
info = Hodlmoon::Client::RetrieveList.call(limit, currency)
|
28
|
+
puts Hodlmoon::Table.build(info, currency)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module Hodlmoon
|
4
|
+
module Client
|
5
|
+
class Base
|
6
|
+
def initialize(limit: nil, coin: nil, currency:)
|
7
|
+
@limit = limit
|
8
|
+
@coin = coin
|
9
|
+
@currency = currency
|
10
|
+
end
|
11
|
+
|
12
|
+
def call
|
13
|
+
HTTParty.get(uri)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def uri
|
19
|
+
raise NotImplementedError
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative 'base'
|
2
|
+
|
3
|
+
module Hodlmoon
|
4
|
+
module Client
|
5
|
+
class RetrieveList < Base
|
6
|
+
def self.call(limit, currency)
|
7
|
+
new(limit: limit, currency: currency).call
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def uri
|
13
|
+
"https://api.coinmarketcap.com/v1/ticker/?limit=#{@limit}&convert=#{@currency}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require_relative 'base'
|
2
|
+
|
3
|
+
module Hodlmoon
|
4
|
+
module Client
|
5
|
+
class RetrievePrice < Base
|
6
|
+
def self.call(coin, currency)
|
7
|
+
new(coin: coin, currency: currency).call
|
8
|
+
end
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def uri
|
13
|
+
"https://api.coinmarketcap.com/v1/ticker/#{@coin}/?convert=#{@currency}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'terminal-table'
|
2
|
+
|
3
|
+
module Hodlmoon
|
4
|
+
class Table
|
5
|
+
def self.build(info, currency)
|
6
|
+
new(info, currency).build
|
7
|
+
end
|
8
|
+
|
9
|
+
def initialize(info, currency)
|
10
|
+
@info = info
|
11
|
+
@currency = currency
|
12
|
+
end
|
13
|
+
|
14
|
+
def build
|
15
|
+
Terminal::Table.new do |t|
|
16
|
+
t.title = '☾ ☾ ☾ Hodlmoon ☽ ☽ ☽'
|
17
|
+
t.headings = headers
|
18
|
+
t.rows = rows
|
19
|
+
t.style = { all_separators: true, border_x: '=', border_i: 'O', alignment: :center }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def headers
|
26
|
+
['name',
|
27
|
+
'symbol',
|
28
|
+
"price_#{@currency}",
|
29
|
+
"market_cap_#{@currency}",
|
30
|
+
'percent_change_1h',
|
31
|
+
'percent_change_24h',
|
32
|
+
'percent_change_7d']
|
33
|
+
end
|
34
|
+
|
35
|
+
def rows
|
36
|
+
colorised_info.map(&:values)
|
37
|
+
end
|
38
|
+
|
39
|
+
def colorised_info
|
40
|
+
filtered_info.map do |coin|
|
41
|
+
coin.each_pair(&method(:colorise))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def colorise(key, value)
|
46
|
+
return unless value
|
47
|
+
|
48
|
+
case key
|
49
|
+
when /price_.*/ then colorise_yellow(value)
|
50
|
+
when /percent_change_.*/ then colorise_red_or_green(value)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def filtered_info
|
55
|
+
@info.map do |coin|
|
56
|
+
headers.each_with_object({}) { |k, h| h[k] = coin[k]; }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def colorise_yellow(string)
|
61
|
+
string.prepend("\e[33m").concat("\e[0m")
|
62
|
+
end
|
63
|
+
|
64
|
+
def colorise_red_or_green(string)
|
65
|
+
string.include?('-') ? colorise_red(string) : colorise_green(string)
|
66
|
+
end
|
67
|
+
|
68
|
+
def colorise_red(string)
|
69
|
+
string.prepend("\e[31m").concat("\e[0m")
|
70
|
+
end
|
71
|
+
|
72
|
+
def colorise_green(string)
|
73
|
+
string.prepend("\e[32m+").concat("\e[0m")
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
metadata
ADDED
@@ -0,0 +1,194 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hodlmoon
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Richard Bates
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-02-13 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: terminal-table
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: thor
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: bundler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.16'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.16'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rake
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '10.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '10.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rubocop
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.52.1
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.52.1
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: vcr
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: webmock
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
description: A command line tool for crytocurrency data. When moon?
|
140
|
+
email:
|
141
|
+
- richo225@gmail.com
|
142
|
+
executables:
|
143
|
+
- console
|
144
|
+
- hodlmoon
|
145
|
+
- setup
|
146
|
+
extensions: []
|
147
|
+
extra_rdoc_files: []
|
148
|
+
files:
|
149
|
+
- ".gitignore"
|
150
|
+
- ".rspec"
|
151
|
+
- ".rubocop.yml"
|
152
|
+
- ".travis.yml"
|
153
|
+
- CODE_OF_CONDUCT.md
|
154
|
+
- Gemfile
|
155
|
+
- Gemfile.lock
|
156
|
+
- LICENSE.txt
|
157
|
+
- README.md
|
158
|
+
- Rakefile
|
159
|
+
- bin/console
|
160
|
+
- bin/hodlmoon
|
161
|
+
- bin/setup
|
162
|
+
- hodlmoon.gemspec
|
163
|
+
- lib/hodlmoon.rb
|
164
|
+
- lib/hodlmoon/cli.rb
|
165
|
+
- lib/hodlmoon/client/base.rb
|
166
|
+
- lib/hodlmoon/client/retrieve_list.rb
|
167
|
+
- lib/hodlmoon/client/retrieve_price.rb
|
168
|
+
- lib/hodlmoon/table.rb
|
169
|
+
- lib/hodlmoon/version.rb
|
170
|
+
homepage: https://github.com/richo225/hodlmoon
|
171
|
+
licenses:
|
172
|
+
- MIT
|
173
|
+
metadata: {}
|
174
|
+
post_install_message:
|
175
|
+
rdoc_options: []
|
176
|
+
require_paths:
|
177
|
+
- lib
|
178
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
179
|
+
requirements:
|
180
|
+
- - ">="
|
181
|
+
- !ruby/object:Gem::Version
|
182
|
+
version: '0'
|
183
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
requirements: []
|
189
|
+
rubyforge_project:
|
190
|
+
rubygems_version: 2.6.14
|
191
|
+
signing_key:
|
192
|
+
specification_version: 4
|
193
|
+
summary: A command line tool for crytocurrency data. When moon?
|
194
|
+
test_files: []
|