inc_5000_list_scraper 0.0.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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/inc5000_scraper.rb +39 -0
  3. metadata +43 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4bba7b0b04536da496d4b51121c027b75a0424c0639dd627493879a7aec55383
4
+ data.tar.gz: 0215d5e5a76505b0b1dc5e2f7bed727317ca3134e2be1f8ecdaabc050fa7dbc5
5
+ SHA512:
6
+ metadata.gz: 9a481a1d6eccedc518bd31e94a0f46ec5ca173afc6ba1f0a3d752ca4ea97d3ce22f97fb4f196d6b93b4c92185ca6e4f5211ce588cb1f4fbf1640aeea36b23a3c
7
+ data.tar.gz: 280022a63381be47f98e07e9c04da0a71b36ab758e5979b1be143043286beec57709ea8ba4c95252412fb296a64aebf914b78af2cfcfdf8d93afd2e6e20985c5
@@ -0,0 +1,39 @@
1
+ class 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
metadata ADDED
@@ -0,0 +1,43 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: inc_5000_list_scraper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Bryan Thompson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2020-08-12 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email: Bryan@Thompson.codes
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/inc5000_scraper.rb
20
+ homepage:
21
+ licenses: []
22
+ metadata: {}
23
+ post_install_message:
24
+ rdoc_options: []
25
+ require_paths:
26
+ - lib
27
+ required_ruby_version: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: '0'
32
+ required_rubygems_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ requirements: []
38
+ rubygems_version: 3.0.8
39
+ signing_key:
40
+ specification_version: 4
41
+ summary: inc_5000_list_scraper scrapes the 2020 Inc 5000 list and outputs a csv of
42
+ the list
43
+ test_files: []