stock_quote_cli 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +1 -0
- data/.travis.yml +3 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +96 -0
- data/README.md +108 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/bin/stock +5 -0
- data/demo.gif +0 -0
- data/lib/stock_quote_cli/api.rb +23 -0
- data/lib/stock_quote_cli/cli.rb +124 -0
- data/lib/stock_quote_cli/text.rb +23 -0
- data/lib/stock_quote_cli/version.rb +3 -0
- data/lib/stock_quote_cli.rb +4 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/stock_quote_cli_spec.rb +19 -0
- data/stock_quote_cli.gemspec +78 -0
- metadata +175 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 00d8917fb44f81d3a3a63e2d7375990c86331d7b
|
4
|
+
data.tar.gz: 25953f561b4b24773c941fb3c143c982df3e8762
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: a341d52270b7511ceb502d949aa3182f26d64a5d6054ca691d71b32c95855c78ae3a634aceceb796a6ff23eebab14504e3055794ac22e1bb93dd6bd23e6357b4
|
7
|
+
data.tar.gz: b9d993ffd9bb956c4743dd42e1eec7e190229224ec806498466efaa119eadadb65e5cf008cd2c8cf68084a654fa1339f14ac5224adce9eff941adc672d4c42d4
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color --format documentation
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
gem "thor", "~> 0.19"
|
6
|
+
gem "stock_quote", "~> 1.2"
|
7
|
+
|
8
|
+
# Add dependencies to develop your gem here.
|
9
|
+
# Include everything needed to run rake, tests, features, etc.
|
10
|
+
group :development do
|
11
|
+
gem "rspec", "~> 2.8.0"
|
12
|
+
gem "shoulda-matchers", "~> 2.7"
|
13
|
+
gem "rdoc", "~> 3.12"
|
14
|
+
gem "bundler", "~> 1.0"
|
15
|
+
gem "jeweler", "~> 1.8.7"
|
16
|
+
gem "pry", "~> 0.10"
|
17
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (4.2.0)
|
5
|
+
i18n (~> 0.7)
|
6
|
+
json (~> 1.7, >= 1.7.7)
|
7
|
+
minitest (~> 5.1)
|
8
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
9
|
+
tzinfo (~> 1.1)
|
10
|
+
addressable (2.3.5)
|
11
|
+
builder (3.2.2)
|
12
|
+
coderay (1.1.0)
|
13
|
+
diff-lcs (1.1.3)
|
14
|
+
faraday (0.8.8)
|
15
|
+
multipart-post (~> 1.2.0)
|
16
|
+
git (1.2.6)
|
17
|
+
github_api (0.10.1)
|
18
|
+
addressable
|
19
|
+
faraday (~> 0.8.1)
|
20
|
+
hashie (>= 1.2)
|
21
|
+
multi_json (~> 1.4)
|
22
|
+
nokogiri (~> 1.5.2)
|
23
|
+
oauth2
|
24
|
+
hashie (2.0.5)
|
25
|
+
highline (1.6.20)
|
26
|
+
httpauth (0.2.0)
|
27
|
+
i18n (0.7.0)
|
28
|
+
jeweler (1.8.8)
|
29
|
+
builder
|
30
|
+
bundler (~> 1.0)
|
31
|
+
git (>= 1.2.5)
|
32
|
+
github_api (= 0.10.1)
|
33
|
+
highline (>= 1.6.15)
|
34
|
+
nokogiri (= 1.5.10)
|
35
|
+
rake
|
36
|
+
rdoc
|
37
|
+
json (1.8.1)
|
38
|
+
jwt (0.1.8)
|
39
|
+
multi_json (>= 1.5)
|
40
|
+
method_source (0.8.2)
|
41
|
+
mime-types (2.4.3)
|
42
|
+
minitest (5.5.0)
|
43
|
+
multi_json (1.8.2)
|
44
|
+
multi_xml (0.5.5)
|
45
|
+
multipart-post (1.2.0)
|
46
|
+
netrc (0.10.2)
|
47
|
+
nokogiri (1.5.10)
|
48
|
+
oauth2 (0.9.2)
|
49
|
+
faraday (~> 0.8)
|
50
|
+
httpauth (~> 0.2)
|
51
|
+
jwt (~> 0.1.4)
|
52
|
+
multi_json (~> 1.0)
|
53
|
+
multi_xml (~> 0.5)
|
54
|
+
rack (~> 1.2)
|
55
|
+
pry (0.10.1)
|
56
|
+
coderay (~> 1.1.0)
|
57
|
+
method_source (~> 0.8.1)
|
58
|
+
slop (~> 3.4)
|
59
|
+
rack (1.5.2)
|
60
|
+
rake (10.1.1)
|
61
|
+
rdoc (3.12.2)
|
62
|
+
json (~> 1.4)
|
63
|
+
rest-client (1.7.2)
|
64
|
+
mime-types (>= 1.16, < 3.0)
|
65
|
+
netrc (~> 0.7)
|
66
|
+
rspec (2.8.0)
|
67
|
+
rspec-core (~> 2.8.0)
|
68
|
+
rspec-expectations (~> 2.8.0)
|
69
|
+
rspec-mocks (~> 2.8.0)
|
70
|
+
rspec-core (2.8.0)
|
71
|
+
rspec-expectations (2.8.0)
|
72
|
+
diff-lcs (~> 1.1.2)
|
73
|
+
rspec-mocks (2.8.0)
|
74
|
+
shoulda-matchers (2.7.0)
|
75
|
+
activesupport (>= 3.0.0)
|
76
|
+
slop (3.6.0)
|
77
|
+
stock_quote (1.2.1)
|
78
|
+
json
|
79
|
+
rest-client (~> 1.6)
|
80
|
+
thor (0.19.1)
|
81
|
+
thread_safe (0.3.4)
|
82
|
+
tzinfo (1.2.2)
|
83
|
+
thread_safe (~> 0.1)
|
84
|
+
|
85
|
+
PLATFORMS
|
86
|
+
ruby
|
87
|
+
|
88
|
+
DEPENDENCIES
|
89
|
+
bundler (~> 1.0)
|
90
|
+
jeweler (~> 1.8.7)
|
91
|
+
pry (~> 0.10)
|
92
|
+
rdoc (~> 3.12)
|
93
|
+
rspec (~> 2.8.0)
|
94
|
+
shoulda-matchers (~> 2.7)
|
95
|
+
stock_quote (~> 1.2)
|
96
|
+
thor (~> 0.19)
|
data/README.md
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
## Stock Quote CLI
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/tbloncar/stock_quote_cli.png?branch=master)](https://travis-ci.org/tbloncar/stock_quote_cli)
|
4
|
+
|
5
|
+
Stock Quote CLI is a Ruby gem that provides a command-line interface for fetching stock information from Yahoo!. It relies on the [stock_quote gem](https://github.com/tyrauber/stock_quote) for fetching real-time and historical data.
|
6
|
+
|
7
|
+
![Demo](https://raw.githubusercontent.com/tbloncar/stock_quote_cli/master/demo.gif)
|
8
|
+
|
9
|
+
Update: Due to Google's sunsetting of iGoogle (and the associated endpoint from
|
10
|
+
which the stock_quote gem once fetched its data), the stock_quote gem has moved
|
11
|
+
to using the Yahoo! Finance API. This CLI gem has been updated to accommodate
|
12
|
+
the awesomely quick changes.
|
13
|
+
|
14
|
+
### Installation
|
15
|
+
|
16
|
+
With Ruby installed, run the following:
|
17
|
+
|
18
|
+
```
|
19
|
+
gem install stock_quote_cli
|
20
|
+
```
|
21
|
+
|
22
|
+
### Usage
|
23
|
+
|
24
|
+
You can use Stock Quote CLI to fetch real-time attributes of multiple stocks. Use the `stock` command in tandem with any of the available subcommands and stock symbols to fetch the relevant attribute(s).
|
25
|
+
|
26
|
+
#### Last Price
|
27
|
+
|
28
|
+
Get the latest price for the specified stock(s).
|
29
|
+
|
30
|
+
```
|
31
|
+
stock last goog yhoo aapl
|
32
|
+
```
|
33
|
+
|
34
|
+
#### Open Price
|
35
|
+
|
36
|
+
Get the opening price for the specified stock(s) on the current day (or last trading day).
|
37
|
+
|
38
|
+
```
|
39
|
+
stock open znga
|
40
|
+
```
|
41
|
+
|
42
|
+
#### Previous Closing Price
|
43
|
+
|
44
|
+
Get the closing price for the specified stock(s) on the previous trading day.
|
45
|
+
|
46
|
+
```
|
47
|
+
stock yclose amzn nflx
|
48
|
+
```
|
49
|
+
|
50
|
+
#### High Price
|
51
|
+
|
52
|
+
Get the high price for the specified stock(s) on the current day (or last trading day).
|
53
|
+
|
54
|
+
```
|
55
|
+
stock high lnkd
|
56
|
+
```
|
57
|
+
|
58
|
+
#### Low Price
|
59
|
+
|
60
|
+
Get the low price for the specified stock(s) on the current day (or last trading day).
|
61
|
+
|
62
|
+
```
|
63
|
+
stock low msft dell
|
64
|
+
```
|
65
|
+
|
66
|
+
#### Historical Data
|
67
|
+
|
68
|
+
Get historical data for a single stock. The default range is 14 days. The default value is the closing price. These can be specified using the `range` (aliased to `-r`) and `value` (aliased to `-v`) options, respectively.
|
69
|
+
|
70
|
+
```
|
71
|
+
stock history fb
|
72
|
+
```
|
73
|
+
|
74
|
+
The `range` (`-r`) option takes an integer. Use this to specify the number of trading days for which you'd like data.
|
75
|
+
|
76
|
+
```
|
77
|
+
stock history -r 15 fb
|
78
|
+
```
|
79
|
+
|
80
|
+
The `value` (`-v`) option takes a string. Use this to specify the price value that you'd like to see in the output. You can choose from the following:
|
81
|
+
|
82
|
+
* `open` (opening price)
|
83
|
+
* `close` (closing price)
|
84
|
+
* `high` (high price)
|
85
|
+
* `low` (low price)
|
86
|
+
* `volume` (share volume)
|
87
|
+
|
88
|
+
Below, we fetch the high price for the Facebook stock for the past 15 days.
|
89
|
+
|
90
|
+
```
|
91
|
+
stock history -r 15 -v high fb
|
92
|
+
```
|
93
|
+
|
94
|
+
### License
|
95
|
+
|
96
|
+
Copyright (c) 2016 Travis Loncar
|
97
|
+
|
98
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal
|
99
|
+
in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
100
|
+
|
101
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
102
|
+
|
103
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
104
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
105
|
+
THE SOFTWARE.
|
106
|
+
|
107
|
+
|
108
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "stock_quote_cli"
|
18
|
+
gem.homepage = "http://github.com/tbloncar/stock_quote_cli"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = "A Ruby gem that provides a command-line interface for fetching stock information."
|
21
|
+
gem.description = "A Ruby gem that provides a command-line interface for fetching stock information."
|
22
|
+
gem.email = "loncar.travis@gmail.com"
|
23
|
+
gem.authors = ["Travis Loncar"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rdoc/task'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "stock_quote_cli #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.0
|
data/bin/stock
ADDED
data/demo.gif
ADDED
Binary file
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "stock_quote"
|
2
|
+
|
3
|
+
module StockQuoteCLI
|
4
|
+
class API
|
5
|
+
def self.stock_history(symbol, range)
|
6
|
+
end_date = Date.today
|
7
|
+
start_date = end_date - range
|
8
|
+
StockQuote::Stock.history(symbol, start_date, end_date)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.stocks_info(symbols)
|
12
|
+
[] + StockQuote::Stock.quote(symbols.join(", "))
|
13
|
+
end
|
14
|
+
|
15
|
+
class StockQuote::Stock
|
16
|
+
private
|
17
|
+
|
18
|
+
def to_ary
|
19
|
+
[] << self
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,124 @@
|
|
1
|
+
require "thor"
|
2
|
+
require "stock_quote"
|
3
|
+
|
4
|
+
module StockQuoteCLI
|
5
|
+
class CLI < Thor
|
6
|
+
desc "last SYMBOL [SYMBOL...]", "get day's LAST stock price for SYMBOL"
|
7
|
+
def last(*symbols)
|
8
|
+
output_info(symbols, :last_trade_price_only)
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "high SYMBOL [SYMBOL...]", "get day's HIGH stock price for SYMBOL"
|
12
|
+
def high(*symbols)
|
13
|
+
output_info(symbols, :days_high)
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "low SYMBOL [SYMBOL...]", "get day's LOW stock price for SYMBOL"
|
17
|
+
def low(*symbols)
|
18
|
+
output_info(symbols, :days_low)
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "change SYMBOL [SYMBOL...]", "get day's CHANGE in stock price for SYMBOL"
|
22
|
+
def change(*symbols)
|
23
|
+
output_info(symbols, :change)
|
24
|
+
end
|
25
|
+
|
26
|
+
desc "open SYMBOL [SYMBOL...]", "get day's OPEN stock price for SYMBOL"
|
27
|
+
def open(*symbols)
|
28
|
+
output_info(symbols, :open)
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "pclose SYMBOL [SYMBOL...]", "get previous closing (PCLOSE) stock price for SYMBOL"
|
32
|
+
def pclose(*symbols)
|
33
|
+
output_info(symbols, :previous_close)
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "volume SYMBOL [SYMBOL...]", "get share VOLUME for SYMBOL"
|
37
|
+
def volume(*symbols)
|
38
|
+
output_info(symbols, :volume)
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "history SYMBOL", "get HISTORY of stock price for SYMBOL"
|
42
|
+
method_option "range", aliases: "-r", type: :numeric, default: 14, desc: "Specify the number of trading days for which to return stock price information."
|
43
|
+
method_option "value", aliases: "-v", type: :string, default: "close", desc: "Specify the stock price value to retrieve for each date."
|
44
|
+
def history(symbol)
|
45
|
+
history = API.stock_history(symbol, options['range'])
|
46
|
+
output_stock_history(history, options['value'], symbol)
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def output_info(symbols, vname)
|
52
|
+
stocks = API.stocks_info(symbols)
|
53
|
+
output_stocks_info(stocks, vname)
|
54
|
+
end
|
55
|
+
|
56
|
+
def output_stocks_info(stocks, vname)
|
57
|
+
puts
|
58
|
+
stocks.each do |quote|
|
59
|
+
# Ensure that quote object has data. If not,
|
60
|
+
# it probably represents an invalid symbol.
|
61
|
+
if quote.open
|
62
|
+
company = format_company(quote.name)
|
63
|
+
if vname == :volume
|
64
|
+
puts "#{company}: #{format_volume(quote.volume)}"
|
65
|
+
else
|
66
|
+
puts "#{company}: #{format_price(quote.send(vname))}"
|
67
|
+
end
|
68
|
+
else
|
69
|
+
output_bad_symbol_message(quote.symbol)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
puts
|
73
|
+
end
|
74
|
+
|
75
|
+
def output_stock_history(history, vname, symbol)
|
76
|
+
return output_bad_symbol_message(symbol) if history.is_a?(StockQuote::NoDataForStockError)
|
77
|
+
|
78
|
+
voptions = %w[open high low close volume]
|
79
|
+
if voptions.include?(vname)
|
80
|
+
puts "\n#{format_title(vname, symbol)}\n"
|
81
|
+
history.each do |quote|
|
82
|
+
date = format_date(quote.date.to_s)
|
83
|
+
if vname == "volume"
|
84
|
+
puts "#{date}: #{format_volume(quote.send(vname))}"
|
85
|
+
else
|
86
|
+
puts "#{date}: #{format_price(quote.send(vname))}"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
else
|
90
|
+
output_bad_vname_message(vname)
|
91
|
+
end
|
92
|
+
puts
|
93
|
+
end
|
94
|
+
|
95
|
+
def output_bad_symbol_message(symbol)
|
96
|
+
puts Text.red("No data available for symbol: #{symbol.upcase}".rjust(28))
|
97
|
+
end
|
98
|
+
|
99
|
+
def output_bad_vname_message(vname)
|
100
|
+
puts Text.red("#{'Invalid value:'.rjust(28)} #{vname}")
|
101
|
+
end
|
102
|
+
|
103
|
+
def format_company(company)
|
104
|
+
Text.green(company).rjust(40)
|
105
|
+
end
|
106
|
+
|
107
|
+
def format_date(date)
|
108
|
+
Text.green(date).rjust(40)
|
109
|
+
end
|
110
|
+
|
111
|
+
def format_price(price)
|
112
|
+
"$#{Text.number_with_commas(price)}"
|
113
|
+
end
|
114
|
+
|
115
|
+
def format_volume(volume)
|
116
|
+
"#{Text.number_with_commas(volume.to_i)} shares"
|
117
|
+
end
|
118
|
+
|
119
|
+
def format_title(vname, symbol)
|
120
|
+
"#{Text.yellow(vname.upcase)} data for:".rjust(39) +
|
121
|
+
" #{Text.yellow(symbol.upcase)}\n"
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module StockQuoteCLI
|
2
|
+
class Text
|
3
|
+
class << self
|
4
|
+
# color methods from https://github.com/pierot/stockery/blob/master/lib/stockery.rb
|
5
|
+
def red(str); color(str, "\e[31m"); end
|
6
|
+
def green(str); color(str, "\e[1m\e[32m"); end
|
7
|
+
def yellow(str); color(str, "\e[0;33m"); end
|
8
|
+
|
9
|
+
def number_with_commas(n)
|
10
|
+
int, dec = n.to_s.split(".")
|
11
|
+
int.chars.reverse.each_slice(3).reduce("") { |m, s|
|
12
|
+
m + s.join + (s.size == 3 ? "," : "")
|
13
|
+
}.reverse.gsub(/^,/, '') + (dec ? ".#{dec}" : "")
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def color(text, color_code)
|
19
|
+
"#{color_code}#{text}\e[0m"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'stock_quote_cli'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
module StockQuoteCLI
|
4
|
+
describe CLI do
|
5
|
+
let(:cli) { CLI }
|
6
|
+
|
7
|
+
context 'history' do
|
8
|
+
it 'should accept a history method' do
|
9
|
+
$stdout.should_receive(:puts).at_least(10).times
|
10
|
+
cli.start(["history", "ebay"])
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'should accept a range option' do
|
14
|
+
$stdout.should_receive(:puts).at_least(14).times
|
15
|
+
cli.start(["history", "-r", "20", "fb"])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: stock_quote_cli 0.0.0 ruby lib
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "stock_quote_cli"
|
9
|
+
s.version = "0.0.0"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
13
|
+
s.authors = ["Travis Loncar"]
|
14
|
+
s.date = "2016-01-01"
|
15
|
+
s.description = "A Ruby gem that provides a command-line interface for fetching stock information."
|
16
|
+
s.email = "loncar.travis@gmail.com"
|
17
|
+
s.executables = ["stock"]
|
18
|
+
s.extra_rdoc_files = [
|
19
|
+
"README.md"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".rspec",
|
23
|
+
".travis.yml",
|
24
|
+
"Gemfile",
|
25
|
+
"Gemfile.lock",
|
26
|
+
"README.md",
|
27
|
+
"Rakefile",
|
28
|
+
"VERSION",
|
29
|
+
"bin/stock",
|
30
|
+
"demo.gif",
|
31
|
+
"lib/stock_quote_cli.rb",
|
32
|
+
"lib/stock_quote_cli/api.rb",
|
33
|
+
"lib/stock_quote_cli/cli.rb",
|
34
|
+
"lib/stock_quote_cli/text.rb",
|
35
|
+
"lib/stock_quote_cli/version.rb",
|
36
|
+
"spec/spec_helper.rb",
|
37
|
+
"spec/stock_quote_cli_spec.rb",
|
38
|
+
"stock_quote_cli.gemspec"
|
39
|
+
]
|
40
|
+
s.homepage = "http://github.com/tbloncar/stock_quote_cli"
|
41
|
+
s.licenses = ["MIT"]
|
42
|
+
s.rubygems_version = "2.4.8"
|
43
|
+
s.summary = "A Ruby gem that provides a command-line interface for fetching stock information."
|
44
|
+
|
45
|
+
if s.respond_to? :specification_version then
|
46
|
+
s.specification_version = 4
|
47
|
+
|
48
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
49
|
+
s.add_runtime_dependency(%q<thor>, ["~> 0.19"])
|
50
|
+
s.add_runtime_dependency(%q<stock_quote>, ["~> 1.2"])
|
51
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
52
|
+
s.add_development_dependency(%q<shoulda-matchers>, ["~> 2.7"])
|
53
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
54
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
55
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.7"])
|
56
|
+
s.add_development_dependency(%q<pry>, ["~> 0.10"])
|
57
|
+
else
|
58
|
+
s.add_dependency(%q<thor>, ["~> 0.19"])
|
59
|
+
s.add_dependency(%q<stock_quote>, ["~> 1.2"])
|
60
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
61
|
+
s.add_dependency(%q<shoulda-matchers>, ["~> 2.7"])
|
62
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
63
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
64
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
|
65
|
+
s.add_dependency(%q<pry>, ["~> 0.10"])
|
66
|
+
end
|
67
|
+
else
|
68
|
+
s.add_dependency(%q<thor>, ["~> 0.19"])
|
69
|
+
s.add_dependency(%q<stock_quote>, ["~> 1.2"])
|
70
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
71
|
+
s.add_dependency(%q<shoulda-matchers>, ["~> 2.7"])
|
72
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
73
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
74
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
|
75
|
+
s.add_dependency(%q<pry>, ["~> 0.10"])
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
metadata
ADDED
@@ -0,0 +1,175 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: stock_quote_cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Travis Loncar
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-01-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.19'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.19'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: stock_quote
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.2'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.8.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.8.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: shoulda-matchers
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.7'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.7'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rdoc
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.12'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.12'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bundler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: jeweler
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.8.7
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.8.7
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: pry
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.10'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0.10'
|
125
|
+
description: A Ruby gem that provides a command-line interface for fetching stock
|
126
|
+
information.
|
127
|
+
email: loncar.travis@gmail.com
|
128
|
+
executables:
|
129
|
+
- stock
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files:
|
132
|
+
- README.md
|
133
|
+
files:
|
134
|
+
- ".rspec"
|
135
|
+
- ".travis.yml"
|
136
|
+
- Gemfile
|
137
|
+
- Gemfile.lock
|
138
|
+
- README.md
|
139
|
+
- Rakefile
|
140
|
+
- VERSION
|
141
|
+
- bin/stock
|
142
|
+
- demo.gif
|
143
|
+
- lib/stock_quote_cli.rb
|
144
|
+
- lib/stock_quote_cli/api.rb
|
145
|
+
- lib/stock_quote_cli/cli.rb
|
146
|
+
- lib/stock_quote_cli/text.rb
|
147
|
+
- lib/stock_quote_cli/version.rb
|
148
|
+
- spec/spec_helper.rb
|
149
|
+
- spec/stock_quote_cli_spec.rb
|
150
|
+
- stock_quote_cli.gemspec
|
151
|
+
homepage: http://github.com/tbloncar/stock_quote_cli
|
152
|
+
licenses:
|
153
|
+
- MIT
|
154
|
+
metadata: {}
|
155
|
+
post_install_message:
|
156
|
+
rdoc_options: []
|
157
|
+
require_paths:
|
158
|
+
- lib
|
159
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
160
|
+
requirements:
|
161
|
+
- - ">="
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '0'
|
164
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - ">="
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: '0'
|
169
|
+
requirements: []
|
170
|
+
rubyforge_project:
|
171
|
+
rubygems_version: 2.4.8
|
172
|
+
signing_key:
|
173
|
+
specification_version: 4
|
174
|
+
summary: A Ruby gem that provides a command-line interface for fetching stock information.
|
175
|
+
test_files: []
|