job_hunter_cli 0.1.2 → 0.1.3

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
  SHA1:
3
- metadata.gz: a8142a717b5608b0681936521f2e64b2cd4c0674
4
- data.tar.gz: 37f722fd23e2b9a656e9a61b69fe4e726fd688f7
3
+ metadata.gz: a7a069a82ddd44ed87014ae52cd1e1cf8a1ae1e7
4
+ data.tar.gz: 9e630fac3ca511b1673721eb6ba680dc4dc5ca47
5
5
  SHA512:
6
- metadata.gz: e5ffe381e72d43d3707756369af26e1552022d9141c0d1b97bba584989710927f666a4c31dadd8bafe3bc7d9bd916e8ad807cba020f7a284ccca653424fe9525
7
- data.tar.gz: f080620e07d1bb02386caa2c83a2ffcb0ee91c292ddd6cad82da03335976a70d2522367299e1fb551e3cf3254de5cf629620adc8003c9b43e280a68611303396
6
+ metadata.gz: bb6e2c7cbcfd223cb2742285cdccf1e05e3c277bdaa9dc0b166a8ed453064a451f23660fbc6368fb73e271f92655f4c0ba8a603f5bf35b991a99b0e554d47c98
7
+ data.tar.gz: 513c494923bc655f92a8e585f719a8d6c5d1ee038e3dea6a7e8ef8929c8c005dde6b2aeaf6407e1f8b45e67e3c204d3ab19c22428f5e0c0a37453702df5af93b
Binary file
@@ -1,6 +1,4 @@
1
1
  # coding: utf-8
2
-
3
-
4
2
  lib = File.expand_path('../lib', __FILE__)
5
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
4
  require 'job_hunter_cli/version'
@@ -21,7 +19,7 @@ Gem::Specification.new do |spec|
21
19
  spec.require_paths = ["lib"]
22
20
 
23
21
  spec.add_development_dependency "open-uri"
24
- spec.add_development_dependency "nokogiri", '~> 1.6.0', '>= 1.6.0'
22
+ spec.add_development_dependency "nokogiri", '~> 1.6.0', '>= 1.6.0'
25
23
  spec.add_development_dependency "bundler", "~> 1.12"
26
24
  spec.add_development_dependency "rake", "~> 10.0"
27
25
  end
@@ -5,6 +5,7 @@ require 'pry'
5
5
  require_relative "job_hunter_cli/version"
6
6
  require_relative "job_hunter_cli/scraper"
7
7
  require_relative "job_hunter_cli/cli"
8
+ require_relative "job_hunter_cli/job"
8
9
 
9
10
  #this sets up the JobHunter Module as having access to all the JobHunter::*FILES*
10
11
  module JobHunterCli
@@ -1,66 +1,67 @@
1
1
  # Controller
2
-
2
+ # For review
3
3
  class JobHunterCli::CLI
4
4
 
5
5
  def start
6
- input =""
7
- input.downcase!
8
- invalid = "invalid"
9
6
  puts ""
10
7
  puts " ---------------------------------- | WELCOME TO JOB HUNTER |-------------------------------- "
11
- puts " If you press enter without input then search will return its default values "
12
- puts " Job Hunter shows you only the most recent jobs posted on Indeed.com "
8
+ puts " Job Hunter shows you only the most recent jobs posted on Indeed.com "
9
+ puts " -------------------------------------------------------------------------------------------- "
10
+ puts ""
11
+ puts " Note: If you press enter without input then search will return its default values "
12
+ puts " Press exit anytime to exit search and start over "
13
13
  puts ""
14
- scraper = JobHunterCli::Scraper.new
14
+ define_scraper
15
+ end
15
16
 
16
- until input =="exit"
17
- # check for input not equal to exit to prevent the cli from not exiting when type exit after prompt
18
- if input !="exit"
19
- puts "1. Enter the max number of the search results you want return. Defaults to 10 if not specified"
20
- input = gets.strip
21
- scraper.limit = "limit=" + input
22
- end
17
+ def define_scraper
18
+ scraper = JobHunterCli::Scraper.new # instantiate the scraper class and save it in a local variable
23
19
 
24
- if input!="exit"
20
+ puts "1. Enter the max number of the search results you want return. Defaults to 10 if not specified"
21
+ scraper.limit = scraper_queries("limit")
25
22
  puts "2. Enter any query or name of job role"
26
- input = gets.strip
27
- scraper.q = "q=" + input
28
- end
29
-
30
- if input!="exit"
23
+ scraper.q = scraper_queries("q")
31
24
  puts "3. Enter initals or name of country. Defaults to US if not specified"
32
- input = gets.strip
33
- scraper.co = "co=" + input
34
- end
35
-
36
- if input!="exit"
25
+ scraper.co = scraper_queries("co")
37
26
  puts "4. Enter a postal code or a city"
38
- input = gets.strip
39
- scraper.l = "l=" + input
40
- end
41
-
42
- if input!="exit"
27
+ scraper.l = scraper_queries("l")
43
28
  puts "5. Enter a number for distance from search location. Defaults to 25 if not specified"
44
- input = gets.strip
45
- scraper.radius = "radius=" + input
46
- end
29
+ scraper.radius = scraper_queries("radius")
30
+ scraper.scrape_jobs # start scrape
31
+ print_jobs
32
+ prompt_after_search
33
+ end
47
34
 
48
- if input != "exit"
49
- scraper.scrape_jobs # start scrape
50
- jobs_array = scraper.scrape_jobs # return the array of hash objects from scrape
51
- counter=0 # apply numbering to results
52
- jobs_array.each do |a|
53
- puts "|" + "#{counter+=1}" +"|"
54
- a.each do |key,value|
55
- puts "#{key.capitalize}: #{value}"
56
- end # end of second each enumerable
57
- puts ""
58
- end # end of first each enumerable
59
- else
60
- puts "Search Ended"
61
- end # end of last if statement on line 47
62
- end # end of until statement
35
+ def scraper_queries(query_type)
36
+ input = gets.strip
37
+ "#{query_type}=#{input}"
38
+ end
63
39
 
64
- end # end of start method
40
+ def print_jobs
41
+ counter = 0 # apply numbering to results
42
+ JobHunterCli::Job.all.each do |job_details|
43
+ puts ""
44
+ puts "#{counter+=1}. " + job_details.job_role
45
+ puts " • " + job_details.company
46
+ puts " • " + job_details.city + ", " + job_details.state + " - " +job_details.country
47
+ puts " • " + job_details.date_posted
48
+ puts " • " + job_details.post_duration
49
+ puts " • " + job_details.description
50
+ puts " • " + job_details.url
51
+ end # end of second each enumerable
52
+ end # end of print_jobs method
53
+
54
+ def prompt_after_search
55
+ puts ""
56
+ puts "--------------------| Search Completed |----------------------"
57
+ puts " Type 'start' to start over or 'exit' to exit search "
58
+ input = gets.strip
59
+ if input == "exit"
60
+ puts "Search Ended...."
61
+ elsif input == "start"
62
+ puts "Enter New Search"
63
+ self.define_scraper
64
+ end
65
+ end
65
66
 
66
- end
67
+ end # end of class
@@ -0,0 +1,22 @@
1
+ class JobHunterCli::Job
2
+ attr_accessor :job_role, :company, :city, :state, :country, :url, :description, :date_posted, :post_duration
3
+ @@jobs = []
4
+
5
+ def initialize(params = {}) # default argument, when instantiated the
6
+ @job_role = params[:job_role]
7
+ @company = params[:company]
8
+ @city = params[:city]
9
+ @state = params[:state]
10
+ @country = params[:country]
11
+ @url = params[:url]
12
+ @description = params[:description]
13
+ @date_posted = params[:date_posted]
14
+ @post_duration = params[:post_duration]
15
+ @@jobs << self
16
+ end
17
+
18
+ def self.all
19
+ @@jobs
20
+ end
21
+
22
+ end
@@ -5,25 +5,21 @@ class JobHunterCli::Scraper
5
5
  def scrape_jobs
6
6
  # indeed.com api uses XML. To parse in XLM use Nokogiri
7
7
  uri = "http://api.indeed.com/ads/apisearch?publisher=3881286689960538&#{@q}&#{@l}&sort=date&#{@radius}&st=&jt=&start=&#{@limit}&fromage=&filter=&latlong=1&#{@co}&chnl=&userip=1.2.3.4&useragent=Mozilla/%2F4.0%28Firefox%29&v=2"
8
- jobs_array = []
9
- jobs_hash = {}
8
+
10
9
  doc = Nokogiri::XML(open(uri))
11
10
  doc.css("result").each do |job_result|
12
- jobs_hash = {
13
- job_role: job_result.css("jobtitle").text,
14
- company: job_result.css("company").text,
15
- city: job_result.css("city").text,
16
- state: job_result.css("state").text,
17
- country: job_result.css("country").text,
18
- url: job_result.css("url").text,
19
- description: job_result.css("snippet").text,
20
- date_posted: job_result.css("date").text,
21
- post_duration: job_result.css("formattedRelativeTime").text
22
- }
23
- jobs_array << jobs_hash
24
-
25
- end # end of each statement
26
- jobs_array
11
+ JobHunterCli::Job.new({
12
+ job_role: job_result.css("jobtitle").text,
13
+ company: job_result.css("company").text,
14
+ city: job_result.css("city").text,
15
+ state: job_result.css("state").text,
16
+ country: job_result.css("country").text,
17
+ url: job_result.css("url").text,
18
+ description: job_result.css("snippet").text,
19
+ date_posted: job_result.css("date").text,
20
+ post_duration: job_result.css("formattedRelativeTime").text
21
+ })
22
+ end # end of each statemen
27
23
  end
28
24
 
29
25
  end
@@ -1,3 +1,3 @@
1
1
  module JobHunterCli
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: job_hunter_cli
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
  - Lenn Hypolite
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-06 00:00:00.000000000 Z
11
+ date: 2016-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: open-uri
@@ -91,9 +91,11 @@ files:
91
91
  - bin/job_hunter_cli
92
92
  - bin/setup
93
93
  - job_hunter_cli-0.1.1.gem
94
+ - job_hunter_cli-0.1.2.gem
94
95
  - job_hunter_cli.gemspec
95
96
  - lib/job_hunter_cli.rb
96
97
  - lib/job_hunter_cli/cli.rb
98
+ - lib/job_hunter_cli/job.rb
97
99
  - lib/job_hunter_cli/scraper.rb
98
100
  - lib/job_hunter_cli/version.rb
99
101
  - spec.md