tsp_scraper 0.1.0 → 0.2.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 +4 -4
- data/.gitignore +4 -4
- data/Gemfile +3 -3
- data/LICENSE +21 -21
- data/README.md +25 -3
- data/bin/console +3 -3
- data/bin/tsp_scraper +10 -10
- data/lib/tsp_scraper/client.rb +26 -24
- data/lib/tsp_scraper/version.rb +3 -3
- data/lib/tsp_scraper.rb +2 -2
- data/tsp_scraper.gemspec +20 -20
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 75f11917c9778038cc5e3006a0e211bdf1277544
|
4
|
+
data.tar.gz: fe3d69b27f7b84296855e55b209e62dd16ccd86d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 312dff98fa87d7ddb55a3f7f8712649325b600a506f74cf6b16a25b9449541de5854cf7e5509def054b8320a82961929a735a66a889fcfd7cd3f7ba062444dd6
|
7
|
+
data.tar.gz: f5a39e561daa2bf857f9a400ffaa82d2a4509b2570beb95efd64f7a92b301d22b6cfa7743ba806a57d6671c2b0a0e1506dd17aca1ee5ec0cc144a1401ee5cc74
|
data/.gitignore
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
*.gem
|
2
|
-
.env
|
3
|
-
.DS_Store
|
4
|
-
Gemfile.lock
|
1
|
+
*.gem
|
2
|
+
.env
|
3
|
+
.DS_Store
|
4
|
+
Gemfile.lock
|
data/Gemfile
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
source "https://rubygems.org"
|
2
|
-
|
3
|
-
gemspec
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
gemspec
|
data/LICENSE
CHANGED
@@ -1,21 +1,21 @@
|
|
1
|
-
The MIT License (MIT)
|
2
|
-
|
3
|
-
Copyright (c) 2015 Jeff Fredrickson
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
7
|
-
in the Software without restriction, including without limitation the rights
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
10
|
-
furnished to do so, subject to the following conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
13
|
-
copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
SOFTWARE.
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Jeff Fredrickson
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -1,3 +1,25 @@
|
|
1
|
-
# tsp_scraper
|
2
|
-
|
3
|
-
Scrapes fund price history from the TSP.gov website.
|
1
|
+
# tsp_scraper
|
2
|
+
|
3
|
+
Scrapes fund price history from the TSP.gov website.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```sh
|
8
|
+
gem install tsp_scraper
|
9
|
+
```
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
The `scrape` method returns CSV data:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
require 'tsp_scraper'
|
17
|
+
TSPScraper::Client.scrape() # Get trailing one month's prices
|
18
|
+
TSPScraper::Client.scrape("2016-01-01", "2016-01-31") # Get January prices
|
19
|
+
```
|
20
|
+
|
21
|
+
The `scrape` method also accepts an options hash for the HTTP request. The options hash should contain [HTTParty](https://github.com/jnunemaker/httparty) options.
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
TSPScraper::Client.scrape("2016-01-01", "2016-01-31", verify: false) # Don't verify SSL certificate
|
25
|
+
```
|
data/bin/console
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
#!/usr/bin/env sh
|
2
|
-
|
3
|
-
irb -Ilib -rtsp_scraper
|
1
|
+
#!/usr/bin/env sh
|
2
|
+
|
3
|
+
irb -Ilib -rtsp_scraper
|
data/bin/tsp_scraper
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require 'tsp_scraper'
|
4
|
-
require 'date'
|
5
|
-
|
6
|
-
start_date = Date.parse(ARGV[0])
|
7
|
-
end_date = Date.parse(ARGV[1])
|
8
|
-
|
9
|
-
csv = TSPScraper::Client.scrape(start_date, end_date)
|
10
|
-
puts csv
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'tsp_scraper'
|
4
|
+
require 'date'
|
5
|
+
|
6
|
+
start_date = Date.parse(ARGV[0])
|
7
|
+
end_date = Date.parse(ARGV[1])
|
8
|
+
|
9
|
+
csv = TSPScraper::Client.scrape(start_date, end_date)
|
10
|
+
puts csv
|
data/lib/tsp_scraper/client.rb
CHANGED
@@ -1,24 +1,26 @@
|
|
1
|
-
require 'httparty'
|
2
|
-
|
3
|
-
module TSPScraper
|
4
|
-
class Client
|
5
|
-
include HTTParty
|
6
|
-
disable_rails_query_string_format
|
7
|
-
base_uri "https://www.tsp.gov/InvestmentFunds/FundPerformance"
|
8
|
-
|
9
|
-
def self.scrape(start_date = Date.today.prev_month, end_date = Date.today)
|
10
|
-
funds = ["Linc", "L2010", "L2020", "L2030", "L2040", "L2050", "G", "F", "C", "S", "I"]
|
11
|
-
|
12
|
-
query: {
|
13
|
-
reloaded: 1,
|
14
|
-
startdate: start_date.strftime("%m/%d/%Y"),
|
15
|
-
enddate: end_date.strftime("%m/%d/%Y"),
|
16
|
-
whichButton: "CSV",
|
17
|
-
fundgroup: funds
|
18
|
-
}
|
19
|
-
}
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
1
|
+
require 'httparty'
|
2
|
+
|
3
|
+
module TSPScraper
|
4
|
+
class Client
|
5
|
+
include HTTParty
|
6
|
+
disable_rails_query_string_format
|
7
|
+
base_uri "https://www.tsp.gov/InvestmentFunds/FundPerformance"
|
8
|
+
|
9
|
+
def self.scrape(start_date = Date.today.prev_month, end_date = Date.today, options = {})
|
10
|
+
funds = ["Linc", "L2010", "L2020", "L2030", "L2040", "L2050", "G", "F", "C", "S", "I"]
|
11
|
+
default_options = {
|
12
|
+
query: {
|
13
|
+
reloaded: 1,
|
14
|
+
startdate: start_date.strftime("%m/%d/%Y"),
|
15
|
+
enddate: end_date.strftime("%m/%d/%Y"),
|
16
|
+
whichButton: "CSV",
|
17
|
+
fundgroup: funds
|
18
|
+
}
|
19
|
+
}
|
20
|
+
options = default_options.merge(options)
|
21
|
+
|
22
|
+
response = self.get("/index.html", options)
|
23
|
+
csv = response.body.strip
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/tsp_scraper/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module TSPScraper
|
2
|
-
VERSION = "0.
|
3
|
-
end
|
1
|
+
module TSPScraper
|
2
|
+
VERSION = "0.2.0"
|
3
|
+
end
|
data/lib/tsp_scraper.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require 'tsp_scraper/version'
|
2
|
-
require 'tsp_scraper/client'
|
1
|
+
require 'tsp_scraper/version'
|
2
|
+
require 'tsp_scraper/client'
|
data/tsp_scraper.gemspec
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
lib = File.expand_path('../lib', __FILE__)
|
2
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
-
require 'tsp_scraper/version'
|
4
|
-
|
5
|
-
Gem::Specification.new do |s|
|
6
|
-
s.name = 'tsp_scraper'
|
7
|
-
s.summary = 'Scrapes fund price history from the TSP.gov website'
|
8
|
-
s.description = 'Scrapes fund price history from the TSP.gov website.'
|
9
|
-
s.homepage = 'https://github.com/jfredrickson/tsp_scraper'
|
10
|
-
s.version = TSPScraper::VERSION
|
11
|
-
s.authors = ['Jeff Fredrickson']
|
12
|
-
s.email = %w(jeff.fredrickson@gmail.com)
|
13
|
-
s.files = `git ls-files -z`.split("\x0")
|
14
|
-
s.require_paths = ['lib']
|
15
|
-
s.license = 'MIT'
|
16
|
-
s.required_ruby_version = '>= 1.9.3'
|
17
|
-
s.executables = ['tsp_scraper']
|
18
|
-
|
19
|
-
s.add_runtime_dependency 'httparty', '~> 0.13'
|
20
|
-
end
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'tsp_scraper/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = 'tsp_scraper'
|
7
|
+
s.summary = 'Scrapes fund price history from the TSP.gov website'
|
8
|
+
s.description = 'Scrapes fund price history from the TSP.gov website.'
|
9
|
+
s.homepage = 'https://github.com/jfredrickson/tsp_scraper'
|
10
|
+
s.version = TSPScraper::VERSION
|
11
|
+
s.authors = ['Jeff Fredrickson']
|
12
|
+
s.email = %w(jeff.fredrickson@gmail.com)
|
13
|
+
s.files = `git ls-files -z`.split("\x0")
|
14
|
+
s.require_paths = ['lib']
|
15
|
+
s.license = 'MIT'
|
16
|
+
s.required_ruby_version = '>= 1.9.3'
|
17
|
+
s.executables = ['tsp_scraper']
|
18
|
+
|
19
|
+
s.add_runtime_dependency 'httparty', '~> 0.13'
|
20
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tsp_scraper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Fredrickson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-03-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -62,9 +62,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
62
62
|
version: '0'
|
63
63
|
requirements: []
|
64
64
|
rubyforge_project:
|
65
|
-
rubygems_version: 2.5
|
65
|
+
rubygems_version: 2.2.5
|
66
66
|
signing_key:
|
67
67
|
specification_version: 4
|
68
68
|
summary: Scrapes fund price history from the TSP.gov website
|
69
69
|
test_files: []
|
70
|
-
has_rdoc:
|