cb-api 1.0.1 → 1.0.3

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.
@@ -10,7 +10,7 @@ module Cb
10
10
  #############################################################
11
11
  def self.retrieve_by_did(did, host_site = '')
12
12
  my_api = Cb::Utils::Api.new()
13
- json_hash = my_api.cb_get_secure(Cb.configuration.uri_subscription_retrieve, :query => {:ExternalID => did, :Hostsite => host_site})
13
+ json_hash = my_api.cb_get(Cb.configuration.uri_subscription_retrieve, :query => {:ExternalID => did, :Hostsite => host_site})
14
14
 
15
15
  if json_hash.has_key?('SubscriptionValues') && json_hash['SubscriptionValues'].present?
16
16
  subscription = CbEmailSubscription.new(json_hash['SubscriptionValues'])
@@ -7,7 +7,7 @@ module Cb
7
7
  ## Run a job search against the given criteria
8
8
  ##
9
9
  ## For detailed information around this API please visit:
10
- ## http://api.careerbuilder.com/JobSearchInfo.aspx
10
+ ##
11
11
  #############################################################
12
12
  def self.search(*args)
13
13
  args = args[0] if args.is_a?(Array) && args.count == 1
@@ -8,7 +8,7 @@ module Cb
8
8
  def self.join_form_questions(tndid)
9
9
  ## Load the join form questions for a TalentNetworkDID
10
10
  my_api = Cb::Utils::Api.new()
11
- json_hash = my_api.cb_get_secure("#{Cb.configuration.uri_tn_join_questions}/#{tndid}/json")
11
+ json_hash = my_api.cb_get("#{Cb.configuration.uri_tn_join_questions}/#{tndid}/json")
12
12
 
13
13
  tn_questions_collection = TalentNetwork.new(json_hash)
14
14
  my_api.append_api_responses(tn_questions_collection, json_hash)
@@ -20,7 +20,7 @@ module Cb
20
20
  ## Gets branding information (stylesheets, copytext, etc...) for the join form.
21
21
  my_api = Cb::Utils::Api.new
22
22
 
23
- json_hash = my_api.cb_get_secure("#{Cb.configuration.uri_tn_join_form_branding}/#{tndid}/json")
23
+ json_hash = my_api.cb_get("#{Cb.configuration.uri_tn_join_form_branding}/#{tndid}/json")
24
24
 
25
25
  if json_hash.has_key? 'Branding'
26
26
  tn_join_form_branding = TalentNetwork::JoinFormBranding.new(json_hash['Branding'])
@@ -35,7 +35,7 @@ module Cb
35
35
  def self.join_form_geography(tnlanguage="USEnglish")
36
36
  ## Gets locations needed to fill the Geography question from the Join Form Question API
37
37
  my_api = Cb::Utils::Api.new
38
- json_hash = my_api.cb_get_secure("#{Cb.configuration.uri_tn_join_form_geo}", :query=>{:TNLanguage=>"#{tnlanguage}"})
38
+ json_hash = my_api.cb_get("#{Cb.configuration.uri_tn_join_form_geo}", :query=>{:TNLanguage=>"#{tnlanguage}"})
39
39
 
40
40
  geo_dropdown = TalentNetwork::JoinFormGeo.new(json_hash)
41
41
  my_api.append_api_responses(geo_dropdown, json_hash)
@@ -55,7 +55,7 @@ module Cb
55
55
 
56
56
  def self.tn_job_information(job_did, join_form_intercept="true")
57
57
  my_api = Cb::Utils::Api.new
58
- json_hash = my_api.cb_get_secure("#{Cb.configuration.uri_tn_job_info}/#{job_did}/json", :query=> {
58
+ json_hash = my_api.cb_get("#{Cb.configuration.uri_tn_job_info}/#{job_did}/json", :query=> {
59
59
  :RequestJoinFormIntercept=>join_form_intercept})
60
60
 
61
61
  if json_hash.has_key? 'Response'
@@ -1,6 +1,6 @@
1
1
  module Cb
2
2
  class Config
3
- attr_accessor :dev_key, :base_uri, :base_uri_secure, :debug_api, :time_out, :use_json, :host_site,
3
+ attr_accessor :dev_key, :base_uri, :debug_api, :time_out, :use_json, :host_site,
4
4
  :uri_job_search, :uri_job_find,
5
5
  :uri_company_find, :uri_job_category_search,
6
6
  :uri_education_code, :uri_employee_types,
@@ -108,14 +108,17 @@ module Cb
108
108
  }
109
109
  end
110
110
 
111
+ def set_base_uri (uri)
112
+ @base_uri = uri
113
+ end
114
+
111
115
  protected
112
116
  #################################################################
113
117
 
114
118
  def set_defaults
115
119
 
116
120
  @dev_key = 'ruby-cb-api' # Get a developer key at http://api.careerbuilder.com
117
- @base_uri = 'http://api.careerbuilder.com'
118
- @base_uri_secure = 'https://api.careerbuilder.com'
121
+ @base_uri = 'https://api.careerbuilder.com'
119
122
  @debug_api = false
120
123
  @time_out = 5
121
124
  @use_json = true
@@ -1,7 +1,7 @@
1
1
  module Cb
2
2
  class CbJobBranding
3
3
 
4
- attr_accessor :name, :media, :sections, :styles, :widgets, :id, :account_id, :type, :errors, :show_widgets
4
+ attr_accessor :name, :media, :sections, :styles, :widgets, :id, :account_id, :type, :errors, :show_widgets, :company_description
5
5
 
6
6
  def initialize args = {}
7
7
  @name = args['Name'] || ''
@@ -11,9 +11,9 @@ module Cb
11
11
  @media = Cb::Branding::Media.new args['Media']
12
12
  @styles = Cb::Branding::Style.new args['Styles']
13
13
  @errors = args['Errors'] || ''
14
-
14
+ @company_description = args['CompanyDescription'] || ''
15
15
  @sections, @widgets = [], []
16
-
16
+
17
17
  args['Sections'].each do |type, sections|
18
18
  @sections << Cb::Branding::Section.new(type, sections) unless sections.nil?
19
19
  end
@@ -25,6 +25,7 @@ module Cb
25
25
  @widgets << Cb::Branding::Widget.new(type, url) unless url.nil?
26
26
  end
27
27
  end
28
+
28
29
  end
29
30
 
30
31
  end
@@ -5,7 +5,7 @@ module Cb
5
5
  class Api
6
6
  include HTTParty
7
7
 
8
- base_uri 'http://api.careerbuilder.com'
8
+ base_uri 'https://api.careerbuilder.com'
9
9
 
10
10
  def initialize
11
11
  self.class.debug_output $stderr if Cb.configuration.debug_api
@@ -25,7 +25,7 @@ module Cb
25
25
  end
26
26
 
27
27
  def cb_post(*args, &block)
28
- self.class.base_uri Cb.configuration.base_uri_secure
28
+ self.class.base_uri Cb.configuration.base_uri
29
29
  response = self.class.post(*args, &block)
30
30
  validated_response = ResponseValidator.validate(response)
31
31
  set_api_error(validated_response)
@@ -33,15 +33,6 @@ module Cb
33
33
  return validated_response
34
34
  end
35
35
 
36
- def cb_get_secure(*args, &block)
37
- self.class.base_uri Cb.configuration.base_uri_secure
38
- response = self.class.get(*args, &block)
39
- validated_response = ResponseValidator.validate(response)
40
- set_api_error(validated_response)
41
-
42
- return validated_response
43
- end
44
-
45
36
  def append_api_responses(obj, resp)
46
37
  if obj.respond_to?('cb_response')
47
38
  meta_class = obj.cb_response
@@ -1,3 +1,3 @@
1
1
  module Cb
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.3'
3
3
  end
@@ -0,0 +1,86 @@
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
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.1
4
+ version: 1.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -242,6 +242,7 @@ files:
242
242
  - lib/cb/utils/validator.rb
243
243
  - lib/cb/version.rb
244
244
  - lib/cb.rb
245
+ - lib/memory.rb
245
246
  - README.md
246
247
  homepage: http://api.careerbuilder.com
247
248
  licenses:
@@ -264,7 +265,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
264
265
  version: '0'
265
266
  requirements: []
266
267
  rubyforge_project:
267
- rubygems_version: 1.8.23
268
+ rubygems_version: 1.8.28
268
269
  signing_key:
269
270
  specification_version: 3
270
271
  summary: Ruby wrapper around Careerbuilder Public API.