bitprice 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
+ SHA1:
3
+ metadata.gz: 12271dc79a825ceff46442063a9d3a61e852a7ca
4
+ data.tar.gz: 5a3679cd78e2d117b272cfe007d660cca3cf9835
5
+ SHA512:
6
+ metadata.gz: 60dbb378797db3e79ca463f77b78883f94e2d0d1e91026418e4baa6ff5e8bb23688613ce19d32c77d6a0cc69f78fc86d01f9f2c6a39524cf9a9cf036e9306623
7
+ data.tar.gz: 8c1fd7887d06818aa6e5c00fd7375dda35f068ef2928115047ef626cfa04b905f7a38f42d360e0515b6a1fa9045e8a8a326c98b9b76ecfa6d126aa553f1b5ff6
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in bitprice.gemspec
6
+ gemspec
@@ -0,0 +1,50 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ bitprice (0.1.0)
5
+ nokogiri
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ coderay (1.1.2)
11
+ colorize (0.8.1)
12
+ diff-lcs (1.3)
13
+ method_source (0.9.0)
14
+ mini_portile2 (2.3.0)
15
+ nokogiri (1.8.1)
16
+ mini_portile2 (~> 2.3.0)
17
+ nokogiri (1.8.1-x64-mingw32)
18
+ mini_portile2 (~> 2.3.0)
19
+ pry (0.11.3)
20
+ coderay (~> 1.1.0)
21
+ method_source (~> 0.9.0)
22
+ rake (10.5.0)
23
+ rspec (3.7.0)
24
+ rspec-core (~> 3.7.0)
25
+ rspec-expectations (~> 3.7.0)
26
+ rspec-mocks (~> 3.7.0)
27
+ rspec-core (3.7.0)
28
+ rspec-support (~> 3.7.0)
29
+ rspec-expectations (3.7.0)
30
+ diff-lcs (>= 1.2.0, < 2.0)
31
+ rspec-support (~> 3.7.0)
32
+ rspec-mocks (3.7.0)
33
+ diff-lcs (>= 1.2.0, < 2.0)
34
+ rspec-support (~> 3.7.0)
35
+ rspec-support (3.7.0)
36
+
37
+ PLATFORMS
38
+ ruby
39
+ x64-mingw32
40
+
41
+ DEPENDENCIES
42
+ bitprice!
43
+ bundler (~> 1.16)
44
+ colorize
45
+ pry
46
+ rake (~> 10.0)
47
+ rspec
48
+
49
+ BUNDLED WITH
50
+ 1.16.0
@@ -0,0 +1,25 @@
1
+
2
+
3
+ -A command line interface for live bitcoin and altcoin prices
4
+
5
+ Scraping Source: https://www.worldcoinindex.com/
6
+
7
+ user types bitprice
8
+
9
+ -Displays a list of the top 100 coins
10
+ --each coin displays "24 hour high"
11
+ --each coin displays "24 hour low"
12
+ --each coin displays percentage
13
+
14
+ -Selecting a specific coin will expand the details
15
+ --each coin displays ticker name
16
+ --each coin displays last price
17
+ --each coin displays percentage
18
+ --each coin displays "24 hour high"
19
+ --each coin displays "24 hour low"
20
+ --each coin displays volume
21
+ --each coin displays number of coins
22
+ --each coin displays market cap
23
+
24
+ -Possible timer system(sleep)
25
+ --allow regular updates via command line
@@ -0,0 +1,72 @@
1
+ # Bitprice
2
+
3
+ Thank you for checking out Bitprice. This CLI Ruby Gem has been created for
4
+ educational purposes. Bitprice utilizes the data provided by https://www.worldcoinindex.com.
5
+
6
+ Bitprice Features:
7
+
8
+ -In-Depth Date instantly for the top 100 cryptocurrencies include:
9
+ -Coin Name
10
+ -Percentage of growth or loss
11
+ -24 Hour High
12
+ -24 Hour Low
13
+ -last price
14
+ -volume
15
+ -market cap
16
+ -number of coins
17
+ -ticker name
18
+
19
+ --Includes initial list covering the Top 100 Cryptocurrency data:
20
+ -Select the associated list number for expanded details about
21
+ any given cryptocurrency.
22
+
23
+
24
+ If you intend to use or modify this software in any way please share your changes with me and site credit!
25
+
26
+ Creator: Micah Ortega
27
+ Email: Codingsynapse@gmail.com
28
+ Website: www.codingsynapse.com
29
+
30
+ **Disclaimer**
31
+ -By using this software, you release the creator of any damages to your financial investments.
32
+ Cryptocurrency is a volatile market. Only invest what you are capable of losing!
33
+
34
+ This software nor the creator can provide investment advice. Invest at your own risk!
35
+
36
+
37
+ ## Installation
38
+
39
+ Add this line to your application's Gemfile:
40
+
41
+ ```ruby
42
+ gem 'bitprice'
43
+ ```
44
+
45
+ And then execute:
46
+
47
+ $ bundle
48
+
49
+ Or install it yourself as:
50
+
51
+ $ gem install bitprice
52
+
53
+ ## Usage
54
+
55
+ To use this gem:
56
+
57
+ 1.) After installation: require 'bitprice'
58
+ 2.) To Launch use the following command: Bit.price
59
+
60
+ ## Development
61
+
62
+ 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.
63
+
64
+ 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).
65
+
66
+ ## Contributing
67
+
68
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Tat2artist/bitprice
69
+
70
+ ## License
71
+
72
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,5 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+ task :default => :spec
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "bitprice"
5
+
6
+ Bitprice::CLI.new.call
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "bitprice"
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,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,40 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "bitprice/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bitprice"
8
+ spec.version = Bitprice::VERSION
9
+ spec.authors = ["'Micah Ortega'"]
10
+ spec.email = ["'codingsynapse@gmail.com'"]
11
+ spec.files = ["lib/bitprice.rb"]
12
+ spec.summary = "Collects Top 100 data about your favorite cryptocurrencies!"
13
+ spec.description = "Detailed information instantly available about your favorite crypto currencies!"
14
+ spec.homepage = "http://codingsynapse.com/"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
21
+ else
22
+ raise "RubyGems 2.0 or newer is required to protect against " \
23
+ "public gem pushes."
24
+ end
25
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
26
+ f.match(%r{^(test|spec|features)/})
27
+ end
28
+ spec.bindir = "exe"
29
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
+ spec.require_paths = ["lib"]
31
+
32
+ spec.add_development_dependency "bundler", "~> 1.16"
33
+ spec.add_development_dependency "rake", "~> 10.0"
34
+ spec.add_development_dependency 'rspec', '~> 0'
35
+ spec.add_development_dependency 'pry', '~> 0'
36
+ spec.add_development_dependency 'colorize', '~> 0'
37
+
38
+ spec.add_dependency "nokogiri"
39
+
40
+ end
@@ -0,0 +1,15 @@
1
+ require 'open-uri'
2
+ require 'nokogiri'
3
+ require 'pry'
4
+
5
+ require_relative "./bitprice/version"
6
+ require_relative './bitprice/cli.rb'
7
+ require_relative './bitprice/listing.rb'
8
+
9
+ class Bit
10
+
11
+ def self.price
12
+ Bitprice::CLI.new.call
13
+ end
14
+
15
+ end
@@ -0,0 +1,80 @@
1
+ require 'colorize'
2
+
3
+ #CLI Controller
4
+ class Bitprice::CLI
5
+
6
+ attr_accessor :input
7
+
8
+ def call
9
+ details
10
+ menu
11
+ end
12
+
13
+ def details
14
+ puts " "
15
+ puts " "
16
+ puts "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$".colorize(:green)
17
+ puts " "
18
+ puts " -------| Welcome to Bitprice! Version 0.1.0 |-------".colorize(:yellow)
19
+ puts "Your #1 source for real time Cryptocurrency information".colorize(:yellow)
20
+ puts " Top 100 Coins ".colorize(:yellow)
21
+ puts " "
22
+ puts "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$".colorize(:green)
23
+ puts " "
24
+
25
+ @listing = Bitprice::Listing.now
26
+ @listing.each.with_index(1) do |crypto, i|
27
+ puts "#{i}." + "#{crypto.name}".colorize(:yellow) + " -" + "#{crypto.percent}".colorize(:red) + " | " + "$#{crypto.high}".colorize(:green) + " / " + "$#{crypto.low}".colorize(:green)
28
+ end
29
+ #@listing.clear
30
+ end
31
+
32
+ def menu
33
+
34
+ puts " "
35
+ puts "--Bitprice Menu--".colorize(:cyan)
36
+ puts "-Want to know more about a specific coin? Enter the associated number of any coin!"
37
+ puts "-Automatically update market details? Type 'auto' for minute by minute updates!"
38
+ puts "-Display the main list? Type 'list'"
39
+ puts "-Done browsing Cryptocurrency markets? Type 'exit'."
40
+
41
+ input = gets.strip.downcase
42
+
43
+ if input.to_i > 0
44
+ info = @listing[input.to_i]
45
+ puts " "
46
+ puts "----- " + "#{info.name}".colorize(:cyan) + " -----"
47
+ puts "-Ticker Name:".colorize(:magenta) + " #{info.ticker}"
48
+ puts "-Last Price:".colorize(:green) + " $#{info.last_price}"
49
+ puts "-Market Percentage:".colorize(:yellow) + " #{info.percent}"
50
+ puts "-24 Hour High:".colorize(:red) + " $#{info.high}"
51
+ puts "-24 Hour Low:".colorize(:red) + " $#{info.low}"
52
+ puts "-24 Hour Volume:".colorize(:cyan) + " $#{info.volume}"
53
+ puts "-Number of Coins:".colorize(:yellow) + " #{info.numcoins}"
54
+ puts "-Market Cap:".colorize(:green) + " #{info.marketcap}"
55
+ puts " "
56
+ elsif input == 'list'
57
+ @listing.clear
58
+ call
59
+ elsif input == 'exit'
60
+ puts " "
61
+ puts "She cannot take any more of this, Captain!".colorize(:magenta)
62
+ puts " "
63
+ abort
64
+ elsif input == 'auto'
65
+ x = 0
66
+ puts " "
67
+ puts "--Auto-Update Enabled--".colorize(:cyan)
68
+ puts " "
69
+ sleep(60)
70
+ @listing.clear
71
+ call
72
+ else
73
+ puts "Bleep Bl00p..Invalid Response."
74
+ end
75
+ menu
76
+ end
77
+
78
+
79
+
80
+ end
@@ -0,0 +1,93 @@
1
+ class Bitprice::Listing
2
+
3
+ attr_accessor :name, :percent, :high, :low, :ticker, :last_price, :volume, :numcoins, :marketcap, :url
4
+
5
+ @@all = []
6
+
7
+ def self.now
8
+ self.scrape_world_coin_index
9
+ self.scrape_crypto
10
+ end
11
+
12
+
13
+ def self.scrape_crypto
14
+ @@all
15
+ end
16
+
17
+
18
+
19
+ def self.scrape_world_coin_index
20
+
21
+
22
+ doc = Nokogiri::HTML(open("https://www.worldcoinindex.com"))
23
+
24
+ counter = 0
25
+
26
+ @coinname = []
27
+ @percentage = []
28
+ @high = []
29
+ @low = []
30
+
31
+ @tic = []
32
+ @lastp = []
33
+ @volum = []
34
+ @numbercoins = []
35
+ @marketc = []
36
+
37
+
38
+ doc.css(".bitcoinName h1 span").each do |coin|
39
+ @coinname << coin.text
40
+ end
41
+
42
+ doc.css(".percentage span").each do |per|
43
+ @percentage << per.text
44
+ end
45
+
46
+ doc.css(".highprice .span").each do |up|
47
+ @high << up.text
48
+ end
49
+
50
+ doc.css(".lowprice .span").each do |down|
51
+ @low << down.text
52
+ end
53
+
54
+ doc.css(".ticker h2").each do |tick|
55
+ @tic << tick.text
56
+ end
57
+
58
+ doc.css(".lastprice .span").each do |last|
59
+ @lastp << last.text
60
+ end
61
+
62
+ doc.css(".volume .span").each do |vol|
63
+ @volum << vol.text.strip
64
+ end
65
+
66
+ doc.css(".volume .span").each do |num|
67
+ @numbercoins << num.text.strip
68
+ end
69
+
70
+ doc.css(".marketcap .span").each do |mar|
71
+ @marketc << mar.text.strip
72
+ end
73
+
74
+ while counter < 100
75
+
76
+ crypto_info = self.new
77
+ crypto_info.name = @coinname[counter]
78
+ crypto_info.url = "coin/" + @coinname[counter]
79
+ crypto_info.percent = @percentage[counter]
80
+ crypto_info.high = @high[counter]
81
+ crypto_info.low = @low[counter]
82
+ crypto_info.ticker = @tic[counter]
83
+ crypto_info.last_price = @lastp[counter]
84
+ crypto_info.volume = @volum[counter]
85
+ crypto_info.numcoins = @numbercoins[counter]
86
+ crypto_info.marketcap = @marketc[counter]
87
+ counter += 1
88
+ @@all << crypto_info
89
+ end
90
+ end
91
+
92
+
93
+ end
@@ -0,0 +1,3 @@
1
+ module Bitprice
2
+ VERSION = "0.1.0"
3
+ end
data/spec.md ADDED
@@ -0,0 +1,6 @@
1
+ # Specifications for the CLI Assessment
2
+
3
+ Specs:
4
+ - [x] Have a CLI for interfacing with the application
5
+ - [X] Pull data from an external source
6
+ - [X] Implement both list and detail views
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bitprice
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - "'Micah Ortega'"
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-11-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.16'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.16'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
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
+ - !ruby/object:Gem::Dependency
70
+ name: colorize
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: nokogiri
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Detailed information instantly available about your favorite crypto currencies!
98
+ email:
99
+ - "'codingsynapse@gmail.com'"
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - Gemfile
106
+ - Gemfile.lock
107
+ - NOTES.md
108
+ - README.md
109
+ - Rakefile
110
+ - bin/bitprice
111
+ - bin/console
112
+ - bin/setup
113
+ - bitprice.gemspec
114
+ - lib/bitprice.rb
115
+ - lib/bitprice/cli.rb
116
+ - lib/bitprice/listing.rb
117
+ - lib/bitprice/version.rb
118
+ - spec.md
119
+ homepage: http://codingsynapse.com/
120
+ licenses:
121
+ - MIT
122
+ metadata:
123
+ allowed_push_host: https://rubygems.org
124
+ post_install_message:
125
+ rdoc_options: []
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubyforge_project:
140
+ rubygems_version: 2.6.13
141
+ signing_key:
142
+ specification_version: 4
143
+ summary: Collects Top 100 data about your favorite cryptocurrencies!
144
+ test_files: []