cryptostats-cli 0.1.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1e88e8fc1b37538f1c0e64b3998b3719849e45982a03d7114f4ff30d32545a82
4
+ data.tar.gz: 2ad7d548abc4c7517f3003df0effa2c6807589c3600906f27b8bea40b69c0618
5
+ SHA512:
6
+ metadata.gz: 4f1fd95062f9166082e25ce7430a51e8ae18d81dee93fea0b0aee38e69484679ce1a7ecd0fcb30df53298319566e98d1623bbc60c50128a81d51ce363d649e14
7
+ data.tar.gz: 5fac5d9ae10b9a0287059323f1be3338a9d320a5953fbd088c2907c868bd1b7c795a360a9ca929d996008af56b817e8aa068c2db1481a77be03c90dd7f03e195
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.2
6
+ before_install: gem install bundler -v 2.1.4
@@ -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 charlesangeloplai@gmail.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 [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'pry'
4
+ gem 'rest-client'
5
+ gem 'json'
6
+ gem 'awesome_print'
7
+ gem "rake", "~> 12.0"
8
+ gem "rspec", "~> 3.0"
9
+ #gem 'rmagick'
10
+ #gem 'ascii-image'
@@ -0,0 +1,56 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ awesome_print (1.8.0)
5
+ coderay (1.1.3)
6
+ diff-lcs (1.4.4)
7
+ domain_name (0.5.20190701)
8
+ unf (>= 0.0.5, < 1.0.0)
9
+ http-accept (1.7.0)
10
+ http-cookie (1.0.3)
11
+ domain_name (~> 0.5)
12
+ json (2.3.1)
13
+ method_source (1.0.0)
14
+ mime-types (3.3.1)
15
+ mime-types-data (~> 3.2015)
16
+ mime-types-data (3.2020.1104)
17
+ netrc (0.11.0)
18
+ pry (0.13.1)
19
+ coderay (~> 1.1)
20
+ method_source (~> 1.0)
21
+ rake (12.3.3)
22
+ rest-client (2.1.0)
23
+ http-accept (>= 1.7.0, < 2.0)
24
+ http-cookie (>= 1.0.2, < 2.0)
25
+ mime-types (>= 1.16, < 4.0)
26
+ netrc (~> 0.8)
27
+ rspec (3.10.0)
28
+ rspec-core (~> 3.10.0)
29
+ rspec-expectations (~> 3.10.0)
30
+ rspec-mocks (~> 3.10.0)
31
+ rspec-core (3.10.0)
32
+ rspec-support (~> 3.10.0)
33
+ rspec-expectations (3.10.0)
34
+ diff-lcs (>= 1.2.0, < 2.0)
35
+ rspec-support (~> 3.10.0)
36
+ rspec-mocks (3.10.0)
37
+ diff-lcs (>= 1.2.0, < 2.0)
38
+ rspec-support (~> 3.10.0)
39
+ rspec-support (3.10.0)
40
+ unf (0.1.4)
41
+ unf_ext
42
+ unf_ext (0.0.7.7)
43
+
44
+ PLATFORMS
45
+ ruby
46
+
47
+ DEPENDENCIES
48
+ awesome_print
49
+ json
50
+ pry
51
+ rake (~> 12.0)
52
+ rest-client
53
+ rspec (~> 3.0)
54
+
55
+ BUNDLED WITH
56
+ 2.1.4
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Charles
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.
@@ -0,0 +1,51 @@
1
+ # Cryptostats CLI
2
+
3
+ Welcome to Cryptostats!
4
+ Cryptostats is a CLI ruby gem that fetches meta data of the top 100 cryptocurrencies from the CoinGecko API and displays updated statistis regarding the current prices, market cap, volume, price change, etc.
5
+
6
+ ## Installation
7
+
8
+ #### Option 1 - Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'cryptostats-cli-gem'
12
+ ```
13
+
14
+ And then execute:
15
+ ```
16
+ $ bundle install
17
+ ```
18
+ Or install it yourself as:
19
+ ```
20
+ $ gem install cryptostats-cli-gem
21
+ ```
22
+
23
+ #### Option 2 - Clone the Git repository:
24
+
25
+ ```
26
+ git clone https://github.com/charlesangelolai/cryptostats-cli-gem.git
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ 1. Execute inside the directory:
32
+
33
+ ```
34
+ $ bin/run
35
+ ```
36
+
37
+ 2. Enter the crypto number of the cryptocurrency for more details: (1 - 100)
38
+
39
+ 3. Crypto Stats is displayed.
40
+
41
+ ## Contributing
42
+
43
+ Bug reports and pull requests are welcome on GitHub at https://github.com/charlesangelolai/cryptostats-cli-gem. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/cryptostats-cli-gem/blob/master/CODE_OF_CONDUCT.md).
44
+
45
+ ## License
46
+
47
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
48
+
49
+ ## Code of Conduct
50
+
51
+ Everyone interacting in the Cryptostats::Cli::Gem project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/cryptostats-cli-gem/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/run ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../lib/environment"
4
+
5
+ Cli.new.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,11 @@
1
+ require 'pry'
2
+ require 'rest-client'
3
+ require 'json'
4
+ require 'awesome_print'
5
+
6
+ #require 'rmagick'
7
+ #require 'ascii-image'
8
+
9
+ require_relative "./models/cryptostats"
10
+ require_relative "./services/api"
11
+ require_relative "./services/cli"
@@ -0,0 +1,37 @@
1
+ class CryptoStats
2
+ @@all = []
3
+
4
+ def initialize(attributes)
5
+ attributes.each do |key, value|
6
+ self.class.attr_accessor(key)
7
+ self.send(("#{key}="), value)
8
+ @@all << self
9
+ end
10
+ end
11
+
12
+ def self.all
13
+ @@all.uniq
14
+ end
15
+
16
+ def display_stats
17
+ puts "-------------------------------------------- Crypto Stats --------------------------------------------"
18
+ #crypto_logo(self.image)
19
+ puts "ID: #{self.id.capitalize}"
20
+ puts "Symbol: #{self.symbol.upcase}"
21
+ puts "Current Price: $#{self.current_price}"
22
+ puts "Market Cap: $#{self.market_cap}"
23
+ puts "Total Volume: $#{self.total_volume}"
24
+ puts "High (24hrs): $#{self.high_24h}"
25
+ puts "Low (24hrs): $#{self.low_24h}"
26
+ puts "Price Change (24hrs): $#{self.price_change_24h}"
27
+ puts "Percentage Change (24hrs): #{self.price_change_percentage_24h}%"
28
+ puts "Last Updated: #{self.last_updated}"
29
+ puts "------------------------------------------------------------------------------------------------------"
30
+ end
31
+
32
+ # def crypto_logo(image)
33
+ # binding.pry
34
+ # ascii = ASCII_Image.new(image)
35
+ # ascii.build(20)
36
+ # end
37
+ end
@@ -0,0 +1,21 @@
1
+ # https://pro-api.coinmarketcap.com/v1/cryptocurrency/listings/latest?CMC_PRO_API_KEY=dff57c31-f1ac-4e58-ac07-74bd976ede24
2
+
3
+ class Api
4
+
5
+ def self.base_url
6
+ "https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&order=market_cap_desc&per_page=100&page=1&sparkline=false"
7
+ end
8
+
9
+ def self.load_data
10
+ load_cryptocurrency
11
+ end
12
+
13
+ def self.load_cryptocurrency
14
+ response = RestClient.get base_url
15
+ data = JSON.parse(response.body)
16
+
17
+ data.each do |crypto_data|
18
+ CryptoStats.new(crypto_data)
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,87 @@
1
+ class Cli
2
+
3
+ def start
4
+ puts ""
5
+ puts "---------------------------------------------".yellow
6
+ puts "---------- Welcome to CryptoStats! ----------".yellow
7
+ puts "---------------------------------------------".yellow
8
+ puts ""
9
+ puts " ~~> fetching data from CoinGecko...".blue
10
+ puts " ~~> loading the top 100 cryptocurrencies...".blue
11
+ Api.load_data
12
+ main_menu
13
+ end
14
+
15
+ def main_menu
16
+ col1 = 0
17
+ col2 = 25
18
+ col3 = 50
19
+ col4 = 75
20
+
21
+ standardize_crypto_name_length
22
+
23
+ puts ""
24
+ puts " --- Top 100 Cryptocurrencies --- ".green
25
+ puts ""
26
+ while col1 < 25
27
+ puts " #{col1 + 1}. #{CryptoStats.all[col1].name} \t\t #{col2 + 1}. #{CryptoStats.all[col2].name} \t\t #{col3 + 1}. #{CryptoStats.all[col3].name} \t\t #{col4 + 1}. #{CryptoStats.all[col4].name}"
28
+
29
+ col1 += 1
30
+ col2 += 1
31
+ col3 += 1
32
+ col4 += 1
33
+ end
34
+
35
+ puts ""
36
+
37
+ main_menu_options
38
+ end
39
+
40
+ def main_menu_options
41
+ print "Enter the Cryptocurrency number to view more details: ".green
42
+ option = get_input
43
+ option = option.to_i - 1
44
+
45
+ if option < 0 || option > 99
46
+ puts "Invalid entry. Please try again...".red
47
+ puts ""
48
+ main_menu_options
49
+ else
50
+ puts ""
51
+ CryptoStats.all[option].display_stats
52
+ puts ""
53
+ exit?
54
+ end
55
+ end
56
+
57
+ def get_input
58
+ gets.chomp
59
+ end
60
+
61
+ def exit?
62
+ print "Would you like to exit the program? (Y/N) ".green
63
+ exit_option = get_input
64
+
65
+ if exit_option == "Y"
66
+ puts ""
67
+ puts "Closing program..."
68
+ puts ""
69
+ elsif exit_option == "N"
70
+ main_menu
71
+ else
72
+ puts "Invalid entry! Please try again..".red
73
+ puts ""
74
+ exit?
75
+ end
76
+ end
77
+
78
+ def standardize_crypto_name_length
79
+ max_length = 25
80
+
81
+ CryptoStats.all.each do |crypto|
82
+ while crypto.name.length < max_length
83
+ crypto.name += " "
84
+ end
85
+ end
86
+ end
87
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cryptostats-cli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Charles Lai
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-12-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rest-client
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: json
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: awesome_print
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: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Welcome to Cryptostats! Cryptostats is a CLI ruby gem that fetches meta
70
+ data of the top 100 cryptocurrencies from the CoinGecko API and displays updated
71
+ statistis regarding the current prices, market cap, volume, price change, etc.
72
+ email:
73
+ - charlesangeloplai@gmail.com
74
+ executables: []
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".gitignore"
79
+ - ".rspec"
80
+ - ".travis.yml"
81
+ - CODE_OF_CONDUCT.md
82
+ - Gemfile
83
+ - Gemfile.lock
84
+ - LICENSE.txt
85
+ - README.md
86
+ - Rakefile
87
+ - bin/run
88
+ - bin/setup
89
+ - lib/environment.rb
90
+ - lib/models/cryptostats.rb
91
+ - lib/services/api.rb
92
+ - lib/services/cli.rb
93
+ homepage:
94
+ licenses:
95
+ - MIT
96
+ metadata: {}
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: 2.3.0
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubygems_version: 3.1.4
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: Cryptocurrency Statistics
116
+ test_files: []