tsp_scraper 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 8dcb08a62c8c7ec079c79b626f3dd3c5abeb08d3
4
+ data.tar.gz: 769dfb4c2b13fbe082270131f7e66b09a2b33300
5
+ SHA512:
6
+ metadata.gz: 8582400a77033d9498d900a0cb42f2c95556a82f7a8c40e36546aaaee0caf35a217f5bde20102e504ac77e8b743f837425dd3f596f9aba720036b65ed2c7f453
7
+ data.tar.gz: 12fd735a93202d3292a2a036d06f29c8e37872ee218dca26d423927029d98397c948fa7ff622ce36c9c86c7789a0fa3e3330adbcd24081990fd8bfe53c6695c5
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .env
3
+ .DS_Store
4
+ Gemfile.lock
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +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.
data/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # tsp_scraper
2
+
3
+ Scrapes fund price history from the TSP.gov website.
data/bin/console ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env sh
2
+
3
+ irb -Ilib -rtsp_scraper
data/bin/tsp_scraper ADDED
@@ -0,0 +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
@@ -0,0 +1,24 @@
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
+ 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
+ response = self.get("/index.html", options)
21
+ csv = response.body.strip
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,3 @@
1
+ module TSPScraper
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,2 @@
1
+ require 'tsp_scraper/version'
2
+ require 'tsp_scraper/client'
@@ -0,0 +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
metadata ADDED
@@ -0,0 +1,70 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tsp_scraper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jeff Fredrickson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.13'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.13'
27
+ description: Scrapes fund price history from the TSP.gov website.
28
+ email:
29
+ - jeff.fredrickson@gmail.com
30
+ executables:
31
+ - tsp_scraper
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - ".gitignore"
36
+ - Gemfile
37
+ - LICENSE
38
+ - README.md
39
+ - bin/console
40
+ - bin/tsp_scraper
41
+ - lib/tsp_scraper.rb
42
+ - lib/tsp_scraper/client.rb
43
+ - lib/tsp_scraper/version.rb
44
+ - tsp_scraper.gemspec
45
+ homepage: https://github.com/jfredrickson/tsp_scraper
46
+ licenses:
47
+ - MIT
48
+ metadata: {}
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: 1.9.3
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ requirements: []
64
+ rubyforge_project:
65
+ rubygems_version: 2.5.0
66
+ signing_key:
67
+ specification_version: 4
68
+ summary: Scrapes fund price history from the TSP.gov website
69
+ test_files: []
70
+ has_rdoc: