tsp_scraper 0.3.1 → 0.3.2

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
  SHA1:
3
- metadata.gz: 49f6c804fc5d5e2610bcf037ccaeab27bbb3e0de
4
- data.tar.gz: 3fd8e293e0e7406e5d83242d2dbd08fd97e30e73
3
+ metadata.gz: 9435a25a43cea911351f675903a19e0fc567e16c
4
+ data.tar.gz: d536b629de412bee275c24f8ca76b8b0b48a669c
5
5
  SHA512:
6
- metadata.gz: 4cbb06c487cc7c867c60343ba3449777b0b36ffb59347bb697ef7b341023c2b2321b813d223fa3c03e4ca684ac1d24359abe9bf851ad687aff056c7544f60a99
7
- data.tar.gz: aca17f786d764989a5bbdfdc9110be85afddcfdf65f739e5f81bea30a9dbea498cf33b36bd34e858fb4d5fb92fbf00a807704dfb26c7c5ce3181ba7a98972526
6
+ metadata.gz: 30dd0e765735a8c6e49be308ee6bdca8757269b70bea54752317cd59f0d6244381b7630d0b17bee8e64cc96cc0016ef2c1bfdf3ac47f13b665b13a178605acfe
7
+ data.tar.gz: cefdbced940927ed4078e3204c427e7e61575d32a361afec32a64c2aa81aaeec99d8040dbba2ea8a7e413c3696ffefe456ce2cc23fcf70b81231be6eb01c0568
data/README.md CHANGED
@@ -12,12 +12,13 @@ gem install tsp_scraper
12
12
 
13
13
  ## Usage
14
14
 
15
- The `scrape` method returns data in an array of hashes:
15
+ The `scrape` methods accept `Date` objects as parameters and return TSP price data as an array of hashes:
16
16
 
17
17
  ```ruby
18
18
  require 'tsp_scraper'
19
19
  TSPScraper::Client.scrape() # Get trailing one month's prices
20
- TSPScraper::Client.scrape("2016-01-01", "2016-01-31") # Get January prices
20
+ TSPScraper::Client.scrape(date) # Get prices for a specific date
21
+ TSPScraper::Client.scrape(start_date, end_date) # Get January prices
21
22
  ```
22
23
 
23
24
  The returned array of hashes has the format:
@@ -51,10 +52,12 @@ The returned array of hashes has the format:
51
52
  ]
52
53
  ```
53
54
 
54
- You can get the raw CSV data as returned by the TSP website by using `TSPScraper::Client.scrape_raw()`.
55
+ You can get the raw CSV data as returned by the TSP website by using `TSPScraper::Client.scrape_raw()`, which accepts the same parameters as the `scrape` method.
56
+
57
+ ### HTTParty Options
55
58
 
56
59
  The `scrape` and `scrape_raw` methods also accept an options hash for the HTTP request. The options hash should contain [HTTParty](https://github.com/jnunemaker/httparty) options.
57
60
 
58
61
  ```ruby
59
- TSPScraper::Client.scrape("2016-01-01", "2016-01-31", verify: false) # Don't verify SSL certificate
62
+ TSPScraper::Client.scrape(start_date, end_date, verify: false) # Don't verify SSL certificate
60
63
  ```
@@ -6,6 +6,10 @@ module TSPScraper
6
6
  disable_rails_query_string_format
7
7
  base_uri "https://www.tsp.gov/InvestmentFunds/FundPerformance"
8
8
 
9
+ def self.scrape_raw(date = Date.today, options = {})
10
+ self.scrape_raw(date, date, options)
11
+ end
12
+
9
13
  def self.scrape_raw(start_date = Date.today.prev_month, end_date = Date.today, options = {})
10
14
  funds = ["Linc", "L2010", "L2020", "L2030", "L2040", "L2050", "G", "F", "C", "S", "I"]
11
15
  default_options = {
@@ -23,6 +27,10 @@ module TSPScraper
23
27
  response.body.strip
24
28
  end
25
29
 
30
+ def self.scrape(date = Date.today, options = {})
31
+ self.scrape(date, date, options)
32
+ end
33
+
26
34
  def self.scrape(start_date = Date.today.prev_month, end_date = Date.today, options = {})
27
35
  raw = self.scrape_raw(start_date, end_date, options = {})
28
36
  TSPScraper::Converter.raw_csv_to_hash(raw)
@@ -1,3 +1,3 @@
1
1
  module TSPScraper
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tsp_scraper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Fredrickson