inc_5000_list_scraper 0.0.1 → 0.0.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
  SHA256:
3
- metadata.gz: 18de481d21982c8806dd96bce6d1d5498802f14179ef6a6334ea0283ecac2c15
4
- data.tar.gz: 990403c184348af191bfa8206c1064b21f13966968aa165a11de371223ec2127
3
+ metadata.gz: a1fdabaa64a2333f6504d053c4b023ecb4d20de2b0e510cd85a47c2ce9fb4644
4
+ data.tar.gz: 2a18dbf526443ddf96512e37566777384560eddfac878a589e84cd2a01d829a1
5
5
  SHA512:
6
- metadata.gz: 82266d0726122752e25060a7829330e270fb924da96dba53aea17e4916b1c9b1a2129875881c3ee36efca3156e4e4f4434561d66f47cfa6de2048c1bfc94323e
7
- data.tar.gz: 90a92f01b377ed88e7dfd70d9042938dc78e89f08e639f468f9dc6018794e967337c8f5ed21677f9de1b084873c045cc2db7f5daa23a94d64443df310b184903
6
+ metadata.gz: a395975a49afc72336caa9efb9bcc424d839b4eec3b1618d2adbe64c32c506863d275da337a97bee244bb6f8bbd7bf15fb30ab00b4548ef5fb84e84345fbdf62
7
+ data.tar.gz: 410e1de2d4b2f5ca41d45df423034b66f43894e0665178a415784bc7321371d4424810eb45769e998d42a97e8da0c130353f951883eac5b034b8c8f15df06667
@@ -0,0 +1,41 @@
1
+ module Inc5000List
2
+ class Scraper
3
+ INC_LIST_REST_URI = 'https://www.inc.com/rest/i5list/2020'.freeze
4
+
5
+ def self.create_csv!
6
+ new.scrape!
7
+ end
8
+
9
+ def scrape!
10
+ CSV.open('inc_5000_list.csv', 'wb') do |out|
11
+ out << company_row(companies.first).keys
12
+
13
+ companies.each do |company|
14
+ out << company_row(company).values
15
+ end
16
+ end
17
+ end
18
+
19
+ def list_as_text
20
+ OpenURI.open_uri(INC_LIST_REST_URI).read
21
+ end
22
+
23
+ def list_as_json
24
+ @list_as_json ||= JSON.parse(list_as_text)
25
+ end
26
+
27
+ def companies
28
+ @companies ||= list_as_json['companies'].map { |c| OpenStruct.new(c) }
29
+ end
30
+
31
+ def company_row(company)
32
+ {
33
+ rank: company.rank,
34
+ company_name: company.company,
35
+ city: company.city,
36
+ state: company.state_s,
37
+ website: company.website
38
+ }
39
+ end
40
+ end
41
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inc_5000_list_scraper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Thompson
@@ -16,7 +16,7 @@ executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
- - lib/inc5000_scraper.rb
19
+ - lib/inc_5000_list_scraper.rb
20
20
  homepage: https://github.com/SnowboardTechie/inc_5000_list_scraper_gem
21
21
  licenses: []
22
22
  metadata:
@@ -1,39 +0,0 @@
1
- module Inc5000Scraper
2
- INC_LIST_REST_URI = 'https://www.inc.com/rest/i5list/2020'.freeze
3
-
4
- def self.scrape!
5
- new.scrape!
6
- end
7
-
8
- def scrape!
9
- CSV.open('inc_5000_list.csv', 'wb') do |out|
10
- out << company_row(companies.first).keys
11
-
12
- companies.each do |company|
13
- out << company_row(company).values
14
- end
15
- end
16
- end
17
-
18
- def list_as_text
19
- OpenURI.open_uri(INC_LIST_REST_URI).read
20
- end
21
-
22
- def list_as_json
23
- @list_as_json ||= JSON.parse(list_as_text)
24
- end
25
-
26
- def companies
27
- @companies ||= list_as_json['companies'].map { |c| OpenStruct.new(c) }
28
- end
29
-
30
- def company_row(company)
31
- {
32
- rank: company.rank,
33
- company_name: company.company,
34
- city: company.city,
35
- state: company.state_s,
36
- website: company.website
37
- }
38
- end
39
- end