price 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5df72801218663da0d398091374140a88d0d7768
4
+ data.tar.gz: 38fdaa3bdbdfb3aabe10b8f53c981e8013f145c7
5
+ SHA512:
6
+ metadata.gz: c0f054dfae8514ca702aedd23ae490878ab98c48af99e50927adfd48b6469b27d760553af21993647e83c56246c08134987e3146c0c373d19fa83da19ab2c055
7
+ data.tar.gz: a6a615f5bc76e707b508ff9856cf57d5f73536e1a0d7c4da1a374d3cde736cfc3e8e925f0ef4e20d1121a9ab8a165344993787dfafdd10d930f27737c85c37c3
@@ -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,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.2
5
+ before_install: gem install bundler -v 1.16.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in price.gemspec
4
+ gemspec
@@ -0,0 +1,54 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ price (0.1.0)
5
+ activesupport
6
+ http
7
+ paint
8
+ terminal-table
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ activesupport (5.1.4)
14
+ concurrent-ruby (~> 1.0, >= 1.0.2)
15
+ i18n (~> 0.7)
16
+ minitest (~> 5.1)
17
+ tzinfo (~> 1.1)
18
+ addressable (2.5.2)
19
+ public_suffix (>= 2.0.2, < 4.0)
20
+ concurrent-ruby (1.0.5)
21
+ domain_name (0.5.20170404)
22
+ unf (>= 0.0.5, < 1.0.0)
23
+ http (3.0.0)
24
+ addressable (~> 2.3)
25
+ http-cookie (~> 1.0)
26
+ http-form_data (>= 2.0.0.pre.pre2, < 3)
27
+ http_parser.rb (~> 0.6.0)
28
+ http-cookie (1.0.3)
29
+ domain_name (~> 0.5)
30
+ http-form_data (2.0.0)
31
+ http_parser.rb (0.6.0)
32
+ i18n (0.9.1)
33
+ concurrent-ruby (~> 1.0)
34
+ minitest (5.10.1)
35
+ paint (2.0.1)
36
+ public_suffix (3.0.1)
37
+ terminal-table (1.8.0)
38
+ unicode-display_width (~> 1.1, >= 1.1.1)
39
+ thread_safe (0.3.6)
40
+ tzinfo (1.2.4)
41
+ thread_safe (~> 0.1)
42
+ unf (0.1.4)
43
+ unf_ext
44
+ unf_ext (0.0.7.4)
45
+ unicode-display_width (1.3.0)
46
+
47
+ PLATFORMS
48
+ ruby
49
+
50
+ DEPENDENCIES
51
+ price!
52
+
53
+ BUNDLED WITH
54
+ 1.16.0
@@ -0,0 +1,16 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Carter Brainerd
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,39 @@
1
+ # Price
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/price`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'price'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install price
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/price.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -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
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "price"
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__)
@@ -0,0 +1,28 @@
1
+ #! /usr/bin/env ruby
2
+ lib = File.expand_path('../../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'price'
5
+
6
+ limit = 10
7
+
8
+ OptionParser.new do |opts|
9
+ opts.banner = 'Usage: price [options]'
10
+
11
+ opts.on('-v', '--version', 'Show the current version and exit.') do
12
+ puts Price::VERSION
13
+ exit 0
14
+ end
15
+
16
+ opts.on('-l', '--limit=<LIMIT>',
17
+ 'The maximum amount of entries to show (Default: 10)') do |i|
18
+ limit = i
19
+ end
20
+
21
+ opts.on_tail('-h', '--help', 'Show this help message and exit.') do
22
+ puts opts
23
+ exit 0
24
+ end
25
+
26
+ end.parse!
27
+
28
+ puts Price.prices(limit)
@@ -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,5 @@
1
+ require_relative 'price/version'
2
+ require_relative 'price/net'
3
+
4
+
5
+ require 'optparse'
@@ -0,0 +1,63 @@
1
+ require 'active_support'
2
+ require 'paint'
3
+ require 'http'
4
+ require 'json'
5
+ require 'terminal-table'
6
+
7
+ module Price
8
+
9
+ def self.prices(limit=10)
10
+ url = "https://api.coinmarketcap.com/v1/ticker/?limit=#{limit}"
11
+ begin
12
+ parsed = JSON.parse(HTTP.get(url))
13
+ rescue StandardError => e
14
+ puts Paint['Unable to get prices. Check your internet connection.',
15
+ '#e74c3c']
16
+ exit 1
17
+ end
18
+ t = Terminal::Table.new do |rows|
19
+
20
+ rows << [Paint['Rank', '#3498db'], Paint['Coin', '#3498db'],
21
+ Paint['Price', '#3498db'], Paint['Change (1h)', '#3498db'],
22
+ Paint['Change (24h)', '#3498db'], Paint['Change (7d)', '#3498db'],
23
+ Paint['Market Cap (USD)', '#3498db']]
24
+ rows.add_separator
25
+
26
+ parsed.each do |n|
27
+
28
+ green = '#2ecc71'
29
+ red = '#e74c3c'
30
+
31
+ one_h_change = n['percent_change_1h'] + '%'
32
+ day_change = n['percent_change_24h'] + '%'
33
+ week_change = n['percent_change_7d'] + '%'
34
+
35
+ # Do some color stuff here
36
+ if one_h_change.include?('-')
37
+ one_h_change = Paint[one_h_change, red]
38
+ else
39
+ one_h_change = Paint[one_h_change, green]
40
+ end
41
+
42
+ if day_change.include?('-')
43
+ day_change = Paint[day_change, red]
44
+ else
45
+ day_change = Paint[day_change, green]
46
+ end
47
+
48
+ if week_change.include?('-')
49
+ week_change = Paint[week_change, red]
50
+ else
51
+ week_change = Paint[week_change, green]
52
+ end
53
+
54
+
55
+ rows << [n['rank'], n['name'], '$' + n['price_usd'], one_h_change,
56
+ day_change, week_change,
57
+ ActiveSupport::NumberHelper.number_to_human(n['market_cap_usd'].to_i)]
58
+ end
59
+ end
60
+ return t
61
+ end
62
+
63
+ end
@@ -0,0 +1,3 @@
1
+ module Price
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,31 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'price'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "price"
8
+ spec.version = Price::VERSION
9
+ spec.authors = ["cbrnrd"]
10
+ spec.email = ["cbawsome77@gmail.com"]
11
+ spec.date = Time.now.strftime('%Y-%m-%d')
12
+
13
+ spec.summary = %q{Get cryptocurrency prices in your terminal}
14
+ spec.homepage = "https://github.com/cbrnrd/price"
15
+ spec.license = "MIT"
16
+
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ f.match(%r{^(test|spec|features)/})
20
+ end
21
+ spec.executables = %w[price]
22
+ spec.require_paths = ['lib']
23
+
24
+
25
+ spec.add_runtime_dependency 'paint'
26
+ spec.add_runtime_dependency 'terminal-table'
27
+ spec.add_runtime_dependency 'http'
28
+ spec.add_runtime_dependency 'activesupport'
29
+
30
+
31
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: price
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - cbrnrd
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-12-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: paint
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: http
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: activesupport
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description:
70
+ email:
71
+ - cbawsome77@gmail.com
72
+ executables:
73
+ - price
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
80
+ - Gemfile
81
+ - Gemfile.lock
82
+ - Guardfile
83
+ - LICENSE.txt
84
+ - README.md
85
+ - Rakefile
86
+ - bin/console
87
+ - bin/price
88
+ - bin/setup
89
+ - lib/price.rb
90
+ - lib/price/net.rb
91
+ - lib/price/version.rb
92
+ - price.gemspec
93
+ homepage: https://github.com/cbrnrd/price
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: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubyforge_project:
113
+ rubygems_version: 2.6.13
114
+ signing_key:
115
+ specification_version: 4
116
+ summary: Get cryptocurrency prices in your terminal
117
+ test_files: []