career_profiles 0.1.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 +7 -0
- data/lib/career_profiles.rb +12 -0
- data/lib/career_profiles/career_interest.rb +30 -0
- data/lib/career_profiles/cli.rb +105 -0
- data/lib/career_profiles/occupation.rb +47 -0
- data/lib/career_profiles/scraper.rb +72 -0
- metadata +118 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 49bfaceb32231078d69a663733b47361f42a45327fc487874cb350e41e5fa695
|
|
4
|
+
data.tar.gz: 7cf7c22e08aebba0c5e1f93d4d37faf3479c3611bfa387813c637d944dd776aa
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 3da8a2ef62fbba1be237b240c6fbea80edf94271555ea6a42aeb4bb8f19b344fdbbff12df37ae2f20fa83ced679b3b5aabbcb97e23b935199cdda0bc93c60a05
|
|
7
|
+
data.tar.gz: 2ac04d897bd85afacf2d5cb9447dbd500f94f1ce52ab99469f4420fd7a83f8c4d8bba66d1fe80af0af768abe949447ae6a67fdca9037385ad45593c404a035d1
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module CareerProfiles
|
|
2
|
+
end
|
|
3
|
+
|
|
4
|
+
require 'pry'
|
|
5
|
+
require 'nokogiri'
|
|
6
|
+
require 'open-uri'
|
|
7
|
+
|
|
8
|
+
require_relative '../lib/career_profiles/scraper'
|
|
9
|
+
require_relative '../lib/career_profiles/career_interest'
|
|
10
|
+
require_relative '../lib/career_profiles/occupation'
|
|
11
|
+
require_relative '../lib/career_profiles/cli'
|
|
12
|
+
require_relative '../lib/career_profiles/version'
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require 'pry'
|
|
2
|
+
class CareerProfiles::CareerInterest
|
|
3
|
+
attr_accessor :name, :occupations
|
|
4
|
+
@@all = []
|
|
5
|
+
|
|
6
|
+
def initialize(career_interest_hash)
|
|
7
|
+
career_interest_hash.each {|key, value| self.send(("#{key}="), value)}
|
|
8
|
+
@@all << self
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def self.new_from_collection(career_interest_array)
|
|
12
|
+
career_interest_array.each {|career_interest_hash| self.new(career_interest_hash)}
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.all
|
|
16
|
+
@@all
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def add_occupations(occupation_hash)
|
|
20
|
+
occupation = CareerProfiles::Occupation.new_from_collection(occupation_hash)
|
|
21
|
+
@occupations = occupation
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def list_occupations
|
|
25
|
+
puts ""
|
|
26
|
+
@occupations.each.with_index(1) do |occupation, i|
|
|
27
|
+
puts "#{i}. #{occupation.name}"
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
require 'pry'
|
|
2
|
+
class CareerProfiles::CLI
|
|
3
|
+
def run
|
|
4
|
+
puts "Loading data..."
|
|
5
|
+
make_career_interests
|
|
6
|
+
add_occupations_to_career_interests
|
|
7
|
+
add_attributes_to_occupations
|
|
8
|
+
@input = []
|
|
9
|
+
start
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def start
|
|
13
|
+
career_interest
|
|
14
|
+
occupation
|
|
15
|
+
options
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def make_career_interests
|
|
19
|
+
career_interest_array ||= CareerProfiles::Scraper.scrape_career_interests
|
|
20
|
+
CareerProfiles::CareerInterest.new_from_collection(career_interest_array)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def add_occupations_to_career_interests
|
|
24
|
+
CareerProfiles::CareerInterest.all.each.with_index do |career_interest, i|
|
|
25
|
+
occupation_hash ||= CareerProfiles::Scraper.scrape_occupations(i)
|
|
26
|
+
career_interest.add_occupations(occupation_hash)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def add_attributes_to_occupations
|
|
31
|
+
CareerProfiles::Occupation.all.each do |occupation|
|
|
32
|
+
attributes_hash = CareerProfiles::Scraper.scrape_occupation_attributes(occupation.url)
|
|
33
|
+
occupation.add_attributes(attributes_hash)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def list_career_interests
|
|
38
|
+
puts "Welcome to Occupation Profiles by Career Interests"
|
|
39
|
+
@career_interests = CareerProfiles::CareerInterest.all
|
|
40
|
+
@career_interests.each.with_index(1) do |career_interest, i|
|
|
41
|
+
puts "#{i}. #{career_interest.name}"
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def career_interest
|
|
46
|
+
list_career_interests
|
|
47
|
+
puts ""
|
|
48
|
+
puts "Enter the number of the career interest you'd like to see occupations on or type exit:"
|
|
49
|
+
@input << gets.strip
|
|
50
|
+
if @input.last.to_i > 0 && @input.last.to_i <= @career_interests.length.to_i
|
|
51
|
+
@career_interests[@input.last.to_i-1].list_occupations
|
|
52
|
+
elsif @input.last.downcase == "exit"
|
|
53
|
+
goodbye
|
|
54
|
+
exit
|
|
55
|
+
else
|
|
56
|
+
puts ""
|
|
57
|
+
puts "Not sure what you want."
|
|
58
|
+
puts ""
|
|
59
|
+
career_interest
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def occupation
|
|
64
|
+
puts ""
|
|
65
|
+
puts "Enter the number of the occupation you'd like to see, type back to see the career interest list again or type exit:"
|
|
66
|
+
@input << gets.strip.downcase
|
|
67
|
+
i = @input[(@input.length)-2]
|
|
68
|
+
occupations = @career_interests[i.to_i-1].occupations
|
|
69
|
+
if @input.last.to_i > 0 && @input.last.to_i <= occupations.length.to_i
|
|
70
|
+
occupations[@input.last.to_i-1].display_occupation
|
|
71
|
+
elsif @input.last.downcase == "back"
|
|
72
|
+
start
|
|
73
|
+
elsif @input.last.downcase == "exit"
|
|
74
|
+
goodbye
|
|
75
|
+
exit
|
|
76
|
+
else
|
|
77
|
+
puts ""
|
|
78
|
+
puts "Not sure what you want."
|
|
79
|
+
@input.pop
|
|
80
|
+
@career_interests[@input.last.to_i-1].list_occupations
|
|
81
|
+
occupation
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def options
|
|
86
|
+
puts ""
|
|
87
|
+
puts "Would you like to explore more occupations? Type Y or N:"
|
|
88
|
+
input = gets.strip
|
|
89
|
+
if input == "Y" || input == "y"
|
|
90
|
+
start
|
|
91
|
+
elsif input == "N" || input == "n"
|
|
92
|
+
goodbye
|
|
93
|
+
exit
|
|
94
|
+
else
|
|
95
|
+
puts ""
|
|
96
|
+
puts "Not sure what you want."
|
|
97
|
+
puts ""
|
|
98
|
+
options
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def goodbye
|
|
103
|
+
puts "See you later to explore more occupations!"
|
|
104
|
+
end
|
|
105
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
class CareerProfiles::Occupation
|
|
2
|
+
attr_accessor :name, :url, :median_pay_2017,:education,:outlook_2016_26, :key_responsibilities
|
|
3
|
+
@@all = []
|
|
4
|
+
|
|
5
|
+
def self.all
|
|
6
|
+
@@all
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def initialize(occupation_hash)
|
|
10
|
+
occupation_hash.each {|key, value| self.send(("#{key}="), value)}
|
|
11
|
+
@@all << self
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def self.new_from_collection(occupation_array)
|
|
15
|
+
occupations= []
|
|
16
|
+
occupation_array.each{|occupation_hash| occupations << self.new(occupation_hash)}
|
|
17
|
+
occupations
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def add_attributes(attributes_hash)
|
|
21
|
+
attributes_hash.each {|key, value| self.send(("#{key}="), value)}
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def display_occupation
|
|
25
|
+
puts " "
|
|
26
|
+
puts "NAME: #{self.name}"
|
|
27
|
+
puts "------------------------"
|
|
28
|
+
puts " "
|
|
29
|
+
puts "KEY RESPONSIBILITIES"
|
|
30
|
+
puts "----------------------"
|
|
31
|
+
puts "#{self.key_responsibilities}"
|
|
32
|
+
puts " "
|
|
33
|
+
puts "EDUCATION REQUIRED"
|
|
34
|
+
puts "----------------------"
|
|
35
|
+
puts "#{self.education}"
|
|
36
|
+
puts " "
|
|
37
|
+
puts "JOB OUTLOOK 2016-2026"
|
|
38
|
+
puts "----------------------"
|
|
39
|
+
puts "#{self.outlook_2016_26}"
|
|
40
|
+
puts " "
|
|
41
|
+
puts "2017 MEDIAN PAY"
|
|
42
|
+
puts "----------------------"
|
|
43
|
+
puts "#{self.median_pay_2017}"
|
|
44
|
+
puts ""
|
|
45
|
+
puts "For more information and video click here: #{self.url}"
|
|
46
|
+
end
|
|
47
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
require'pry'
|
|
2
|
+
class CareerProfiles::Scraper
|
|
3
|
+
def self.get_page
|
|
4
|
+
Nokogiri::HTML(open("https://www.bls.gov/k12/content/students/careers/career-exploration.htm"))
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def self.scrape_career_interests
|
|
8
|
+
list = []
|
|
9
|
+
names_index = get_page.css("div.careerCol p.careerList")
|
|
10
|
+
names_index.each do |c|
|
|
11
|
+
list << c.text
|
|
12
|
+
end
|
|
13
|
+
names = []
|
|
14
|
+
list.each do |c|
|
|
15
|
+
names << c.gsub("[+] Show", "")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
career_interests = []
|
|
20
|
+
names.each {|name| career_interests << {:name => name}}
|
|
21
|
+
career_interests
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def self.scrape_occupations(i)
|
|
25
|
+
names = []
|
|
26
|
+
career_interest_index = get_page.css("div.careerNames ul")[i].css("a")
|
|
27
|
+
career_interest_index.each do |o|
|
|
28
|
+
names << o.text
|
|
29
|
+
end
|
|
30
|
+
names.delete_if {|x| x == "Designer"}
|
|
31
|
+
|
|
32
|
+
urls = []
|
|
33
|
+
career_interest_index.each do |o|
|
|
34
|
+
urls << o.attribute("href").text
|
|
35
|
+
end
|
|
36
|
+
urls.delete_if {|x| x == "https://www.bls.gov/ooh/arts-and-design/home.htm"}
|
|
37
|
+
|
|
38
|
+
occupations = []
|
|
39
|
+
names.each {|name| occupations << {:name => name}}
|
|
40
|
+
u = 0
|
|
41
|
+
urls.each {|url| occupations[u][:url] = url; u += 1}
|
|
42
|
+
occupations
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def self.get_occupation_page(link)
|
|
46
|
+
Nokogiri::HTML(open(link))
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def self.scrape_occupation_attributes(link)
|
|
50
|
+
index = get_occupation_page(link).css("table#quickfacts tbody tr")
|
|
51
|
+
pay_index = index[0]
|
|
52
|
+
med_pay = pay_index.css("td").text.strip
|
|
53
|
+
med_pay = med_pay.gsub("\n", ' ').squeeze(' ')
|
|
54
|
+
|
|
55
|
+
education_index = index[1]
|
|
56
|
+
education = education_index.css("td").text.strip
|
|
57
|
+
|
|
58
|
+
outlook_index = index[5]
|
|
59
|
+
outlook_2016_26 = outlook_index.css("td").text.strip
|
|
60
|
+
|
|
61
|
+
role_index = get_occupation_page(link).css("article")
|
|
62
|
+
role = role_index.css("p")[1].text
|
|
63
|
+
|
|
64
|
+
occupation_attributes = {
|
|
65
|
+
:median_pay_2017 => med_pay,
|
|
66
|
+
:education => education,
|
|
67
|
+
:outlook_2016_26 => outlook_2016_26,
|
|
68
|
+
:key_responsibilities => role,
|
|
69
|
+
}
|
|
70
|
+
occupation_attributes
|
|
71
|
+
end
|
|
72
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: career_profiles
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- "'Angelica Sanchez'"
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2019-01-29 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '2.0'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '2.0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: nokogiri
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '0'
|
|
62
|
+
type: :development
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: pry
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
83
|
+
description: Provides details on occupations by career interests.
|
|
84
|
+
email:
|
|
85
|
+
- "'anlsanchez@ucdavis.edu'"
|
|
86
|
+
executables: []
|
|
87
|
+
extensions: []
|
|
88
|
+
extra_rdoc_files: []
|
|
89
|
+
files:
|
|
90
|
+
- lib/career_profiles.rb
|
|
91
|
+
- lib/career_profiles/career_interest.rb
|
|
92
|
+
- lib/career_profiles/cli.rb
|
|
93
|
+
- lib/career_profiles/occupation.rb
|
|
94
|
+
- lib/career_profiles/scraper.rb
|
|
95
|
+
homepage: https://github.com/anlsanchez5/career-profiles
|
|
96
|
+
licenses:
|
|
97
|
+
- MIT
|
|
98
|
+
metadata: {}
|
|
99
|
+
post_install_message:
|
|
100
|
+
rdoc_options: []
|
|
101
|
+
require_paths:
|
|
102
|
+
- lib
|
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
104
|
+
requirements:
|
|
105
|
+
- - ">="
|
|
106
|
+
- !ruby/object:Gem::Version
|
|
107
|
+
version: '0'
|
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
|
+
requirements:
|
|
110
|
+
- - ">="
|
|
111
|
+
- !ruby/object:Gem::Version
|
|
112
|
+
version: '0'
|
|
113
|
+
requirements: []
|
|
114
|
+
rubygems_version: 3.0.2
|
|
115
|
+
signing_key:
|
|
116
|
+
specification_version: 4
|
|
117
|
+
summary: Career Intrests and their Occupations
|
|
118
|
+
test_files: []
|