best_companies 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b399b9bb0306d0a0e281039a274daa2814428d84204541203cc9c99e4d52b216
4
- data.tar.gz: f06d05a2e196c93d3caaf10f2a899b17bd1537fc576c5826752d9e321a19a1f3
3
+ metadata.gz: 86893b4a729518e32947f4aee037b36e4445dada6b9ff9d01a5808eec3271606
4
+ data.tar.gz: 8ce59014dc3de26fe6bb5e1eb0b5f615aceecc8fcd588a93bac7fbfe60ed0e67
5
5
  SHA512:
6
- metadata.gz: 3c8083713bfe2a61915454c24b3b3015a2a3020d3b5dd65ebcae262621ad3dedf2f337443dc9cd88aead4459c5ed2e7f010d42df5b9cb0aabfdb9b23b40fc448
7
- data.tar.gz: f0dad27447d426f41353b7c31e70a894196b0405e3f88b35c0be791cfac59933db1b52d07ee29f1c18dacce0e7c17b17015b60bc9ce9c893e4ed9eccc183dfba
6
+ metadata.gz: 1b22e5f5b70be7148e6701be32f1eeeaf3a3bda2486d52d96e91d97241d9dbc7ca767e3a66bdba774467d261cd13f791a5611aa1cd6305c630466df10534ecd1
7
+ data.tar.gz: 064dad37be1e15a37df5da0ed05e35922d99215c9d6e319fafaf3791c23428d235cafe5d0eabafb77f092b7232db1b56e0110756c0a1d1ceb150ff173d24541f
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- best_companies (0.1.2)
4
+ best_companies (0.1.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
  require_relative '../lib/best_companies.rb'
3
3
 
4
- BestCompanies::CLI.start
4
+ BestCompanies::CLI.new.call
@@ -1,4 +1,4 @@
1
- #require "best_companies/version"
1
+ require "best_companies/version"
2
2
  require 'pry'
3
3
  require 'nokogiri'
4
4
  require 'open-uri'
@@ -6,10 +6,6 @@ require 'colorize'
6
6
  require 'colorized_string'
7
7
  require 'faraday'
8
8
 
9
- module BestCompanies
10
- # Your code goes here...
11
- end
12
-
13
9
  require_relative '../lib/best_companies/concerns/findable'
14
10
  require_relative '../lib/best_companies/concerns/nameable'
15
11
  require_relative '../lib/best_companies/concerns/persistable'
@@ -18,8 +14,3 @@ require_relative '../lib/best_companies/industry'
18
14
  require_relative '../lib/best_companies/company'
19
15
  require_relative '../lib/best_companies/scraper'
20
16
  require_relative '../lib/best_companies/state'
21
-
22
-
23
- puts "loading your environment..."
24
-
25
- BestCompanies::CLI.start
@@ -1,7 +1,12 @@
1
1
  class BestCompanies::CLI
2
2
  BASE_PATH = "https://www.greatplacetowork.com/best-workplaces/100-best/"
3
+
4
+ def call
5
+ puts "loading your environment..."
6
+ start
7
+ end
3
8
 
4
- def self.start
9
+ def start
5
10
  puts "\nWelcome!".bold
6
11
  puts "Do you want to view the 2017 or 2018 Fortune list? Type the year."
7
12
  year = gets.strip
@@ -9,33 +14,33 @@ class BestCompanies::CLI
9
14
  create_list(year)
10
15
  ask_user
11
16
  else
12
- self.reject_input
13
- self.start
17
+ reject_input
18
+ start
14
19
  end
15
20
  end
16
21
 
17
- def self.switch_year(year)
22
+ def switch_year(year)
18
23
  if year == "2017"
19
24
  BestCompanies::Company.all.clear
20
25
  BestCompanies::Industry.all.clear
21
26
  BestCompanies::State.all.clear
22
- self.create_list("2017")
23
- self.ask_user
27
+ create_list("2017")
28
+ ask_user
24
29
  else
25
30
  BestCompanies::Company.all.clear
26
31
  BestCompanies::Industry.all.clear
27
32
  BestCompanies::State.all.clear
28
- self.create_list("2018")
29
- self.ask_user
33
+ create_list("2018")
34
+ ask_user
30
35
  end
31
36
  end
32
37
 
33
- def self.create_list(year)
38
+ def create_list(year)
34
39
  company_hash = BestCompanies::Scraper.scrape_companies(BASE_PATH + year, year)
35
40
  BestCompanies::Company.create_from_list(company_hash)
36
41
  end
37
42
 
38
- def self.ask_user
43
+ def ask_user
39
44
  puts "To see the entire list of Best Companies please type ".colorize(:light_blue) + "see list"
40
45
  puts "To enter in a custom range of Best Companies between 1-100, type the range in number-number format. ".colorize(:light_blue) + "For Ex: 15-20"
41
46
  puts "To view the ratings and awards for a company, enter the company rank (1-100) ".colorize(:light_blue) + "For Ex: 'rank 5'"
@@ -52,10 +57,10 @@ class BestCompanies::CLI
52
57
  BestCompanies::Company.list_all(0,99)
53
58
  when "see states"
54
59
  BestCompanies::State.list
55
- BestCompanies::State.check_input(self.get_input)
60
+ BestCompanies::State.check_input(self.class.get_input)
56
61
  when "see industries"
57
62
  BestCompanies::Industry.list
58
- BestCompanies::Industry.check_input(self.get_input)
63
+ BestCompanies::Industry.check_input(self.class.get_input)
59
64
  when "archive"
60
65
  BestCompanies::Company.archive
61
66
  when "2017"
@@ -65,7 +70,7 @@ class BestCompanies::CLI
65
70
  when "exit"
66
71
  exit
67
72
  else
68
- self.validate_input(input)
73
+ validate_input(input)
69
74
  end
70
75
 
71
76
  while input != "exit"
@@ -73,7 +78,7 @@ class BestCompanies::CLI
73
78
  end
74
79
  end
75
80
 
76
- def self.validate_input(input)
81
+ def validate_input(input)
77
82
  if input.match(/\d{1,}\-\d{1}/)
78
83
  input = input.split("-")
79
84
  num1 = (input[0].to_i)
@@ -83,28 +88,28 @@ class BestCompanies::CLI
83
88
  num2 = num2 - 1
84
89
  BestCompanies::Company.list_all(num1,num2)
85
90
  else
86
- self.reject_input
91
+ self.class.reject_input
87
92
  end
88
93
  elsif input.match(/(rank)\s\d{1,}/)
89
94
  input = input.split(" ")[1]
90
95
  if input.to_i.between?(1,100) && Faraday.get(BestCompanies::Company.all[(input.to_i)-1].review_url).status == 404
91
96
  puts "This company does not have a published review".colorize(:light_blue)
92
- self.see_company(BestCompanies::Company.all[(input.to_i)-1])
97
+ self.class.see_company(BestCompanies::Company.all[(input.to_i)-1])
93
98
  BestCompanies::Company.all[(input.to_i)-1].save?
94
99
  puts "------------------------------------------------"
95
100
  else
96
- self.add_ratings_and_awards(input)
101
+ self.class.add_ratings_and_awards(input)
97
102
  end
98
103
  elsif input.match(/[A-Za-z]/)
99
104
  if BestCompanies::State.all.detect{|state|state.name == input} != nil
100
- BestCompanies::State.all.detect{|state|state.name == input}.companies.each{|company|see_company(company)}
105
+ BestCompanies::State.all.detect{|state|state.name == input}.companies.each{|company|self.class.see_company(company)}
101
106
  elsif BestCompanies::Industry.all.detect{|industry|industry.name == input} != nil
102
- BestCompanies::Industry.all.detect{|industry|industry.name == input}.companies.each{|company|see_company(company)}
107
+ BestCompanies::Industry.all.detect{|industry|industry.name == input}.companies.each{|company|self.class.see_company(company)}
103
108
  else
104
- self.reject_input
109
+ self.class.reject_input
105
110
  end
106
111
  else
107
- self.reject_input
112
+ self.class.reject_input
108
113
  end
109
114
  end
110
115
 
@@ -124,7 +129,7 @@ class BestCompanies::CLI
124
129
  validated_input = BestCompanies::Company.all.detect{|c|c.rank == input}
125
130
  validated_input.add_ratings(BestCompanies::Scraper.scrape_ratings(validated_input.review_url))
126
131
  validated_input.add_awards(BestCompanies::Scraper.scrape_awards(validated_input.review_url))
127
- self.see_company(validated_input)
132
+ see_company(validated_input)
128
133
  BestCompanies::Company.all[(input.to_i)-1].save?
129
134
  puts "------------------------------------------------"
130
135
  end
@@ -1,3 +1,3 @@
1
1
  module BestCompanies
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: best_companies
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yosa Yon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-21 00:00:00.000000000 Z
11
+ date: 2018-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler