google-finance-ruby-client 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +6 -0
- data/.rspec +2 -0
- data/.rubocop.yml +9 -0
- data/.rubocop_todo.yml +69 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.md +3 -0
- data/CONTRIBUTING.md +125 -0
- data/Gemfile +3 -0
- data/LICENSE.md +22 -0
- data/README.md +63 -0
- data/RELEASING.md +61 -0
- data/Rakefile +17 -0
- data/google-finance-ruby-client.gemspec +26 -0
- data/google-finance.png +0 -0
- data/lib/google-finance-ruby-client.rb +11 -0
- data/lib/google-finance/errors.rb +2 -0
- data/lib/google-finance/errors/symbol_not_found_error.rb +14 -0
- data/lib/google-finance/errors/symbols_not_found_error.rb +14 -0
- data/lib/google-finance/faraday_middleware/preprocessor.rb +10 -0
- data/lib/google-finance/quote.rb +72 -0
- data/lib/google-finance/quotes.rb +20 -0
- data/lib/google-finance/resource.rb +4 -0
- data/lib/google-finance/resources.rb +28 -0
- data/lib/google-finance/version.rb +3 -0
- data/spec/fixtures/google-finance/invalid.yml +73 -0
- data/spec/fixtures/google-finance/msft.yml +1030 -0
- data/spec/fixtures/google-finance/msft_ab.yml +2149 -0
- data/spec/fixtures/google-finance/msft_ab_invalid.yml +73 -0
- data/spec/fixtures/google-finance/search_invalid.yml +73 -0
- data/spec/fixtures/google-finance/search_msft.yml +1030 -0
- data/spec/google-finance/quote_spec.rb +37 -0
- data/spec/google-finance/quotes_spec.rb +39 -0
- data/spec/google-finance/version_spec.rb +7 -0
- data/spec/spec_helper.rb +10 -0
- data/spec/support/vcr.rb +9 -0
- metadata +201 -0
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GoogleFinance::Quote do
|
4
|
+
context 'known symbol', vcr: { cassette_name: 'msft' } do
|
5
|
+
subject do
|
6
|
+
GoogleFinance::Quote.get('MSFT')
|
7
|
+
end
|
8
|
+
it 'retrieves a quote' do
|
9
|
+
expect(subject.symbol).to eq 'MSFT'
|
10
|
+
expect(subject.exchange).to eq 'NASDAQ'
|
11
|
+
expect(subject.id).to eq '358464'
|
12
|
+
expect(subject.name).to eq 'Microsoft Corporation'
|
13
|
+
expect(subject.market_capitalization).to eq '650.73B'
|
14
|
+
end
|
15
|
+
it 'renames and coerces reuters_url' do
|
16
|
+
expect(subject.reuters_url).to eq URI('http://stocks.us.reuters.com/stocks/ratios.asp?rpc=66&symbol=MSFT.O')
|
17
|
+
end
|
18
|
+
it 'coerces numbers' do
|
19
|
+
expect(subject.last_trade_price).to eq 84.26
|
20
|
+
expect(subject.change).to eq 0.09
|
21
|
+
expect(subject.high_52_week).to eq 86.2
|
22
|
+
expect(subject.low_52_week).to eq 58.8
|
23
|
+
expect(subject.change_in_percent).to eq 0.11
|
24
|
+
expect(subject.change_in_percent_s).to eq '+0.11%'
|
25
|
+
expect(subject.earnings_per_share).to eq 2.96
|
26
|
+
expect(subject.price_earnings_ratio).to eq 28.51
|
27
|
+
end
|
28
|
+
end
|
29
|
+
context 'invalid symbol', vcr: { cassette_name: 'invalid' } do
|
30
|
+
subject do
|
31
|
+
GoogleFinance::Quote.get('INVALID')
|
32
|
+
end
|
33
|
+
it 'fails with SymbolNotFoundError' do
|
34
|
+
expect { subject }.to raise_error GoogleFinance::Errors::SymbolNotFoundError, 'Symbol INVALID Not Found'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GoogleFinance::Quotes do
|
4
|
+
context 'known symbol', vcr: { cassette_name: 'search_msft' } do
|
5
|
+
subject do
|
6
|
+
GoogleFinance::Quotes.search('MSFT')
|
7
|
+
end
|
8
|
+
it 'retrieves a single quote' do
|
9
|
+
expect(subject.size).to eq 1
|
10
|
+
expect(subject[0].symbol).to eq 'MSFT'
|
11
|
+
end
|
12
|
+
end
|
13
|
+
context 'known symbols', vcr: { cassette_name: 'msft_ab' } do
|
14
|
+
subject do
|
15
|
+
GoogleFinance::Quotes.search('MSFT', 'AB')
|
16
|
+
end
|
17
|
+
it 'retrieves multiple quotes' do
|
18
|
+
expect(subject.size).to eq 2
|
19
|
+
expect(subject[0].symbol).to eq 'MSFT'
|
20
|
+
expect(subject[1].symbol).to eq 'AB'
|
21
|
+
end
|
22
|
+
end
|
23
|
+
context 'invalid symbol', vcr: { cassette_name: 'search_invalid' } do
|
24
|
+
subject do
|
25
|
+
GoogleFinance::Quotes.search('INVALID')
|
26
|
+
end
|
27
|
+
it 'retrieves a single quote' do
|
28
|
+
expect { subject }.to raise_error GoogleFinance::Errors::SymbolsNotFoundError, 'One or More Symbols INVALID Not Found'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
context 'with an invalid symbol', vcr: { cassette_name: 'msft_ab_invalid' } do
|
32
|
+
subject do
|
33
|
+
GoogleFinance::Quotes.search('MSFT', 'AB', 'INVALID')
|
34
|
+
end
|
35
|
+
it 'retrieves multiple quotes' do
|
36
|
+
expect { subject }.to raise_error GoogleFinance::Errors::SymbolsNotFoundError, 'One or More Symbols MSFT AB INVALID Not Found'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/spec/spec_helper.rb
ADDED
data/spec/support/vcr.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
require 'vcr'
|
2
|
+
require 'webmock/rspec'
|
3
|
+
|
4
|
+
VCR.configure do |config|
|
5
|
+
config.cassette_library_dir = 'spec/fixtures/google-finance'
|
6
|
+
config.hook_into :webmock
|
7
|
+
# config.default_cassette_options = { record: :new_episodes }
|
8
|
+
config.configure_rspec_metadata!
|
9
|
+
end
|
metadata
ADDED
@@ -0,0 +1,201 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: google-finance-ruby-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel Doubrovkine
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-12-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.9'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday_middleware
|
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: hashie
|
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: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
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: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.51.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 0.51.0
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: vcr
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: webmock
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description:
|
126
|
+
email: dblock@dblock.org
|
127
|
+
executables: []
|
128
|
+
extensions: []
|
129
|
+
extra_rdoc_files: []
|
130
|
+
files:
|
131
|
+
- ".gitignore"
|
132
|
+
- ".rspec"
|
133
|
+
- ".rubocop.yml"
|
134
|
+
- ".rubocop_todo.yml"
|
135
|
+
- ".travis.yml"
|
136
|
+
- CHANGELOG.md
|
137
|
+
- CONTRIBUTING.md
|
138
|
+
- Gemfile
|
139
|
+
- LICENSE.md
|
140
|
+
- README.md
|
141
|
+
- RELEASING.md
|
142
|
+
- Rakefile
|
143
|
+
- google-finance-ruby-client.gemspec
|
144
|
+
- google-finance.png
|
145
|
+
- lib/google-finance-ruby-client.rb
|
146
|
+
- lib/google-finance/errors.rb
|
147
|
+
- lib/google-finance/errors/symbol_not_found_error.rb
|
148
|
+
- lib/google-finance/errors/symbols_not_found_error.rb
|
149
|
+
- lib/google-finance/faraday_middleware/preprocessor.rb
|
150
|
+
- lib/google-finance/quote.rb
|
151
|
+
- lib/google-finance/quotes.rb
|
152
|
+
- lib/google-finance/resource.rb
|
153
|
+
- lib/google-finance/resources.rb
|
154
|
+
- lib/google-finance/version.rb
|
155
|
+
- spec/fixtures/google-finance/invalid.yml
|
156
|
+
- spec/fixtures/google-finance/msft.yml
|
157
|
+
- spec/fixtures/google-finance/msft_ab.yml
|
158
|
+
- spec/fixtures/google-finance/msft_ab_invalid.yml
|
159
|
+
- spec/fixtures/google-finance/search_invalid.yml
|
160
|
+
- spec/fixtures/google-finance/search_msft.yml
|
161
|
+
- spec/google-finance/quote_spec.rb
|
162
|
+
- spec/google-finance/quotes_spec.rb
|
163
|
+
- spec/google-finance/version_spec.rb
|
164
|
+
- spec/spec_helper.rb
|
165
|
+
- spec/support/vcr.rb
|
166
|
+
homepage: http://github.com/dblock/google-finance-ruby-client
|
167
|
+
licenses:
|
168
|
+
- MIT
|
169
|
+
metadata: {}
|
170
|
+
post_install_message:
|
171
|
+
rdoc_options: []
|
172
|
+
require_paths:
|
173
|
+
- lib
|
174
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
175
|
+
requirements:
|
176
|
+
- - ">="
|
177
|
+
- !ruby/object:Gem::Version
|
178
|
+
version: '0'
|
179
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
180
|
+
requirements:
|
181
|
+
- - ">="
|
182
|
+
- !ruby/object:Gem::Version
|
183
|
+
version: 1.3.6
|
184
|
+
requirements: []
|
185
|
+
rubyforge_project:
|
186
|
+
rubygems_version: 2.6.12
|
187
|
+
signing_key:
|
188
|
+
specification_version: 4
|
189
|
+
summary: Google Finance web API ruby client.
|
190
|
+
test_files:
|
191
|
+
- spec/fixtures/google-finance/invalid.yml
|
192
|
+
- spec/fixtures/google-finance/msft.yml
|
193
|
+
- spec/fixtures/google-finance/msft_ab.yml
|
194
|
+
- spec/fixtures/google-finance/msft_ab_invalid.yml
|
195
|
+
- spec/fixtures/google-finance/search_invalid.yml
|
196
|
+
- spec/fixtures/google-finance/search_msft.yml
|
197
|
+
- spec/google-finance/quote_spec.rb
|
198
|
+
- spec/google-finance/quotes_spec.rb
|
199
|
+
- spec/google-finance/version_spec.rb
|
200
|
+
- spec/spec_helper.rb
|
201
|
+
- spec/support/vcr.rb
|