stock_quote_cli 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ac4ef8b3d44d215e90402941e4c6c337c395bc91
4
- data.tar.gz: 7bc9fcc4834be7becea81c19e7bcf9f46a039e2d
3
+ metadata.gz: c2f026e810d56e1c1a4569ae66aeb3c7f213b4ad
4
+ data.tar.gz: 3d9e0f96f63cce57cdb204bf777a7aa876ce6da6
5
5
  SHA512:
6
- metadata.gz: 5e0387c82dafb2a3a9de3750e6db88f7febc155038520e2e4f2bcce905b181af93cb9a24987cd4be8342582a938cad821b2fbad418d7075d1ff049b4ca80e29c
7
- data.tar.gz: 91d75279c38572fa1d8b2c68929bb5a30137c539a2143878a5da5a9fc51be7410d724f609bcacb1c5496841fa65c7cd1e054358a42a73f417fd13e7b5c33fad7
6
+ metadata.gz: 9c066ddaf42915093992312c1e195e40d909747b439603e09b01330cde76659f6938e91ee5550542e24733657098864e5aced7d32345c0b7609cb403c30483a4
7
+ data.tar.gz: 354bf7d6f24d5cf8362c888c0ab56a5c207ac0d693a18b7e91c0f4958aa6e55159b158dea7b30754cd4a57bf60215a8f496613e95f1eb8c25248f9bd66e61826
data/.rspec CHANGED
@@ -1 +1 @@
1
- --color
1
+ --color --format documentation
data/README.md CHANGED
@@ -1,13 +1,10 @@
1
- Stock Quote CLI
2
- ===============
1
+ ## Stock Quote CLI
3
2
 
4
3
  [![Build Status](https://travis-ci.org/tbloncar/stock_quote_cli.png?branch=master)](https://travis-ci.org/tbloncar/stock_quote_cli)
5
4
 
6
- ### Description
7
-
8
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.
9
6
 
10
- ![Example](https://raw.githubusercontent.com/tbloncar/stock_quote_cli/master/example.png)
7
+ ![Demo](https://raw.githubusercontent.com/tbloncar/stock_quote_cli/master/demo.gif)
11
8
 
12
9
  Update: Due to Google's sunsetting of iGoogle (and the associated endpoint from
13
10
  which the stock_quote gem once fetched its data), the stock_quote gem has moved
@@ -16,11 +13,13 @@ the awesomely quick changes.
16
13
 
17
14
  ### Installation
18
15
 
19
- Build passes with `ruby-2.0.0-p247`. With Ruby installed, run the following:
16
+ With Ruby installed, run the following:
20
17
 
21
- gem install stock_quote_cli
18
+ ```
19
+ gem install stock_quote_cli
20
+ ```
22
21
 
23
- ### Usage Details
22
+ ### Usage
24
23
 
25
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).
26
25
 
@@ -28,41 +27,55 @@ You can use Stock Quote CLI to fetch real-time attributes of multiple stocks. Us
28
27
 
29
28
  Get the latest price for the specified stock(s).
30
29
 
31
- stock last goog yhoo aapl
30
+ ```
31
+ stock last goog yhoo aapl
32
+ ```
32
33
 
33
34
  #### Open Price
34
35
 
35
36
  Get the opening price for the specified stock(s) on the current day (or last trading day).
36
37
 
37
- stock open znga
38
+ ```
39
+ stock open znga
40
+ ```
38
41
 
39
42
  #### Previous Closing Price
40
43
 
41
44
  Get the closing price for the specified stock(s) on the previous trading day.
42
45
 
43
- stock yclose amzn nflx
46
+ ```
47
+ stock yclose amzn nflx
48
+ ```
44
49
 
45
50
  #### High Price
46
51
 
47
52
  Get the high price for the specified stock(s) on the current day (or last trading day).
48
53
 
49
- stock high lnkd
54
+ ```
55
+ stock high lnkd
56
+ ```
50
57
 
51
58
  #### Low Price
52
59
 
53
60
  Get the low price for the specified stock(s) on the current day (or last trading day).
54
61
 
55
- stock low msft dell
62
+ ```
63
+ stock low msft dell
64
+ ```
56
65
 
57
66
  #### Historical Data
58
67
 
59
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.
60
69
 
61
- stock history fb
70
+ ```
71
+ stock history fb
72
+ ```
62
73
 
63
74
  The `range` (`-r`) option takes an integer. Use this to specify the number of trading days for which you'd like data.
64
75
 
65
- stock history -r 15 fb
76
+ ```
77
+ stock history -r 15 fb
78
+ ```
66
79
 
67
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:
68
81
 
@@ -74,11 +87,13 @@ The `value` (`-v`) option takes a string. Use this to specify the price value th
74
87
 
75
88
  Below, we fetch the high price for the Facebook stock for the past 15 days.
76
89
 
77
- stock history -r 15 -v high fb
90
+ ```
91
+ stock history -r 15 -v high fb
92
+ ```
78
93
 
79
94
  ### License
80
95
 
81
- Copyright (c) 2015 Travis Loncar
96
+ Copyright (c) 2016 Travis Loncar
82
97
 
83
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
84
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:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.1
1
+ 1.1.0
Binary file
@@ -1,18 +1,4 @@
1
- require "stock_quote_cli/cli"
2
-
3
- module StockQuoteCLI
4
- class TextHelpers
5
- class << self
6
- # color methods from https://github.com/pierot/stockery/blob/master/lib/stockery.rb
7
- def red(str); color(str, "\e[31m"); end
8
- def green(str); color(str, "\e[1m\e[32m"); end
9
- def yellow(str); color(str, "\e[0;33m"); end
10
-
11
- private
12
-
13
- def color(text, color_code)
14
- "#{color_code}#{text}\e[0m"
15
- end
16
- end
17
- end
18
- end
1
+ require "stock_quote_cli/version"
2
+ require "stock_quote_cli/api"
3
+ require "stock_quote_cli/text"
4
+ require "stock_quote_cli/cli"
@@ -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
@@ -1,164 +1,124 @@
1
1
  require "thor"
2
2
  require "stock_quote"
3
- require "stock_quote_cli/quote"
4
- require "stock_quote_cli/history"
5
3
 
6
4
  module StockQuoteCLI
7
- class CLI < Thor
8
- include StockQuoteCLI::Quote
9
- include StockQuoteCLI::History
10
-
11
- DEFAULT_RANGE = 14 # days
12
- DEFAULT_VALUE = "close"
13
- VALUE_OPTIONS = ["open", "high", "low", "close", "volume"]
14
-
15
- desc "last SYMBOL [SYMBOL...]", "get day's LAST stock price for SYMBOL"
16
- def last(symbol, *symbols)
17
- stocks = stocks(symbol, symbols)
18
- output_quote_messages(stocks, :last_trade_price_only)
19
- end
20
-
21
- desc "high SYMBOL [SYMBOL...]", "get day's HIGH stock price for SYMBOL"
22
- def high(symbol, *symbols)
23
- stocks = stocks(symbol, symbols)
24
- output_quote_messages(stocks, :days_high)
25
- end
26
-
27
- desc "low SYMBOL [SYMBOL...]", "get day's LOW stock price for SYMBOL"
28
- def low(symbol, *symbols)
29
- stocks = stocks(symbol, symbols)
30
- output_quote_messages(stocks, :days_low)
31
- end
32
-
33
- desc "change SYMBOL [SYMBOL...]", "get day's CHANGE in stock price for SYMBOL"
34
- def change(symbol, *symbols)
35
- stocks = stocks(symbol, symbols)
36
- output_quote_messages(stocks, :change)
37
- end
38
-
39
- desc "open SYMBOL [SYMBOL...]", "get day's OPEN stock price for SYMBOL"
40
- def open(symbol, *symbols)
41
- stocks = stocks(symbol, symbols)
42
- output_quote_messages(stocks, :open)
43
- end
44
-
45
- desc "pclose SYMBOL [SYMBOL...]", "get previous closing (PCLOSE) stock price for SYMBOL"
46
- def pclose(symbol, *symbols)
47
- stocks = stocks(symbol, symbols)
48
- output_quote_messages(stocks, :previous_close)
49
- end
50
-
51
- desc "volume SYMBOL [SYMBOL...]", "get share VOLUME for SYMBOL"
52
- def volume(symbol, *symbols)
53
- stocks = stocks(symbol, symbols)
54
- output_quote_messages(stocks, :volume)
55
- end
56
-
57
- desc "history SYMBOL", "get HISTORY of stock price for SYMBOL"
58
- method_option "range", aliases: "-r", type: :numeric, default: DEFAULT_RANGE, desc: "Specify the number of trading days for which to return stock price information."
59
- method_option "value", aliases: "-v", type: :string, default: DEFAULT_VALUE, desc: "Specify the stock price value to retrieve for each date."
60
- def history(symbol)
61
- stock_history = get_stock_history(symbol, options['range'])
62
- value = options['value']
63
- output_history_messages(stock_history, value, VALUE_OPTIONS, symbol)
64
- end
65
-
66
- private
67
-
68
- def output_quote_messages(stocks, method_name)
69
- puts
70
- stocks.each do |stock|
71
- if stock.response_code == 200
72
- company = format_company(stock.name)
73
- unless method_name == :volume
74
- price = format_price(stock.send(method_name))
75
- puts "#{company}: #{price}"
76
- else
77
- volume = format_volume(stock.volume)
78
- puts "#{company}: #{volume}"
79
- end
80
- else
81
- puts bad_symbol_message
82
- end
83
- end
84
- puts
85
- end
86
-
87
- def output_history_messages(stock_history, method_name, method_options, symbol)
88
- puts
89
- if stock_history.is_a?(StockQuote::NoDataForStockError)
90
- puts bad_symbol_message
91
- else
92
- if method_options.include?(method_name)
93
- puts format_title(method_name, symbol)
94
- puts
95
- stock_history.each do |day|
96
- date = format_date(day.date.to_s)
97
- unless method_name == "volume"
98
- price = format_price(day.send(method_name))
99
- puts "#{date}: #{price}"
100
- else
101
- volume = format_volume(day.send(method_name))
102
- puts "#{date}: #{volume}"
103
- end
104
- end
105
- else
106
- puts bad_value_message(method_name)
107
- end
108
- end
109
- puts
110
- end
111
-
112
- def bad_symbol_message
113
- TextHelpers.red('No data available for symbol...'.rjust(28))
114
- end
115
-
116
- def bad_value_message(value_name)
117
- TextHelpers.red("#{'Invalid value:'.rjust(28)} #{value_name}")
118
- end
119
-
120
- def format_company(company)
121
- TextHelpers.green(company).rjust(40)
122
- end
123
-
124
- def format_date(date)
125
- TextHelpers.green(date).rjust(40)
126
- end
127
-
128
- def format_price(price)
129
- "$#{price.number_with_commas}"
130
- end
131
-
132
- def format_volume(volume)
133
- "#{volume.number_with_commas} shares"
134
- end
135
-
136
- def format_title(method_name, symbol)
137
- "#{TextHelpers.yellow(method_name.upcase)} data for".rjust(38) + ": #{TextHelpers.yellow(symbol.upcase)}"
138
- end
139
- end
140
- end
141
-
142
- class Numeric
143
- def number_with_commas
144
- split_on_dot = to_s.split("\.")
145
- whole = split_on_dot[0]
146
- decimal = split_on_dot[1] || ""
147
- char_array = whole.reverse.split(//)
148
- whole_with_commas = char_array.each_with_index.map do |char, i|
149
- if char_array.size > 3 && i % 3 == 0 && i > 0
150
- "#{char},"
151
- else
152
- char
153
- end
154
- end.reverse.join("")
155
- if decimal.size == 1
156
- decimal = "#{decimal}0"
157
- end
158
- unless decimal == "" || decimal == "00"
159
- "#{whole_with_commas}.#{decimal}"
160
- else
161
- "#{whole_with_commas}"
162
- end
163
- end
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
164
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
@@ -0,0 +1,3 @@
1
+ module StockQuoteCLI
2
+ VERSION = "1.1.0"
3
+ end
@@ -8,5 +8,4 @@ require 'stock_quote_cli'
8
8
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
9
 
10
10
  RSpec.configure do |config|
11
-
12
11
  end
@@ -1,13 +1,9 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
3
  module StockQuoteCLI
4
- describe CLI do
4
+ describe CLI do
5
5
  let(:cli) { CLI }
6
6
 
7
- it 'should exist' do
8
- subject.should be_true
9
- end
10
-
11
7
  context 'history' do
12
8
  it 'should accept a history method' do
13
9
  $stdout.should_receive(:puts).at_least(10).times
@@ -19,11 +15,5 @@ module StockQuoteCLI
19
15
  cli.start(["history", "-r", "20", "fb"])
20
16
  end
21
17
  end
22
-
23
- context 'last' do
24
- it 'should accept one argument' do
25
- subject.stub(:last) { nil }
26
- end
27
- end
28
- end
18
+ end
29
19
  end
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Travis Loncar"]
14
- s.date = "2015-01-01"
14
+ s.date = "2016-01-01"
15
15
  s.description = "A Ruby gem that provides a command-line interface for fetching stock information."
16
16
  s.email = "loncar.travis@gmail.com"
17
17
  s.executables = ["stock"]
@@ -20,7 +20,6 @@ Gem::Specification.new do |s|
20
20
  "README.md"
21
21
  ]
22
22
  s.files = [
23
- ".document",
24
23
  ".rspec",
25
24
  ".travis.yml",
26
25
  "Gemfile",
@@ -30,18 +29,19 @@ Gem::Specification.new do |s|
30
29
  "Rakefile",
31
30
  "VERSION",
32
31
  "bin/stock",
33
- "example.png",
32
+ "demo.gif",
34
33
  "lib/stock_quote_cli.rb",
34
+ "lib/stock_quote_cli/api.rb",
35
35
  "lib/stock_quote_cli/cli.rb",
36
- "lib/stock_quote_cli/history.rb",
37
- "lib/stock_quote_cli/quote.rb",
36
+ "lib/stock_quote_cli/text.rb",
37
+ "lib/stock_quote_cli/version.rb",
38
38
  "spec/spec_helper.rb",
39
39
  "spec/stock_quote_cli_spec.rb",
40
40
  "stock_quote_cli.gemspec"
41
41
  ]
42
42
  s.homepage = "http://github.com/tbloncar/stock_quote_cli"
43
43
  s.licenses = ["MIT"]
44
- s.rubygems_version = "2.4.5"
44
+ s.rubygems_version = "2.4.8"
45
45
  s.summary = "A Ruby gem that provides a command-line interface for fetching stock information."
46
46
 
47
47
  if s.respond_to? :specification_version then
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stock_quote_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Travis Loncar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-01 00:00:00.000000000 Z
11
+ date: 2016-01-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -129,24 +129,22 @@ executables:
129
129
  - stock
130
130
  extensions: []
131
131
  extra_rdoc_files:
132
- - LICENSE.txt
133
132
  - README.md
134
133
  files:
135
- - ".document"
136
134
  - ".rspec"
137
135
  - ".travis.yml"
138
136
  - Gemfile
139
137
  - Gemfile.lock
140
- - LICENSE.txt
141
138
  - README.md
142
139
  - Rakefile
143
140
  - VERSION
144
141
  - bin/stock
145
- - example.png
142
+ - demo.gif
146
143
  - lib/stock_quote_cli.rb
144
+ - lib/stock_quote_cli/api.rb
147
145
  - lib/stock_quote_cli/cli.rb
148
- - lib/stock_quote_cli/history.rb
149
- - lib/stock_quote_cli/quote.rb
146
+ - lib/stock_quote_cli/text.rb
147
+ - lib/stock_quote_cli/version.rb
150
148
  - spec/spec_helper.rb
151
149
  - spec/stock_quote_cli_spec.rb
152
150
  - stock_quote_cli.gemspec
@@ -170,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
168
  version: '0'
171
169
  requirements: []
172
170
  rubyforge_project:
173
- rubygems_version: 2.4.5
171
+ rubygems_version: 2.4.8
174
172
  signing_key:
175
173
  specification_version: 4
176
174
  summary: A Ruby gem that provides a command-line interface for fetching stock information.
data/.document DELETED
@@ -1,5 +0,0 @@
1
- lib/**/*.rb
2
- bin/*
3
- -
4
- features/**/*.feature
5
- LICENSE.txt
@@ -1,20 +0,0 @@
1
- Copyright (c) 2013 Travis Loncar
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Binary file
@@ -1,11 +0,0 @@
1
- module StockQuoteCLI
2
- module History
3
- private
4
-
5
- def get_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
- end
11
- end
@@ -1,26 +0,0 @@
1
- module StockQuoteCLI
2
- module Quote
3
- private
4
-
5
- def stocks(symbol, symbols)
6
- symbol_string = symbol_string(symbol, symbols)
7
- get_stocks(symbol_string)
8
- end
9
-
10
- def symbol_string(symbol, symbols)
11
- symbols.unshift(symbol).join(", ")
12
- end
13
-
14
- def get_stocks(symbol_string)
15
- [] + StockQuote::Stock.quote(symbol_string)
16
- end
17
-
18
- class StockQuote::Stock
19
- private
20
-
21
- def to_ary
22
- [] << self
23
- end
24
- end
25
- end
26
- end