tsp_scraper 0.8.0 → 0.9.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e3fdf116c523aefb82e8d38f43a60b9b2e7e85c46da74e5a05d4f0070353edb9
4
- data.tar.gz: 6dbda0c5d9a5172b18c58bc743675977802eaeb6c207468bc195b99de557ab9c
3
+ metadata.gz: 06f326a47003377a09a52f6a6943355119373cfd73740f645a7e91f7f4583a91
4
+ data.tar.gz: 0e8f2a09436a87940f7b7fc66b7243d8c4c0b28e88b32e72ebf984b283c28237
5
5
  SHA512:
6
- metadata.gz: e4de9026afd500e4d1f4c9ddbd2243998fd5e3ae85fc0196e5df92a479d83ea624b066fae944f8e7d8c01cb54d0d7cad3bf8350759a0229163984c85ef74ac41
7
- data.tar.gz: fa3d6219627bba8b6f40591354df177ec79c4e28e9a7cabac0551fb87214417e805da6111dc4c4b32749bffcd3b722a16d661b2bc7f64029934811747fcafa1d
6
+ metadata.gz: 397fa873097f209732982fcdf156b2062e240aaf71ea53470861fca6e6a56715aa2b257099b825a1aa28438fa3206ab4fb775ad81b74eadbe136271dabc12540
7
+ data.tar.gz: 342ccc4844395e03c838d88fdcc79bf1bbe139406228cb7304738e720f9311cc6f7edd47e1915d16a8a4e32f3a78f806be6cd7a66881ec484858d99ade698805
@@ -4,22 +4,21 @@ module TSPScraper
4
4
  class Client
5
5
  include HTTParty
6
6
  disable_rails_query_string_format
7
- base_uri "https://www.tsp.gov/InvestmentFunds/FundPerformance"
7
+ base_uri "https://secure.tsp.gov/components/CORS"
8
8
 
9
9
  def self.scrape_raw(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
10
  default_options = {
12
11
  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
12
+ download: 1,
13
+ startdate: start_date.strftime("%Y%m%d"),
14
+ enddate: end_date.strftime("%Y%m%d"),
15
+ format: "CSV",
16
+ Lfunds: 1,
17
+ InvFunds: 1
18
18
  }
19
19
  }
20
20
  options = default_options.merge(options)
21
-
22
- response = self.get("/index.html", options)
21
+ response = self.get("/getSharePrices.html", options)
23
22
  response.body.strip
24
23
  end
25
24
 
@@ -2,11 +2,10 @@ module TSPScraper
2
2
  class Converter
3
3
  # TSP CSV has a janky format:
4
4
  # - Each field in a row, except for the first field, is prepended by a space
5
- # - Each row has a final column containing just a space
6
5
  # For this reason, we manually clean up the CSV instead of using the Ruby CSV library, especially since we know TSP
7
6
  # does not use quotation marks in their CSV fields... at least for now.
8
7
  def self.raw_csv_to_hash(raw_csv)
9
- raw_data = raw_csv.lines.map { |row| row.strip.chomp(',').split(',').map { |field| field.strip } }
8
+ raw_data = raw_csv.lines.map { |row| row.strip.split(',').map { |field| field.strip } }
10
9
  headers = raw_data.shift
11
10
  data = []
12
11
  raw_data.each do |d|
@@ -16,12 +15,7 @@ module TSPScraper
16
15
  }
17
16
  headers.each_with_index do |header, index|
18
17
  next if index == 0
19
- if d[index].empty?
20
- value = nil
21
- else
22
- value = BigDecimal(d[index])
23
- end
24
- hash[:funds][header] = value
18
+ hash[:funds][header] = BigDecimal(d[index]) unless d[index].empty?
25
19
  end
26
20
  data.push(hash)
27
21
  end
@@ -1,3 +1,3 @@
1
1
  module TSPScraper
2
- VERSION = "0.8.0"
2
+ VERSION = "0.9.0"
3
3
  end
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.executables = ['tsp_scraper']
18
18
 
19
19
  s.add_runtime_dependency 'httparty', '~> 0.17.1'
20
- s.add_development_dependency 'bundler', '~> 2.0.2'
20
+ s.add_development_dependency 'bundler', '~> 2.1.4'
21
21
  s.add_development_dependency 'rake', '~> 13.0.0'
22
22
  s.add_development_dependency 'pry', '~> 0.12.2'
23
23
  s.add_development_dependency 'minitest', '~> 5.12.2'
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.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Fredrickson
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-15 00:00:00.000000000 Z
11
+ date: 2020-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.0.2
33
+ version: 2.1.4
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 2.0.2
40
+ version: 2.1.4
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -107,7 +107,7 @@ homepage: https://github.com/jfredrickson/tsp_scraper
107
107
  licenses:
108
108
  - MIT
109
109
  metadata: {}
110
- post_install_message:
110
+ post_install_message:
111
111
  rdoc_options: []
112
112
  require_paths:
113
113
  - lib
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  version: '0'
124
124
  requirements: []
125
125
  rubygems_version: 3.0.3
126
- signing_key:
126
+ signing_key:
127
127
  specification_version: 4
128
128
  summary: Scrapes fund price history from the TSP.gov website
129
129
  test_files: []