jobbie 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2677d8977d4f31787d9a4cdbb28915c1a1f2942c
4
+ data.tar.gz: 603af9e0f4454a85393a1d1e04b1dfb90750e03b
5
+ SHA512:
6
+ metadata.gz: 20f048a5aaf01b943e183a99ae840344e7ced655af0f60c0e3bca060647f7bfe5fd76458e7706131f17f4248079bf73e91617cceb5a449739215b5c4cd538b59
7
+ data.tar.gz: 358e600d349068b0e6d4a5528204b61c8372bdb0d03ddceb366e16d651be2565fb65184ab6032888cda060793bd579874b57b4178249ffa1a22e31a99aec481f
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1 @@
1
+ inherit_from: .rubocop_todo.yml
@@ -0,0 +1,27 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2015-12-10 14:48:37 -0200 using RuboCop version 0.35.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 48
10
+ # Configuration parameters: AllowURI, URISchemes.
11
+ Metrics/LineLength:
12
+ Max: 248
13
+
14
+ # Offense count: 8
15
+ # Configuration parameters: Exclude.
16
+ Style/Documentation:
17
+ Exclude:
18
+ - 'spec/**/*'
19
+ - 'test/**/*'
20
+ - 'lib/jobbie.rb'
21
+ - 'lib/jobbie/app.rb'
22
+ - 'lib/jobbie/indeed.rb'
23
+ - 'lib/jobbie/info_jobs.rb'
24
+ - 'lib/jobbie/ninetynine_jobs.rb'
25
+ - 'lib/jobbie/trampos.rb'
26
+ - 'lib/jobbie/vagas.rb'
27
+ - 'lib/jobbie/version.rb'
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.3
4
+ before_install: gem install bundler -v 1.10.6
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in jobbie.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Diego Carrion
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,76 @@
1
+ # Jobbie
2
+
3
+ Jobbie parses the job pages from different sites:
4
+
5
+ * [99jobs](https://www.99jobs.com/)
6
+ * [Indeed](http://www.indeed.com.br/)
7
+ * [InfoJobs](http://www.infojobs.com.br/)
8
+ * [Trampos](http://trampos.co/)
9
+ * [Vagas](http://www.vagas.com.br/)
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'jobbie'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install jobbie
26
+
27
+ ## Usage
28
+
29
+ ``` ruby
30
+ # Parsing a job page
31
+
32
+ url = 'http://trampos.co/oportunidades/123939'
33
+ dictionary = { skills: %w(Java Ruby Python ...), focuses: %w(Back-end Front-end Analytics ...) }
34
+
35
+ # Factory automatically detects the site by the URL
36
+ job = Jobbie::Factory.init url: url, dictionary: dictionary
37
+
38
+ # OR
39
+
40
+ job == Jobbie::Trampos.new url: url, dictionary: dictionary
41
+
42
+ # THEN
43
+
44
+ job.company
45
+ job.location
46
+ job.seniority
47
+ job.skills
48
+ job.required_skills
49
+ job.focuses
50
+
51
+ # Parsing a search result
52
+
53
+ jobs = Jobbie::Factory.init(url: 'http://trampos.co/oportunidades?tr=ruby').jobs
54
+
55
+ # THEN
56
+
57
+ jobs.first.title
58
+ jobs.first.url
59
+ jobs.first.location
60
+ ```
61
+
62
+ ## Development
63
+
64
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
65
+
66
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
67
+
68
+ ## Contributing
69
+
70
+ Bug reports and pull requests are welcome on GitHub at https://github.com/contratadome/jobbie.
71
+
72
+
73
+ ## License
74
+
75
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
76
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "jobbie"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'jobbie/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "jobbie"
8
+ spec.version = Jobbie::VERSION
9
+ spec.authors = ["Diego Carrion"]
10
+ spec.email = ["tech@contratado.me"]
11
+
12
+ spec.summary = %q{A job pages parser}
13
+ spec.homepage = "https://github.com/contratadome/jobbie"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "nokogiri"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.10"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec"
26
+ spec.add_development_dependency "byebug"
27
+ spec.add_development_dependency "webmock"
28
+ spec.add_development_dependency "vcr"
29
+ end
@@ -0,0 +1,25 @@
1
+ require 'nokogiri'
2
+ require 'jobbie/version'
3
+ require 'jobbie/app'
4
+ require 'jobbie/indeed'
5
+ require 'jobbie/info_jobs'
6
+ require 'jobbie/ninetynine_jobs'
7
+ require 'jobbie/trampos'
8
+ require 'jobbie/vagas'
9
+
10
+ module Jobbie
11
+ class Factory
12
+ def self.init(params)
13
+ class_for(params[:url]).new params
14
+ end
15
+
16
+ def self.class_for(url)
17
+ { 'www.vagas.com.br' => Vagas,
18
+ 'www.infojobs.com.br' => InfoJobs,
19
+ 'www.99jobs.com' => NinetynineJobs,
20
+ 'www.indeed.com.br' => Indeed,
21
+ 'trampos.co' => Trampos
22
+ }[URI.parse(url).host]
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,101 @@
1
+ require 'open-uri'
2
+
3
+ module Jobbie
4
+ class App
5
+ attr_reader :url, :title, :company
6
+
7
+ def initialize(url:, dictionary: {}, title: nil, location: nil, company: nil)
8
+ @url = url
9
+ @dictionary = dictionary
10
+ @title = title
11
+ @location = location
12
+ @company = company
13
+ end
14
+
15
+ def title
16
+ @title ||= title_text
17
+ end
18
+
19
+ def seniority
20
+ scan(%w(Junior Júnior Senior Sênior Pleno)).first
21
+ end
22
+
23
+ def required_skills
24
+ title.scan(regexp(@dictionary[:skills])).flatten
25
+ end
26
+
27
+ %w(focuses skills).each do |collection|
28
+ define_method collection do
29
+ scan @dictionary[collection.to_sym]
30
+ end
31
+ end
32
+
33
+ def location
34
+ @location ||= begin
35
+ element = find location_selector
36
+ element.text.split(%r{[,\/]})[0].strip if element
37
+ end
38
+ end
39
+
40
+ def company
41
+ @company ||= value_from find(company_locator)
42
+ end
43
+
44
+ def jobs
45
+ jobs_elements.map { |job| self.class.new to_job_params(job).merge(dictionary: @dictionary) }
46
+ end
47
+
48
+ private
49
+
50
+ def jobs_elements
51
+ doc.css(jobs_selector)
52
+ end
53
+
54
+ def title_text
55
+ doc.css(title_selector).map(&:text).join(' ')
56
+ end
57
+
58
+ def find(selector)
59
+ doc.css(selector).first
60
+ end
61
+
62
+ def scan(values)
63
+ document_text.gsub(%r{,|\/}, ' ').scan(regexp(values)).flatten.uniq(&:downcase)
64
+ end
65
+
66
+ def document_text
67
+ doc.text
68
+ end
69
+
70
+ def doc
71
+ @doc ||= Nokogiri(open(@url).read, nil, 'utf-8').tap do |doc|
72
+ doc.css(selectors_to_remove).remove if selectors_to_remove
73
+ end
74
+ end
75
+
76
+ def regexp(values)
77
+ /(?:\s(?:|\W)|^)(#{values.sort { |x, y| y <=> x }.map { |value| Regexp.escape(value).gsub("\\ ", "[\\ \\-]") }.join("|")})(?:\s|\W\s|$)/i
78
+ end
79
+
80
+ def title_selector
81
+ 'h1'
82
+ end
83
+
84
+ def selectors_to_remove
85
+ 'script, aside'
86
+ end
87
+
88
+ def path_to_url(path)
89
+ path.start_with?('http') ? path : build_url(path)
90
+ end
91
+
92
+ def build_url(path)
93
+ uri = URI url
94
+ "#{uri.scheme}://#{uri.host}#{path}"
95
+ end
96
+
97
+ def value_from(element)
98
+ element.text if element
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,35 @@
1
+ module Jobbie
2
+ class Indeed < App
3
+ private
4
+
5
+ def to_job_params(job)
6
+ a = job.css('a').first
7
+ { url: path_to_url(a.attr('href')), title: a.text, location: job.css('.location').first.text.split(',')[0], company: company_from(job) }
8
+ end
9
+
10
+ def company_from(job)
11
+ element = job.css("span[itemprop='name']").first
12
+ element.text.strip if element
13
+ end
14
+
15
+ def jobs_selector
16
+ 'div.result'
17
+ end
18
+
19
+ def company_locator
20
+ 'span.company'
21
+ end
22
+
23
+ def selectors_to_remove
24
+ '.recJobs'
25
+ end
26
+
27
+ def location_selector
28
+ 'span.location'
29
+ end
30
+
31
+ def title_selector
32
+ '.jobtitle font'
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,34 @@
1
+ module Jobbie
2
+ class InfoJobs < App
3
+ def company
4
+ super == 'Empresa com nome confidencial' ? nil : super
5
+ end
6
+
7
+ private
8
+
9
+ def to_job_params(job)
10
+ a = job.css('.vaga a').first
11
+ { url: a.attr('href'), title: a.text.strip, location: job.css("span[itemprop='addressLocality']").first.text.strip, company: company_from(job) }
12
+ end
13
+
14
+ def jobs_selector
15
+ '#ctl00_phMasterPage_cGrid_divGrid ul.unstyled.left'
16
+ end
17
+
18
+ def company_locator
19
+ '#ctl00_phMasterPage_cVacancySummary_litCompany'
20
+ end
21
+
22
+ def selectors_to_remove
23
+ '.gridSuggested.summary'
24
+ end
25
+
26
+ def location_selector
27
+ '#ctl00_phMasterPage_cVacancySummary_litLocation'
28
+ end
29
+
30
+ def company_from(job)
31
+ job.css("span[itemprop='name']").first.text.strip
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,31 @@
1
+ module Jobbie
2
+ class NinetynineJobs < App
3
+ def seniority
4
+ find('.col-md-6 p').text
5
+ end
6
+
7
+ private
8
+
9
+ def to_job_params(job)
10
+ a = job.css('a').first
11
+ { url: path_to_url(a.attr('href')), title: a.css('h1').first.text.strip, location: a.css('.mbf').first.text.scan(/Local (.*),/).flatten[0], company: company_from(a) }
12
+ end
13
+
14
+ def jobs_selector
15
+ 'div.panel-opportunity'
16
+ end
17
+
18
+ def company_locator
19
+ '.col-md-3 h1.panel-title'
20
+ end
21
+
22
+ def location_selector
23
+ 'address'
24
+ end
25
+
26
+ def company_from(a)
27
+ text = a.css('.evaluation-average').first.text.scan(/Organização(.*)/).flatten[0]
28
+ text == 'Não informado' ? nil : text
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,52 @@
1
+ require 'json'
2
+
3
+ module Jobbie
4
+ class Trampos < App
5
+ def location
6
+ @location ||= opportunity['city']
7
+ end
8
+
9
+ def company
10
+ @company ||= company_from(opportunity)
11
+ end
12
+
13
+ private
14
+
15
+ def selectors_to_remove
16
+ end
17
+
18
+ def to_job_params(job)
19
+ { url: path_to_url("/oportunidades/#{job['id']}"), title: job['name'], location: job['city'], company: company_from(job) }
20
+ end
21
+
22
+ def company_from(job)
23
+ (job['company'] || {})['name']
24
+ end
25
+
26
+ def jobs_elements
27
+ opportunities
28
+ end
29
+
30
+ def title_selector
31
+ 'h2'
32
+ end
33
+
34
+ def title_text
35
+ super.gsub(/\#\w{2} /, '')
36
+ end
37
+
38
+ def document_text
39
+ opportunity.reject { |key| key == 'company' }.values.join ' '
40
+ end
41
+
42
+ %w(opportunities opportunity).each do |name|
43
+ define_method name do
44
+ instance_variable_get("@#{name}") || instance_variable_set("@#{name}", parse(name))
45
+ end
46
+ end
47
+
48
+ def parse(name)
49
+ JSON.parse(doc.text.scan(/#{name}: (\{.*\})/).flatten[0])[name]
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,30 @@
1
+ module Jobbie
2
+ class Vagas < App
3
+ def seniority
4
+ find("span[itemprop='occupationalCategory']").text
5
+ end
6
+
7
+ def company
8
+ @company ||= find('title').text.scan(/\-\s(.*)\s\(/).flatten.first
9
+ end
10
+
11
+ private
12
+
13
+ def to_job_params(job)
14
+ a = job.css('a').first
15
+ { url: path_to_url(a.attr('href')), title: a.attr('title'), location: job.css("span[itemprop='addressLocality']").first.text.split(' / ')[0], company: job.css("span[itemprop='name']").first.text.strip }
16
+ end
17
+
18
+ def jobs_selector
19
+ 'article.vaga'
20
+ end
21
+
22
+ def selectors_to_remove
23
+ 'script, aside, .expiradaVagasSimilares'
24
+ end
25
+
26
+ def location_selector
27
+ "span[itemprop='address']"
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,3 @@
1
+ module Jobbie
2
+ VERSION = '0.1.0'
3
+ end
metadata ADDED
@@ -0,0 +1,162 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jobbie
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Diego Carrion
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-12-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
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: byebug
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
+ - !ruby/object:Gem::Dependency
84
+ name: webmock
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: vcr
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description:
112
+ email:
113
+ - tech@contratado.me
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - ".gitignore"
119
+ - ".rspec"
120
+ - ".rubocop.yml"
121
+ - ".rubocop_todo.yml"
122
+ - ".travis.yml"
123
+ - Gemfile
124
+ - LICENSE.txt
125
+ - README.md
126
+ - Rakefile
127
+ - bin/console
128
+ - bin/setup
129
+ - jobbie.gemspec
130
+ - lib/jobbie.rb
131
+ - lib/jobbie/app.rb
132
+ - lib/jobbie/indeed.rb
133
+ - lib/jobbie/info_jobs.rb
134
+ - lib/jobbie/ninetynine_jobs.rb
135
+ - lib/jobbie/trampos.rb
136
+ - lib/jobbie/vagas.rb
137
+ - lib/jobbie/version.rb
138
+ homepage: https://github.com/contratadome/jobbie
139
+ licenses:
140
+ - MIT
141
+ metadata: {}
142
+ post_install_message:
143
+ rdoc_options: []
144
+ require_paths:
145
+ - lib
146
+ required_ruby_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ required_rubygems_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ requirements: []
157
+ rubyforge_project:
158
+ rubygems_version: 2.4.5.1
159
+ signing_key:
160
+ specification_version: 4
161
+ summary: A job pages parser
162
+ test_files: []