jobparser 0.11.0 → 0.12.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.
@@ -9,7 +9,8 @@ module JobParser
9
9
 
10
10
  def store(hash)
11
11
  Job.where(:url => hash[:url]).delete
12
- Job.new(hash).save!
12
+ hash = strip_job_fields(hash)
13
+ Job.create(hash)
13
14
  end
14
15
 
15
16
  def cache_expired?(url)
@@ -41,6 +42,14 @@ module JobParser
41
42
  include Mongoid::Document
42
43
  include Mongoid::Timestamps
43
44
 
45
+ EXTRA_SCHEMA_TEXT_FIELDS = %w{
46
+ benefits education_requirements incentives industry
47
+ occupational_category qualifications responsibilities skills special_commitments work_hours
48
+ }
49
+ EXTRA_SCHEMA_TEXT_FIELDS.each do |f|
50
+ field f.to_sym, :type => String
51
+ end
52
+
44
53
  field :url, :type => String
45
54
  field :salary, :type => Array
46
55
  field :title, :type => String
@@ -48,6 +57,17 @@ module JobParser
48
57
  field :salary_string, :type => String
49
58
  field :location, :type => String
50
59
  field :deadline, :type => String
60
+ field :schema, :type => Boolean, :default => false
61
+
62
+ end
63
+
64
+ private
65
+
66
+ def strip_job_fields(hash)
67
+ new_hash = {}
68
+ excluded_fields = [:from_cache]
69
+ hash.each { |k, v| new_hash[k] = v unless excluded_fields.include?(k) }
70
+ new_hash
51
71
  end
52
72
 
53
73
  end
@@ -35,7 +35,7 @@ module JobParser
35
35
  EXTRA_SCHEMA_TEXT_FIELDS.each do |field|
36
36
  underscore_name = underscore(field).to_sym
37
37
  result = send("job_#{underscore_name}")
38
- res[underscore_name] = result unless result.nil?
38
+ res[underscore_name] = result unless result.nil? || result.empty?
39
39
  end
40
40
  end
41
41
  cache(res)
@@ -1,3 +1,3 @@
1
1
  module JobParser
2
- VERSION = "0.11.0"
2
+ VERSION = "0.12.0"
3
3
  end
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.11.0
4
+ version: 0.12.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: