google-finance-ruby-client 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.
- 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
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e1e3de285dc0df2900f5f75481d521d70bd9c7d4
|
4
|
+
data.tar.gz: 6d83ab892591d4def05596980920ec6a1691d6ae
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f83a316a809c9e13019648aa51546a4f25c255a22a4e0b009b8c618daff3d6f50ec5425f8ca971c5862dc99364725908a75212dd92749af7248721dd5a62a2a4
|
7
|
+
data.tar.gz: fb4fc664048cdd77f7ed0314dfcb60ac46115f2505a378c3f2e849d05e9674e14a0cd583a21d7faf3cd69ee584d9e9e71abc1b23150ec57a5a4bf92c403c28fb
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2017-12-02 20:20:41 -0500 using RuboCop version 0.51.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
Lint/AmbiguousRegexpLiteral:
|
11
|
+
Exclude:
|
12
|
+
- 'lib/google-finance/faraday_middleware/preprocessor.rb'
|
13
|
+
|
14
|
+
# Offense count: 2
|
15
|
+
Metrics/AbcSize:
|
16
|
+
Max: 20
|
17
|
+
|
18
|
+
# Offense count: 2
|
19
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
20
|
+
Metrics/BlockLength:
|
21
|
+
Max: 35
|
22
|
+
|
23
|
+
# Offense count: 7
|
24
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
25
|
+
# URISchemes: http, https
|
26
|
+
Metrics/LineLength:
|
27
|
+
Max: 132
|
28
|
+
|
29
|
+
# Offense count: 3
|
30
|
+
# Configuration parameters: CountComments.
|
31
|
+
Metrics/MethodLength:
|
32
|
+
Max: 14
|
33
|
+
|
34
|
+
# Offense count: 1
|
35
|
+
Metrics/PerceivedComplexity:
|
36
|
+
Max: 8
|
37
|
+
|
38
|
+
# Offense count: 1
|
39
|
+
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
|
40
|
+
# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
|
41
|
+
Naming/FileName:
|
42
|
+
Exclude:
|
43
|
+
- 'lib/google-finance-ruby-client.rb'
|
44
|
+
|
45
|
+
# Offense count: 6
|
46
|
+
Style/Documentation:
|
47
|
+
Exclude:
|
48
|
+
- 'spec/**/*'
|
49
|
+
- 'test/**/*'
|
50
|
+
- 'lib/google-finance/errors/symbol_not_found_error.rb'
|
51
|
+
- 'lib/google-finance/errors/symbols_not_found_error.rb'
|
52
|
+
- 'lib/google-finance/faraday_middleware/preprocessor.rb'
|
53
|
+
- 'lib/google-finance/quote.rb'
|
54
|
+
- 'lib/google-finance/quotes.rb'
|
55
|
+
- 'lib/google-finance/resources.rb'
|
56
|
+
|
57
|
+
# Offense count: 1
|
58
|
+
# Configuration parameters: MinBodyLength.
|
59
|
+
Style/GuardClause:
|
60
|
+
Exclude:
|
61
|
+
- 'lib/google-finance/quote.rb'
|
62
|
+
|
63
|
+
# Offense count: 1
|
64
|
+
# Cop supports --auto-correct.
|
65
|
+
# Configuration parameters: EnforcedStyle, SupportedStyles, AllowInnerSlashes.
|
66
|
+
# SupportedStyles: slashes, percent_r, mixed
|
67
|
+
Style/RegexpLiteral:
|
68
|
+
Exclude:
|
69
|
+
- 'lib/google-finance/faraday_middleware/preprocessor.rb'
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
# Contributing to Google-Finance-Ruby-Client
|
2
|
+
|
3
|
+
This project is work of [many contributors](https://github.com/dblock/google-finance-ruby-client/graphs/contributors).
|
4
|
+
|
5
|
+
You're encouraged to submit [pull requests](https://github.com/dblock/google-finance-ruby-client/pulls), [propose features and discuss issues](https://github.com/dblock/google-finance-ruby-client/issues).
|
6
|
+
|
7
|
+
In the examples below, substitute your Github username for `contributor` in URLs.
|
8
|
+
|
9
|
+
### Fork the Project
|
10
|
+
|
11
|
+
Fork the [project on Github](https://github.com/dblock/google-finance-ruby-client) and check out your copy.
|
12
|
+
|
13
|
+
```
|
14
|
+
git clone https://github.com/contributor/google-finance-ruby-client.git
|
15
|
+
cd google-finance-ruby-client
|
16
|
+
git remote add upstream https://github.com/dblock/google-finance-ruby-client.git
|
17
|
+
```
|
18
|
+
|
19
|
+
### Bundle Install and Test
|
20
|
+
|
21
|
+
Ensure that you can build the project and run tests.
|
22
|
+
|
23
|
+
```
|
24
|
+
bundle install
|
25
|
+
bundle exec rake
|
26
|
+
```
|
27
|
+
|
28
|
+
## Contribute Code
|
29
|
+
|
30
|
+
### Create a Topic Branch
|
31
|
+
|
32
|
+
Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
|
33
|
+
|
34
|
+
```
|
35
|
+
git checkout master
|
36
|
+
git pull upstream master
|
37
|
+
git checkout -b my-feature-branch
|
38
|
+
```
|
39
|
+
|
40
|
+
### Write Tests
|
41
|
+
|
42
|
+
Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build. Add tests to [spec](spec).
|
43
|
+
|
44
|
+
We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
|
45
|
+
|
46
|
+
### Write Code
|
47
|
+
|
48
|
+
Implement your feature or bug fix.
|
49
|
+
|
50
|
+
Ruby style is enforced with [Rubocop](https://github.com/bbatsov/rubocop). Run `bundle exec rubocop` and fix any style issues highlighted, auto-correct issues when possible with `bundle exec rubocop -a`. To silence generally ingored issues, including line lengths or code complexity metrics, run `bundle exec rubocop --auto-gen-config`.
|
51
|
+
|
52
|
+
Make sure that `bundle exec rake` completes without errors.
|
53
|
+
|
54
|
+
### Write Documentation
|
55
|
+
|
56
|
+
Document any external behavior in the [README](README.md).
|
57
|
+
|
58
|
+
### Update Changelog
|
59
|
+
|
60
|
+
Add a line to [CHANGELOG](CHANGELOG.md) under *Next Release*. Don't remove *Your contribution here*.
|
61
|
+
|
62
|
+
Make it look like every other line, including a link to the issue being fixed, your name and link to your Github account.
|
63
|
+
|
64
|
+
### Commit Changes
|
65
|
+
|
66
|
+
Make sure git knows your name and email address:
|
67
|
+
|
68
|
+
```
|
69
|
+
git config --global user.name "Your Name"
|
70
|
+
git config --global user.email "contributor@example.com"
|
71
|
+
```
|
72
|
+
|
73
|
+
Writing good commit logs is important. A commit log should describe what changed and why.
|
74
|
+
|
75
|
+
```
|
76
|
+
git add ...
|
77
|
+
git commit
|
78
|
+
```
|
79
|
+
|
80
|
+
### Push
|
81
|
+
|
82
|
+
```
|
83
|
+
git push origin my-feature-branch
|
84
|
+
```
|
85
|
+
|
86
|
+
### Make a Pull Request
|
87
|
+
|
88
|
+
Go to https://github.com/contributor/google-finance-ruby-client and select your feature branch. Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
|
89
|
+
|
90
|
+
### Update CHANGELOG Again
|
91
|
+
|
92
|
+
Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows.
|
93
|
+
|
94
|
+
```
|
95
|
+
* [#123](https://github.com/dblock/google-finance-ruby-client/pull/123): Reticulated splines - [@contributor](https://github.com/contributor).
|
96
|
+
```
|
97
|
+
|
98
|
+
Amend your previous commit and force push the changes.
|
99
|
+
|
100
|
+
```
|
101
|
+
git commit --amend
|
102
|
+
git push origin my-feature-branch -f
|
103
|
+
```
|
104
|
+
|
105
|
+
### Rebase
|
106
|
+
|
107
|
+
If you've been working on a change for a while, rebase with upstream/master.
|
108
|
+
|
109
|
+
```
|
110
|
+
git fetch upstream
|
111
|
+
git rebase upstream/master
|
112
|
+
git push origin my-feature-branch -f
|
113
|
+
```
|
114
|
+
|
115
|
+
### Check on Your Pull Request
|
116
|
+
|
117
|
+
Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.
|
118
|
+
|
119
|
+
### Be Patient
|
120
|
+
|
121
|
+
It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there!
|
122
|
+
|
123
|
+
## Thank You
|
124
|
+
|
125
|
+
Please do know that we really appreciate and value your time and work. We love you, really.
|
data/Gemfile
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 Daniel Doubrovkine and Contributors
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
Google Finance Ruby Client
|
2
|
+
==========================
|
3
|
+
|
4
|
+
[](http://badge.fury.io/rb/google-finance-ruby-client)
|
5
|
+
[](https://travis-ci.org/dblock/google-finance-ruby-client)
|
6
|
+
|
7
|
+
A Ruby client for the undocumented Google Finance web API that attempts to make sense of the data.
|
8
|
+
|
9
|
+
<a href='http://finance.google.com/finance'></a>
|
10
|
+
|
11
|
+
_IANAL, but do note that if your application is for public consumption, using the Google Finance API [seems to be against Google's terms of service](https://groups.google.com/forum/#!msg/google-finance-apis/O8fjsgnamHE/-ZKSjif4yDIJ)._
|
12
|
+
|
13
|
+
## Installation
|
14
|
+
|
15
|
+
Add to Gemfile.
|
16
|
+
|
17
|
+
```
|
18
|
+
gem 'google-finance-ruby-client'
|
19
|
+
```
|
20
|
+
|
21
|
+
Run `bundle install`.
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
### Get a Quote
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
quote = GoogleFinance::Quote.get('MSFT')
|
29
|
+
|
30
|
+
quote.last_trade_price # 84.26
|
31
|
+
quote.change # 0.09
|
32
|
+
quote.change_in_percent # 0.11
|
33
|
+
quote.change_in_percent_s # "+0.11%"
|
34
|
+
```
|
35
|
+
|
36
|
+
See [quote.rb](lib/google_finance/quote.rb) for more fields.
|
37
|
+
|
38
|
+
If a symbol cannot be found a [GoogleFinance::Errors::SymbolNotFound](lib/google-finance/errors/symbol_not_found_error.rb) is raised.
|
39
|
+
|
40
|
+
### Get Multiple Quotes
|
41
|
+
|
42
|
+
Searches for a ticker or tickers, then fetches each quote.
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
quotes = GoogleFinance::Quotes.search('MSFT', 'AB')
|
46
|
+
|
47
|
+
quotes.size # 2
|
48
|
+
|
49
|
+
quotes[0] # GoogleFinance::Quote.get('MSFT')
|
50
|
+
quotes[1] # GoogleFinance::Quote.get('AB')
|
51
|
+
```
|
52
|
+
|
53
|
+
If one of the symbols cannot be found a [GoogleFinance::Errors::SymbolsNotFound](lib/google-finance/errors/symbols_not_found_error.rb) is raised.
|
54
|
+
|
55
|
+
## Contributing
|
56
|
+
|
57
|
+
See [CONTRIBUTING](CONTRIBUTING.md).
|
58
|
+
|
59
|
+
## Copyright and License
|
60
|
+
|
61
|
+
Copyright (c) 2017, [Daniel Doubrovkine](https://twitter.com/dblockdotorg) and [Contributors](CHANGELOG.md).
|
62
|
+
|
63
|
+
This project is licensed under the [MIT License](LICENSE.md).
|
data/RELEASING.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Releasing Google-Finance-Ruby-Client
|
2
|
+
|
3
|
+
There're no hard rules about when to release google-finance-ruby-client. Release bug fixes frequently, features not so frequently and breaking API changes rarely.
|
4
|
+
|
5
|
+
### Release
|
6
|
+
|
7
|
+
Run tests, check that all tests succeed locally.
|
8
|
+
|
9
|
+
```
|
10
|
+
bundle install
|
11
|
+
rake
|
12
|
+
```
|
13
|
+
|
14
|
+
Check that the last build succeeded in [Travis CI](https://travis-ci.org/dblock/google-finance-ruby-client) for all supported platforms.
|
15
|
+
|
16
|
+
Change "Next" in [CHANGELOG.md](CHANGELOG.md) to the current date.
|
17
|
+
|
18
|
+
```
|
19
|
+
### 0.2.2 (7/10/2015)
|
20
|
+
```
|
21
|
+
|
22
|
+
Remove the line with "Your contribution here.", since there will be no more contributions to this release.
|
23
|
+
|
24
|
+
Commit your changes.
|
25
|
+
|
26
|
+
```
|
27
|
+
git add CHANGELOG.md
|
28
|
+
git commit -m "Preparing for release, 0.2.2."
|
29
|
+
git push origin master
|
30
|
+
```
|
31
|
+
|
32
|
+
Release.
|
33
|
+
|
34
|
+
```
|
35
|
+
$ rake release
|
36
|
+
|
37
|
+
google-finance-ruby-client 0.2.2 built to pkg/google-finance-ruby-client-0.2.2.gem.
|
38
|
+
Tagged v0.2.2.
|
39
|
+
Pushed git commits and tags.
|
40
|
+
Pushed google-finance-ruby-client 0.2.2 to rubygems.org.
|
41
|
+
```
|
42
|
+
|
43
|
+
### Prepare for the Next Version
|
44
|
+
|
45
|
+
Add the next release to [CHANGELOG.md](CHANGELOG.md).
|
46
|
+
|
47
|
+
```
|
48
|
+
### 0.2.3 (Next)
|
49
|
+
|
50
|
+
* Your contribution here.
|
51
|
+
```
|
52
|
+
|
53
|
+
Increment the third version number in [lib/google-finance/version.rb](lib/google-finance/version.rb).
|
54
|
+
|
55
|
+
Commit your changes.
|
56
|
+
|
57
|
+
```
|
58
|
+
git add CHANGELOG.md lib/google-finance/version.rb
|
59
|
+
git commit -m "Preparing for next development iteration, 0.2.3."
|
60
|
+
git push origin master
|
61
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
|
5
|
+
Bundler.setup :default, :development
|
6
|
+
|
7
|
+
require 'rspec/core'
|
8
|
+
require 'rspec/core/rake_task'
|
9
|
+
|
10
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
11
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
12
|
+
end
|
13
|
+
|
14
|
+
require 'rubocop/rake_task'
|
15
|
+
RuboCop::RakeTask.new
|
16
|
+
|
17
|
+
task default: %i[rubocop spec]
|
@@ -0,0 +1,26 @@
|
|
1
|
+
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
2
|
+
require 'google-finance/version'
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = 'google-finance-ruby-client'
|
6
|
+
s.bindir = 'bin'
|
7
|
+
s.version = GoogleFinance::VERSION
|
8
|
+
s.authors = ['Daniel Doubrovkine']
|
9
|
+
s.email = 'dblock@dblock.org'
|
10
|
+
s.platform = Gem::Platform::RUBY
|
11
|
+
s.required_rubygems_version = '>= 1.3.6'
|
12
|
+
s.files = `git ls-files`.split("\n")
|
13
|
+
s.test_files = `git ls-files -- spec/*`.split("\n")
|
14
|
+
s.require_paths = ['lib']
|
15
|
+
s.homepage = 'http://github.com/dblock/google-finance-ruby-client'
|
16
|
+
s.licenses = ['MIT']
|
17
|
+
s.summary = 'Google Finance web API ruby client.'
|
18
|
+
s.add_dependency 'faraday', '>= 0.9'
|
19
|
+
s.add_dependency 'faraday_middleware'
|
20
|
+
s.add_dependency 'hashie'
|
21
|
+
s.add_development_dependency 'rake', '~> 10'
|
22
|
+
s.add_development_dependency 'rspec'
|
23
|
+
s.add_development_dependency 'rubocop', '0.51.0'
|
24
|
+
s.add_development_dependency 'vcr'
|
25
|
+
s.add_development_dependency 'webmock'
|
26
|
+
end
|
data/google-finance.png
ADDED
Binary file
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'faraday_middleware'
|
3
|
+
require 'faraday_middleware/response_middleware'
|
4
|
+
require 'hashie'
|
5
|
+
require_relative 'google-finance/version'
|
6
|
+
require_relative 'google-finance/faraday_middleware/preprocessor'
|
7
|
+
require_relative 'google-finance/errors'
|
8
|
+
require_relative 'google-finance/resources'
|
9
|
+
require_relative 'google-finance/resource'
|
10
|
+
require_relative 'google-finance/quote'
|
11
|
+
require_relative 'google-finance/quotes'
|