devry 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +47 -0
- data/VERSION +1 -0
- data/devry.gemspec +64 -0
- data/lib/devry.rb +106 -0
- data/spec/devry_spec.rb +67 -0
- data/spec/fixtures/index.html +967 -0
- data/spec/fixtures/job.html +328 -0
- data/spec/fixtures/page_2.html +626 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +17 -0
- metadata +118 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Michael Guterl
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
= devry
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
+
* Send me a pull request. Bonus points for topic branches.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2010 Michael Guterl. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "devry"
|
8
|
+
gem.summary = %Q{scrape jobs off of devry's career site}
|
9
|
+
gem.description = %Q{scrape jobs off of devry's career site}
|
10
|
+
gem.email = "mguterl@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/mguterl/devry"
|
12
|
+
gem.authors = ["Michael Guterl"]
|
13
|
+
gem.add_dependency "mechanize", ">= 1.0.0"
|
14
|
+
gem.add_development_dependency "rspec", ">= 1.3.0"
|
15
|
+
gem.add_development_dependency "fakeweb", ">= 1.2.8"
|
16
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
17
|
+
end
|
18
|
+
Jeweler::GemcutterTasks.new
|
19
|
+
rescue LoadError
|
20
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
21
|
+
end
|
22
|
+
|
23
|
+
require 'spec/rake/spectask'
|
24
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
25
|
+
spec.libs << 'lib' << 'spec'
|
26
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
27
|
+
end
|
28
|
+
|
29
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
30
|
+
spec.libs << 'lib' << 'spec'
|
31
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
32
|
+
spec.rcov = true
|
33
|
+
end
|
34
|
+
|
35
|
+
task :spec => :check_dependencies
|
36
|
+
|
37
|
+
task :default => :spec
|
38
|
+
|
39
|
+
require 'rake/rdoctask'
|
40
|
+
Rake::RDocTask.new do |rdoc|
|
41
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
42
|
+
|
43
|
+
rdoc.rdoc_dir = 'rdoc'
|
44
|
+
rdoc.title = "devry #{version}"
|
45
|
+
rdoc.rdoc_files.include('README*')
|
46
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
47
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.2
|
data/devry.gemspec
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{devry}
|
8
|
+
s.version = "0.0.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Michael Guterl"]
|
12
|
+
s.date = %q{2010-05-03}
|
13
|
+
s.description = %q{scrape jobs off of devry's career site}
|
14
|
+
s.email = %q{mguterl@gmail.com}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".gitignore",
|
22
|
+
"LICENSE",
|
23
|
+
"README.rdoc",
|
24
|
+
"Rakefile",
|
25
|
+
"VERSION",
|
26
|
+
"devry.gemspec",
|
27
|
+
"lib/devry.rb",
|
28
|
+
"spec/devry_spec.rb",
|
29
|
+
"spec/fixtures/index.html",
|
30
|
+
"spec/fixtures/job.html",
|
31
|
+
"spec/fixtures/page_2.html",
|
32
|
+
"spec/spec.opts",
|
33
|
+
"spec/spec_helper.rb"
|
34
|
+
]
|
35
|
+
s.homepage = %q{http://github.com/mguterl/devry}
|
36
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
37
|
+
s.require_paths = ["lib"]
|
38
|
+
s.rubygems_version = %q{1.3.6}
|
39
|
+
s.summary = %q{scrape jobs off of devry's career site}
|
40
|
+
s.test_files = [
|
41
|
+
"spec/devry_spec.rb",
|
42
|
+
"spec/spec_helper.rb"
|
43
|
+
]
|
44
|
+
|
45
|
+
if s.respond_to? :specification_version then
|
46
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
47
|
+
s.specification_version = 3
|
48
|
+
|
49
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
50
|
+
s.add_runtime_dependency(%q<mechanize>, [">= 1.0.0"])
|
51
|
+
s.add_development_dependency(%q<rspec>, [">= 1.3.0"])
|
52
|
+
s.add_development_dependency(%q<fakeweb>, [">= 1.2.8"])
|
53
|
+
else
|
54
|
+
s.add_dependency(%q<mechanize>, [">= 1.0.0"])
|
55
|
+
s.add_dependency(%q<rspec>, [">= 1.3.0"])
|
56
|
+
s.add_dependency(%q<fakeweb>, [">= 1.2.8"])
|
57
|
+
end
|
58
|
+
else
|
59
|
+
s.add_dependency(%q<mechanize>, [">= 1.0.0"])
|
60
|
+
s.add_dependency(%q<rspec>, [">= 1.3.0"])
|
61
|
+
s.add_dependency(%q<fakeweb>, [">= 1.2.8"])
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
data/lib/devry.rb
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'mechanize'
|
2
|
+
|
3
|
+
module Devry
|
4
|
+
|
5
|
+
module Helpers
|
6
|
+
|
7
|
+
def extract_text(element)
|
8
|
+
return nil if element.nil?
|
9
|
+
element.text.strip
|
10
|
+
end
|
11
|
+
|
12
|
+
def extract_time(element)
|
13
|
+
return nil if element.nil?
|
14
|
+
Time.parse(element.text.strip)
|
15
|
+
end
|
16
|
+
|
17
|
+
def extract_url(element)
|
18
|
+
return nil if element.nil?
|
19
|
+
element.at("a")['href']
|
20
|
+
end
|
21
|
+
|
22
|
+
def fetch_page(url)
|
23
|
+
agent.get(url)
|
24
|
+
end
|
25
|
+
|
26
|
+
def agent
|
27
|
+
@agent ||= Mechanize.new
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
class Job
|
33
|
+
|
34
|
+
extend Helpers
|
35
|
+
include Helpers
|
36
|
+
|
37
|
+
BASE_URI = 'https://devryuniversity-devry.icims.com/jobs/search?pr='
|
38
|
+
|
39
|
+
def self.all
|
40
|
+
page = fetch_page("#{BASE_URI}1")
|
41
|
+
|
42
|
+
page.body =~ /Page (\d+) of (\d+)/
|
43
|
+
page_count = $2.to_i
|
44
|
+
|
45
|
+
jobs = []
|
46
|
+
|
47
|
+
(1..page_count).each do |page_number|
|
48
|
+
|
49
|
+
page = fetch_page("#{BASE_URI}#{page_number}")
|
50
|
+
|
51
|
+
page.search(".iCIMS_JobsTable tr").each_with_index do |row, idx|
|
52
|
+
|
53
|
+
next if idx == 0 # skip header
|
54
|
+
|
55
|
+
details = row.search("td")
|
56
|
+
|
57
|
+
job = Job.new(:id => extract_text(details[0]),
|
58
|
+
:title => extract_text(details[1]),
|
59
|
+
:location => extract_text(details[2]),
|
60
|
+
:posted_date => extract_time(details[3]),
|
61
|
+
:url => extract_url(details[1]))
|
62
|
+
|
63
|
+
jobs << job
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
jobs
|
69
|
+
end
|
70
|
+
|
71
|
+
attr_reader :id, :title, :location, :posted_date, :url
|
72
|
+
|
73
|
+
def initialize(attributes = {})
|
74
|
+
attributes.each do |k, v|
|
75
|
+
instance_variable_set(:"@#{k}", v)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def city
|
80
|
+
split_location[2]
|
81
|
+
end
|
82
|
+
|
83
|
+
def state
|
84
|
+
split_location[1]
|
85
|
+
end
|
86
|
+
|
87
|
+
def country
|
88
|
+
split_location[0]
|
89
|
+
end
|
90
|
+
|
91
|
+
def description
|
92
|
+
page = fetch_page(url)
|
93
|
+
["tr:nth-child(11) p", "tr:nth-child(13) p", "tr:nth-child(15) p"].map do |selector|
|
94
|
+
extract_text page.at(selector)
|
95
|
+
end.join("\n\n")
|
96
|
+
end
|
97
|
+
|
98
|
+
private
|
99
|
+
|
100
|
+
def split_location
|
101
|
+
location.split('-')
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
data/spec/devry_spec.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# -*- coding: undecided -*-
|
2
|
+
require 'spec/spec_helper'
|
3
|
+
|
4
|
+
describe Devry do
|
5
|
+
|
6
|
+
describe Devry::Job do
|
7
|
+
|
8
|
+
describe ".all" do
|
9
|
+
|
10
|
+
before do
|
11
|
+
@jobs = Devry::Job.all
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should return a list of jobs' do
|
15
|
+
@jobs.size.should == 11
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "instance" do
|
21
|
+
|
22
|
+
before do
|
23
|
+
@jobs = Devry::Job.all
|
24
|
+
@job = @jobs.first
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should extract the id' do
|
28
|
+
@job.id.should == "2010-13545"
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should extract the title' do
|
32
|
+
@job.title.should == "Online Adjunct Faculty-Investment Fundamentals and Security Analysis"
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'should extract the location' do
|
36
|
+
@job.location.should == "US-CA-Fremont"
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should extract the country from location' do
|
40
|
+
@job.country.should == "US"
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'should extract the state from location' do
|
44
|
+
@job.state.should == "CA"
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should extract the city from location' do
|
48
|
+
@job.city.should == "Fremont"
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should extract the posted date' do
|
52
|
+
@job.posted_date.should == Time.mktime(2010, 4, 27)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should extract the url' do
|
56
|
+
@job.url.should == "https://devryuniversity-devry.icims.com/jobs/13545/job"
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should extract the description' do
|
60
|
+
@job.description.should == "The Faculty provides the educational focus of teaching (facilitating) in our academic courses, and service to the College, profession, and scholarly activities are integral aspects of this position.\n\nTo perform this job successfully, an individual must be able to perform each essential duty satisfactorily. The requirements listed below are representative of the knowledge, skill, and/or ability required. Reasonable accommodations may be made to enable individuals with disabilities to perform the essential functions.\n\nMaster's degree in Finance; Ph.D preferred. CPA, CFA or CFM is required. Minimum of 3 years related industry and/or academic experience. Prior teaching experience is required. We are proud to be an EEO employer M/F/D/V. We maintain a drug-free workplace and perform pre-employment substance abuse testing. Thank you for applying for this outstanding opportunity today."
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|