jobparser 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,24 @@
1
+ require 'date'
2
+
3
+ module JobParser
4
+ module Facets
5
+ class Deadline < Facet
6
+ def parse
7
+ special_case_result = use_special_case(:deadline)
8
+ return special_case_result unless special_case_result.nil?
9
+
10
+ regex = /(Apply before|Closing Date):\s*(.+)$/i
11
+ loop_over_elements { |name, elem|
12
+ regex.match(elem.content) { |m|
13
+ return Cleaner.strip_all_white_space(m[2])
14
+ }
15
+ }
16
+
17
+ regex.match(@plain_text) { |m|
18
+ # return Cleaner.strip_all_white_space(m[2])
19
+ }
20
+
21
+ end
22
+ end
23
+ end
24
+ end
@@ -16,7 +16,9 @@ module JobParser
16
16
 
17
17
  def use_special_case(name)
18
18
  if special_case = SpecialCases.case_for_url(@url)
19
- special_case[name].call(@doc)
19
+ unless special_case[name].nil?
20
+ special_case[name].call(@doc)
21
+ end
20
22
  end
21
23
  end
22
24
 
@@ -23,5 +23,9 @@ module JobParser
23
23
  def apply_link
24
24
  Facets::Apply.new(@doc, @url, @plain_text).parse
25
25
  end
26
+
27
+ def deadline
28
+ Facets::Deadline.new(@doc, @url, @plain_text).parse
29
+ end
26
30
  end
27
31
  end
@@ -16,7 +16,8 @@ module JobParser
16
16
  :title => job_title,
17
17
  :apply => apply_link,
18
18
  :salary_string => job_salary_string,
19
- :location => job_location
19
+ :location => job_location,
20
+ :deadline => deadline
20
21
  }
21
22
  end
22
23
 
@@ -36,6 +36,10 @@ module JobParser
36
36
  end
37
37
  end
38
38
 
39
+ def deadline
40
+
41
+ end
42
+
39
43
  def does_use_schema?
40
44
  @doc.css("*").any? { |elem|
41
45
  elem['itemtype'] == "http://schema.org/JobPosting"
@@ -38,6 +38,17 @@ module JobParser
38
38
  }
39
39
  salary
40
40
  }
41
+ },
42
+ "bfi.org.uk" => {
43
+ :deadline => Proc.new { |doc|
44
+ match = ""
45
+ doc.css(".block-container>p").each do |p|
46
+ /The closing date for this position is (.+)\./.match(p.content) { |m|
47
+ match = m[1]
48
+ }
49
+ end
50
+ match
51
+ }
41
52
  }
42
53
  }
43
54
  end
@@ -1,3 +1,3 @@
1
1
  module JobParser
2
- VERSION = "0.4.2"
2
+ VERSION = "0.5.0"
3
3
  end
data/lib/jobparser.rb CHANGED
@@ -12,6 +12,7 @@ require "jobparser/facets/salarystring"
12
12
  require "jobparser/facets/location"
13
13
  require "jobparser/facets/apply"
14
14
  require "jobparser/facets/title"
15
+ require "jobparser/facets/deadline"
15
16
 
16
17
  require "open-uri"
17
18
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jobparser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-26 00:00:00.000000000 Z
12
+ date: 2013-07-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -100,6 +100,7 @@ extra_rdoc_files: []
100
100
  files:
101
101
  - lib/jobparser/cleaner.rb
102
102
  - lib/jobparser/facets/apply.rb
103
+ - lib/jobparser/facets/deadline.rb
103
104
  - lib/jobparser/facets/facet.rb
104
105
  - lib/jobparser/facets/location.rb
105
106
  - lib/jobparser/facets/salary.rb