cb-api 1.0.4 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cb/clients/email_subscription_api.rb +2 -2
- data/lib/cb/clients/employee_types_api.rb +1 -1
- data/lib/cb/clients/job_api.rb +1 -1
- data/lib/cb/clients/recommendation_api.rb +2 -2
- data/lib/cb/clients/saved_search_api.rb +1 -1
- data/lib/cb/models/implementations/cb_category.rb +6 -6
- data/lib/cb/utils/validator.rb +9 -10
- data/lib/cb/version.rb +1 -1
- metadata +3 -20
- data/lib/memory.rb +0 -86
@@ -12,7 +12,7 @@ module Cb
|
|
12
12
|
my_api = Cb::Utils::Api.new()
|
13
13
|
json_hash = my_api.cb_get(Cb.configuration.uri_subscription_retrieve, :query => {:ExternalID => did, :Hostsite => host_site})
|
14
14
|
|
15
|
-
if json_hash.has_key?('SubscriptionValues') && json_hash['SubscriptionValues'].
|
15
|
+
if json_hash.has_key?('SubscriptionValues') && !json_hash['SubscriptionValues'].nil?
|
16
16
|
subscription = CbEmailSubscription.new(json_hash['SubscriptionValues'])
|
17
17
|
my_api.append_api_responses(subscription, json_hash['SubscriptionValues'])
|
18
18
|
end
|
@@ -56,7 +56,7 @@ module Cb
|
|
56
56
|
json_hash = my_api.cb_post(Cb.configuration.uri_subscription_modify,
|
57
57
|
:body => xml_body)
|
58
58
|
|
59
|
-
if json_hash.has_key?('SubscriptionValues') && json_hash['SubscriptionValues'].
|
59
|
+
if json_hash.has_key?('SubscriptionValues') && !json_hash['SubscriptionValues'].nil?
|
60
60
|
subscription = CbEmailSubscription.new(json_hash['SubscriptionValues'])
|
61
61
|
my_api.append_api_responses(subscription, json_hash['SubscriptionValues'])
|
62
62
|
end
|
@@ -23,7 +23,7 @@ module Cb
|
|
23
23
|
employee_types = []
|
24
24
|
if json_hash.has_key?('ResponseEmployeeTypes')
|
25
25
|
if json_hash['ResponseEmployeeTypes'].has_key?('EmployeeTypes') &&
|
26
|
-
json_hash['ResponseEmployeeTypes']['EmployeeTypes'].
|
26
|
+
!json_hash['ResponseEmployeeTypes']['EmployeeTypes'].nil?
|
27
27
|
|
28
28
|
if json_hash['ResponseEmployeeTypes']['EmployeeTypes']['EmployeeType'].is_a?(Array)
|
29
29
|
|
data/lib/cb/clients/job_api.rb
CHANGED
@@ -17,7 +17,7 @@ module Cb
|
|
17
17
|
jobs = []
|
18
18
|
if json_hash.has_key?('ResponseJobSearch')
|
19
19
|
if json_hash['ResponseJobSearch'].has_key?('Results') &&
|
20
|
-
json_hash['ResponseJobSearch']['Results'].
|
20
|
+
!json_hash['ResponseJobSearch']['Results'].nil?
|
21
21
|
|
22
22
|
json_hash['ResponseJobSearch']['Results']['JobSearchResult'].each do | cur_job |
|
23
23
|
jobs << CbJob.new(cur_job)
|
@@ -17,7 +17,7 @@ module Cb
|
|
17
17
|
jobs = []
|
18
18
|
if json_hash.has_key?('ResponseRecommendJob')
|
19
19
|
if json_hash['ResponseRecommendJob'].has_key?('RecommendJobResults') &&
|
20
|
-
json_hash['ResponseRecommendJob']['RecommendJobResults'].
|
20
|
+
!json_hash['ResponseRecommendJob']['RecommendJobResults'].nil?
|
21
21
|
|
22
22
|
json_hash['ResponseRecommendJob']['RecommendJobResults']['RecommendJobResult'].each do |cur_job|
|
23
23
|
jobs << CbJob.new(cur_job)
|
@@ -47,7 +47,7 @@ module Cb
|
|
47
47
|
if json_hash.has_key?('ResponseRecommendUser')
|
48
48
|
|
49
49
|
if json_hash['ResponseRecommendUser'].has_key?('RecommendJobResults') &&
|
50
|
-
|
50
|
+
!json_hash['ResponseRecommendUser']['RecommendJobResults'].nil?
|
51
51
|
|
52
52
|
json_hash['ResponseRecommendUser']['RecommendJobResults']['RecommendJobResult'].each do |cur_job|
|
53
53
|
jobs << CbJob.new(cur_job)
|
@@ -117,7 +117,7 @@ module Cb
|
|
117
117
|
if json_hash.has_key?('SavedJobSearches') && json_hash['SavedJobSearches'].has_key?('SavedSearches')
|
118
118
|
saved_search_hash = json_hash['SavedJobSearches']['SavedSearches']
|
119
119
|
|
120
|
-
|
120
|
+
unless saved_search_hash.nil?
|
121
121
|
if saved_search_hash['SavedSearch'].is_a?(Array)
|
122
122
|
saved_search_hash['SavedSearch'].each do |saved_search|
|
123
123
|
saved_searches << CbSavedSearch.new(saved_search)
|
@@ -2,21 +2,21 @@ module Cb
|
|
2
2
|
class CbCategory
|
3
3
|
attr_accessor :code, :name, :language
|
4
4
|
def initialize(args={})
|
5
|
-
@code = args["Code"]
|
6
|
-
@name = args["Name"]["#text"]
|
7
|
-
@language = args["Name"]["@language"] ||
|
5
|
+
@code = args["Code"] || String.new
|
6
|
+
@name = args["Name"]["#text"] || String.new
|
7
|
+
@language = args["Name"]["@language"] || String.new
|
8
8
|
end
|
9
9
|
|
10
10
|
def CategoryName()
|
11
|
-
|
11
|
+
@name unless @name.nil?
|
12
12
|
end
|
13
13
|
|
14
14
|
def CategoryCode()
|
15
|
-
|
15
|
+
@code unless @code.nil?
|
16
16
|
end
|
17
17
|
|
18
18
|
def CategoryLanguage()
|
19
|
-
|
19
|
+
@language unless @language.nil?
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
data/lib/cb/utils/validator.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'json'
|
2
|
-
require 'active_support/core_ext/hash'
|
3
2
|
|
4
3
|
module Cb
|
5
4
|
module ResponseValidator
|
@@ -17,13 +16,9 @@ module Cb
|
|
17
16
|
|
18
17
|
begin
|
19
18
|
json = JSON.parse(response.response.body)
|
20
|
-
|
21
|
-
return json
|
22
|
-
else
|
23
|
-
return self.get_empty_json_hash
|
24
|
-
end
|
19
|
+
json.keys.any? ? json : self.get_empty_json_hash
|
25
20
|
rescue JSON::ParserError
|
26
|
-
|
21
|
+
self.handle_parser_error(response.response.body)
|
27
22
|
end
|
28
23
|
end
|
29
24
|
|
@@ -35,7 +30,7 @@ module Cb
|
|
35
30
|
return self.get_empty_json_hash
|
36
31
|
else
|
37
32
|
# if it was, return a hash from the xml UNLESS it was a generic
|
38
|
-
xml_hash =
|
33
|
+
xml_hash = nori.parse(xml.to_s)
|
39
34
|
if xml_hash.has_key?('Response') && xml_hash['Response'].has_key?('Errors')
|
40
35
|
return self.get_empty_json_hash
|
41
36
|
else
|
@@ -45,8 +40,12 @@ module Cb
|
|
45
40
|
end
|
46
41
|
|
47
42
|
def self.get_empty_json_hash
|
48
|
-
|
43
|
+
Hash.new
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.nori
|
47
|
+
@nori ||= Nori.new
|
49
48
|
end
|
50
49
|
|
51
50
|
end
|
52
|
-
end
|
51
|
+
end
|
data/lib/cb/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cb-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -19,7 +19,7 @@ authors:
|
|
19
19
|
autorequire:
|
20
20
|
bindir: bin
|
21
21
|
cert_chain: []
|
22
|
-
date: 2013-
|
22
|
+
date: 2013-11-01 00:00:00.000000000 Z
|
23
23
|
dependencies:
|
24
24
|
- !ruby/object:Gem::Dependency
|
25
25
|
name: httparty
|
@@ -85,22 +85,6 @@ dependencies:
|
|
85
85
|
- - ~>
|
86
86
|
- !ruby/object:Gem::Version
|
87
87
|
version: 1.6.0
|
88
|
-
- !ruby/object:Gem::Dependency
|
89
|
-
name: activesupport
|
90
|
-
requirement: !ruby/object:Gem::Requirement
|
91
|
-
none: false
|
92
|
-
requirements:
|
93
|
-
- - ~>
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version: 3.2.11
|
96
|
-
type: :runtime
|
97
|
-
prerelease: false
|
98
|
-
version_requirements: !ruby/object:Gem::Requirement
|
99
|
-
none: false
|
100
|
-
requirements:
|
101
|
-
- - ~>
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: 3.2.11
|
104
88
|
- !ruby/object:Gem::Dependency
|
105
89
|
name: rake
|
106
90
|
requirement: !ruby/object:Gem::Requirement
|
@@ -242,7 +226,6 @@ files:
|
|
242
226
|
- lib/cb/utils/validator.rb
|
243
227
|
- lib/cb/version.rb
|
244
228
|
- lib/cb.rb
|
245
|
-
- lib/memory.rb
|
246
229
|
- README.md
|
247
230
|
homepage: http://api.careerbuilder.com
|
248
231
|
licenses:
|
@@ -265,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
265
248
|
version: '0'
|
266
249
|
requirements: []
|
267
250
|
rubyforge_project:
|
268
|
-
rubygems_version: 1.8.
|
251
|
+
rubygems_version: 1.8.25
|
269
252
|
signing_key:
|
270
253
|
specification_version: 3
|
271
254
|
summary: Ruby wrapper around Careerbuilder Public API.
|
data/lib/memory.rb
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
module Memory
|
2
|
-
# sizes are guessed, I was too lazy to look
|
3
|
-
# them up and then they are also platform
|
4
|
-
# dependent
|
5
|
-
REF_SIZE = 4 # ?
|
6
|
-
OBJ_OVERHEAD = 4 # ?
|
7
|
-
FIXNUM_SIZE = 4 # ?
|
8
|
-
|
9
|
-
# informational output from analysis
|
10
|
-
MemoryInfo = Struct.new :roots, :objects, :bytes, :loops
|
11
|
-
|
12
|
-
def self.analyze(*roots)
|
13
|
-
an = Analyzer.new
|
14
|
-
an.roots = roots
|
15
|
-
an.analyze
|
16
|
-
end
|
17
|
-
|
18
|
-
class Analyzer
|
19
|
-
attr_accessor :roots
|
20
|
-
attr_reader :result
|
21
|
-
|
22
|
-
def analyze
|
23
|
-
@result = MemoryInfo.new roots, 0, 0, 0
|
24
|
-
@objs = {}
|
25
|
-
|
26
|
-
queue = roots.dup
|
27
|
-
|
28
|
-
until queue.empty?
|
29
|
-
obj = queue.shift
|
30
|
-
|
31
|
-
case obj
|
32
|
-
# special treatment for some types
|
33
|
-
# some are certainly missing from this
|
34
|
-
when IO
|
35
|
-
visit(obj)
|
36
|
-
when String
|
37
|
-
visit(obj) { @result.bytes += obj.size }
|
38
|
-
when Fixnum
|
39
|
-
@result.bytes += FIXNUM_SIZE
|
40
|
-
when Array
|
41
|
-
visit(obj) do
|
42
|
-
@result.bytes += obj.size * REF_SIZE
|
43
|
-
queue.concat(obj)
|
44
|
-
end
|
45
|
-
when Hash
|
46
|
-
visit(obj) do
|
47
|
-
@result.bytes += obj.size * REF_SIZE * 2
|
48
|
-
obj.each {|k,v| queue.push(k).push(v)}
|
49
|
-
end
|
50
|
-
when Enumerable
|
51
|
-
visit(obj) do
|
52
|
-
obj.each do |o|
|
53
|
-
@result.bytes += REF_SIZE
|
54
|
-
queue.push(o)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
else
|
58
|
-
visit(obj) do
|
59
|
-
obj.instance_variables.each do |var|
|
60
|
-
@result.bytes += REF_SIZE
|
61
|
-
queue.push(obj.instance_variable_get(var))
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
@result
|
68
|
-
end
|
69
|
-
|
70
|
-
private
|
71
|
-
def visit(obj)
|
72
|
-
id = obj.object_id
|
73
|
-
|
74
|
-
if @objs.has_key? id
|
75
|
-
@result.loops += 1
|
76
|
-
false
|
77
|
-
else
|
78
|
-
@objs[id] = true
|
79
|
-
@result.bytes += OBJ_OVERHEAD
|
80
|
-
@result.objects += 1
|
81
|
-
yield obj if block_given?
|
82
|
-
true
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|