Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Replace mechanize with plain old open-uri and nokogiri

  • Loading branch information...
commit 405e9727a2797c7fdac5720f1ad1cfc7b4f2c534 1 parent 687a453
Michael Guterl mguterl authored
Showing with 6 additions and 9 deletions.
  1. +1 −1  Rakefile
  2. +4 −7 lib/devry.rb
  3. +1 −1  spec/devry_spec.rb
2  Rakefile
View
@@ -10,7 +10,7 @@ begin
gem.email = "mguterl@gmail.com"
gem.homepage = "http://github.com/mguterl/devry"
gem.authors = ["Michael Guterl"]
- gem.add_dependency "mechanize", ">= 1.0.0"
+ gem.add_dependency "nokogiri"
gem.add_development_dependency "rspec", ">= 1.3.0"
gem.add_development_dependency "fakeweb", ">= 1.2.8"
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
11 lib/devry.rb
View
@@ -1,4 +1,5 @@
-require 'mechanize'
+require 'open-uri'
+require 'nokogiri'
module Devry
@@ -20,11 +21,7 @@ def extract_url(element)
end
def fetch_page(url)
- agent.get(url)
- end
-
- def agent
- @agent ||= Mechanize.new
+ Nokogiri::HTML open(url)
end
def extract_description(url)
@@ -51,7 +48,7 @@ class Job
def self.all
page = fetch_page("#{BASE_URI}1")
- page.body =~ /Page (\d+) of (\d+)/
+ page.to_s =~ /Page (\d+) of (\d+)/
page_count = $2.to_i
jobs = []
2  spec/devry_spec.rb
View
@@ -57,7 +57,7 @@
end
it 'should extract the description' do
- @job.description.should == "<tr><td class=\"iCIMS_InfoField iCIMS_InfoField_Job\"><strong>Overview</strong>:</td></tr><tr><td class=\"iCIMS_InfoMsg iCIMS_InfoMsg_Job\"><p style=\"margin: 0px\">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.</p><br><br></td></tr><tr><td class=\"iCIMS_InfoField iCIMS_InfoField_Job\"><strong>Responsibilities</strong>:</td></tr><tr><td class=\"iCIMS_InfoMsg iCIMS_InfoMsg_Job\"><p style=\"margin: 0px\">To 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.</p><p style=\"margin: 0px\"> </p><ol><li>Develops strategies to teach the course for the entire semester or session, using DeVry Online curriculum guides and meeting the university's academic standards.</li><li>Provides students with an approved syllabus that follows a template established by DeVry Online, and which includes the terminal course objectives. </li><li>Organizes and prepares all course materials for facilitation.</li><li>Utilizes appropriate educational technology to engage students and enhance learning. </li><li>Connects students' current study to real-world applications, using lab and library assignments and linking coursework to previous/future study in related disciplines. </li><li>Ensures that the content and level of material included on exams correspond to the course terminal objectives, that the material has been adequately addressed in the course, that concepts have been demonstrated, and that relevant homework has been reviewed. </li><li>Provides multiple evaluative formats for students to demonstrate their knowledge and earn their grades in the course. </li><li>Demonstrates consistency and fairness in the preparation and grading of exams, and provide timely feedback to students. </li><li>Maintains students’ grade book, and completes final grades by the deadline.</li></ol><br><br></td></tr><tr><td class=\"iCIMS_InfoField iCIMS_InfoField_Job\"><strong>Qualifications</strong>:</td></tr><tr><td class=\"iCIMS_InfoMsg iCIMS_InfoMsg_Job\"><p style=\"margin: 0px\">Master'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. <br><br>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.</p><br><br></td></tr>"
+ @job.description.should == "<tr><td class=\"iCIMS_InfoField iCIMS_InfoField_Job\"><strong>Overview</strong>:</td></tr><tr><td class=\"iCIMS_InfoMsg iCIMS_InfoMsg_Job\"><p style=\"margin: 0px\">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.</p><br><br></td></tr><tr><td class=\"iCIMS_InfoField iCIMS_InfoField_Job\"><strong>Responsibilities</strong>:</td></tr><tr><td class=\"iCIMS_InfoMsg iCIMS_InfoMsg_Job\"><p style=\"margin: 0px\">To 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.</p><p style=\"margin: 0px\">&nbsp;</p><ol><li>Develops strategies to teach the course for the entire semester or session, using DeVry Online curriculum guides and meeting the university's academic standards.</li><li>Provides students with an approved syllabus that follows a template established by DeVry Online, and which includes the terminal course objectives. </li><li>Organizes and prepares all course materials for facilitation.</li><li>Utilizes appropriate educational technology to engage students and enhance learning. </li><li>Connects students' current study to real-world applications, using lab and library assignments and linking coursework to previous/future study in related disciplines. </li><li>Ensures that the content and level of material included on exams correspond to the course terminal objectives, that the material has been adequately addressed in the course, that concepts have been demonstrated, and that relevant homework has been reviewed. </li><li>Provides multiple evaluative formats for students to demonstrate their knowledge and earn their grades in the course. </li><li>Demonstrates consistency and fairness in the preparation and grading of exams, and provide timely feedback to students. </li><li>Maintains students&rsquo; grade book, and completes final grades by the deadline.</li></ol><br><br></td></tr><tr><td class=\"iCIMS_InfoField iCIMS_InfoField_Job\"><strong>Qualifications</strong>:</td></tr><tr><td class=\"iCIMS_InfoMsg iCIMS_InfoMsg_Job\"><p style=\"margin: 0px\">Master's degree in Finance; Ph.D preferred. CPA, CFA or CFM is required.&nbsp; Minimum of 3 years related industry and/or academic experience. Prior teaching experience is required. <br><br>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.</p><br><br></td></tr>"
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.