tsp_scraper 0.6.0 → 0.7.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/README.md +41 -1
- data/bin/tsp_scraper +2 -7
- data/lib/tsp_scraper.rb +1 -0
- data/lib/tsp_scraper/cli.rb +30 -0
- data/lib/tsp_scraper/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b69375e7e65e0d12ba96ed093c71da4101e96a43
|
4
|
+
data.tar.gz: 7a119bc38c237fdfbb0f207025a4706cb1bc554b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 91068db4e62f0a2329f8b7510adc59101b910b3ba8f588c958f49d2a3931bf7834de4fda2f14485402ce53d824fc9c121ce1a24dfd7915b05992a8078d9e08b6
|
7
|
+
data.tar.gz: 5e89d26bc0bbb0704f88fc6f95fdd0abfe168a96846efb371e39c515655878572e39824cdbcd11ef5f325a929e2273a2804810370e6beb14071b633df3085711
|
data/README.md
CHANGED
@@ -13,6 +13,10 @@ gem install tsp_scraper
|
|
13
13
|
|
14
14
|
## Usage
|
15
15
|
|
16
|
+
The `tsp_scraper` gem includes both an API and a command-line interface (CLI).
|
17
|
+
|
18
|
+
### API Usage
|
19
|
+
|
16
20
|
The `scrape` method accepts `Date` objects as parameters and returns TSP price data as an array of hashes:
|
17
21
|
|
18
22
|
```ruby
|
@@ -54,10 +58,46 @@ The returned array of hashes has the format:
|
|
54
58
|
|
55
59
|
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
60
|
|
57
|
-
|
61
|
+
#### HTTParty Options
|
58
62
|
|
59
63
|
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.
|
60
64
|
|
61
65
|
```ruby
|
62
66
|
TSPScraper::Client.scrape(start_date, end_date, verify: false) # Don't verify SSL certificate
|
63
67
|
```
|
68
|
+
|
69
|
+
### CLI Usage
|
70
|
+
|
71
|
+
Installing the gem makes the `tsp_scraper` command available to you.
|
72
|
+
|
73
|
+
```
|
74
|
+
tsp_scraper START_DATE END_DATE
|
75
|
+
```
|
76
|
+
|
77
|
+
START_DATE and END_DATE should be in the format YYYY-MM-DD.
|
78
|
+
|
79
|
+
```
|
80
|
+
$ tsp_scraper 2017-01-23 2017-01-24
|
81
|
+
2017-01-24,L Income,18.5121
|
82
|
+
2017-01-24,L 2010,0.0
|
83
|
+
2017-01-24,L 2020,24.7183
|
84
|
+
2017-01-24,L 2030,27.2166
|
85
|
+
2017-01-24,L 2040,29.1416
|
86
|
+
2017-01-24,L 2050,16.6275
|
87
|
+
2017-01-24,G Fund,15.2106
|
88
|
+
2017-01-24,F Fund,17.4619
|
89
|
+
2017-01-24,C Fund,31.4713
|
90
|
+
2017-01-24,S Fund,42.0024
|
91
|
+
2017-01-24,I Fund,25.2087
|
92
|
+
2017-01-23,L Income,18.4934
|
93
|
+
2017-01-23,L 2010,0.0
|
94
|
+
2017-01-23,L 2020,24.6629
|
95
|
+
2017-01-23,L 2030,27.12
|
96
|
+
2017-01-23,L 2040,29.0183
|
97
|
+
2017-01-23,L 2050,16.5456
|
98
|
+
2017-01-23,G Fund,15.2096
|
99
|
+
2017-01-23,F Fund,17.5237
|
100
|
+
2017-01-23,C Fund,31.2661
|
101
|
+
2017-01-23,S Fund,41.434
|
102
|
+
2017-01-23,I Fund,25.1846
|
103
|
+
```
|
data/bin/tsp_scraper
CHANGED
data/lib/tsp_scraper.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
module TSPScraper
|
2
|
+
class CLI
|
3
|
+
def self.start
|
4
|
+
begin
|
5
|
+
end_date_raw = ARGV.pop
|
6
|
+
start_date_raw = ARGV.pop
|
7
|
+
start_date = Date.parse(start_date_raw)
|
8
|
+
end_date = Date.parse(end_date_raw)
|
9
|
+
rescue
|
10
|
+
print_help
|
11
|
+
exit 1
|
12
|
+
end
|
13
|
+
quotes = TSPScraper::Client.scrape(start_date, end_date)
|
14
|
+
print_quotes quotes
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.print_help
|
18
|
+
puts "Usage: tsp_scraper START_DATE END_DATE"
|
19
|
+
puts "START_DATE and END_DATE should be in the format YYYY-MM-DD."
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.print_quotes(quotes)
|
23
|
+
quotes.each do |quote|
|
24
|
+
quote[:funds].each do |name, price|
|
25
|
+
puts "#{quote[:date]},#{name},#{price.to_s('F')}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/tsp_scraper/version.rb
CHANGED
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.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Fredrickson
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- bin/setup
|
99
99
|
- bin/tsp_scraper
|
100
100
|
- lib/tsp_scraper.rb
|
101
|
+
- lib/tsp_scraper/cli.rb
|
101
102
|
- lib/tsp_scraper/client.rb
|
102
103
|
- lib/tsp_scraper/converter.rb
|
103
104
|
- lib/tsp_scraper/version.rb
|