career_builder 0.2.1 → 0.2.2

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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.1
1
+ 0.2.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{career_builder}
8
- s.version = "0.2.1"
8
+ s.version = "0.2.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Michael Guterl"]
12
- s.date = %q{2011-04-04}
12
+ s.date = %q{2011-04-11}
13
13
  s.description = %q{Ruby wrapper for the CareerBuilder V2 HTTP XML API}
14
14
  s.email = %q{mguterl@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -51,7 +51,9 @@ Gem::Specification.new do |s|
51
51
  "spec/career_builder/client/authentication_spec.rb",
52
52
  "spec/career_builder/client/get_resume_spec.rb",
53
53
  "spec/career_builder/client/resume_actions_remaining_today_spec.rb",
54
+ "spec/career_builder/client_spec.rb",
54
55
  "spec/career_builder/resume/lazy_collection_spec.rb",
56
+ "spec/career_builder/resume_spec.rb",
55
57
  "spec/career_builder_spec.rb",
56
58
  "spec/spec.opts",
57
59
  "spec/spec_helper.rb",
@@ -66,7 +68,9 @@ Gem::Specification.new do |s|
66
68
  "spec/career_builder/client/authentication_spec.rb",
67
69
  "spec/career_builder/client/get_resume_spec.rb",
68
70
  "spec/career_builder/client/resume_actions_remaining_today_spec.rb",
71
+ "spec/career_builder/client_spec.rb",
69
72
  "spec/career_builder/resume/lazy_collection_spec.rb",
73
+ "spec/career_builder/resume_spec.rb",
70
74
  "spec/career_builder_spec.rb",
71
75
  "spec/spec_helper.rb",
72
76
  "spec/support/webmock.rb"
@@ -16,9 +16,18 @@ module CareerBuilder
16
16
 
17
17
  attr_reader :email, :password
18
18
 
19
+ attr_accessor :connection_retry_count
20
+
21
+ DEFAULT_CONNECTION_RETRY_COUNT = 5
22
+ class << self
23
+ attr_accessor :connection_retry_count
24
+ end
25
+ self.connection_retry_count = DEFAULT_CONNECTION_RETRY_COUNT
26
+
19
27
  def initialize(email, password, options = {})
20
28
  @email, @password = email, password
21
29
  @debug = options.fetch(:debug) { false }
30
+ @connection_retry_count = options.fetch(:connection_retry_count) { Client.connection_retry_count }
22
31
  end
23
32
 
24
33
  def resumes(options = {})
@@ -2,26 +2,28 @@ module CareerBuilder
2
2
 
3
3
  class Resume < BasicObject
4
4
 
5
- attr_reader :client
6
-
7
5
  def initialize(client, partial_resume)
8
- @partial_resume = partial_resume
9
6
  @client = client
7
+ @partial_resume = partial_resume
10
8
  end
11
9
 
12
10
  def real_contact_email
13
11
  full_resume.contact_email
14
12
  end
15
-
13
+
16
14
  def home_location
17
15
  full_resume.home_location
18
16
  end
19
17
 
18
+ def full_resume
19
+ @full_resume ||= fetch_full_resume
20
+ end
21
+
20
22
  private
21
23
 
22
24
  def method_missing(meth, *args, &block)
23
- if partial_resume.respond_to?(meth)
24
- partial_resume.send(meth, *args, &block)
25
+ if @partial_resume.respond_to?(meth)
26
+ @partial_resume.send(meth, *args, &block)
25
27
  else
26
28
  if full_resume.respond_to?(meth)
27
29
  full_resume.send(meth, *args, &block)
@@ -31,12 +33,13 @@ module CareerBuilder
31
33
  end
32
34
  end
33
35
 
34
- def partial_resume
35
- @partial_resume
36
- end
37
-
38
- def full_resume
39
- @full_resume ||= client.get_resume(:resume_id => @partial_resume.id)
36
+ def fetch_full_resume
37
+ @client.get_resume(:resume_id => @partial_resume.id)
38
+ rescue Errno::ECONNRESET => e
39
+ count ||= 0
40
+ count += 1
41
+ retry unless count > @client.connection_retry_count
42
+ raise e
40
43
  end
41
44
 
42
45
  end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ describe CareerBuilder::Client do
4
+
5
+ let(:client) { CareerBuilder::Client.new('valid_username', 'valid_password') }
6
+
7
+ describe '#connection_retry_count' do
8
+
9
+ it 'has a sane default value' do
10
+ client.connection_retry_count.should == CareerBuilder::Client.connection_retry_count
11
+ end
12
+
13
+ it 'allows the value to be specified during creation' do
14
+ client = CareerBuilder::Client.new('valid_username', 'valid_password', :connection_retry_count => 1)
15
+
16
+ client.connection_retry_count.should == 1
17
+ end
18
+ end
19
+
20
+ end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ describe CareerBuilder::Resume do
4
+
5
+ context 'when fetching the full resume generates a connection error' do
6
+
7
+ let(:resume) { CareerBuilder::Resume.new(client, partial_resume) }
8
+
9
+ let(:client) { CareerBuilder::Client.new('valid_email', 'valid_password') }
10
+ let(:partial_resume) { double(:id => 42) }
11
+ let(:full_resume) { double(:contact_email => 'foo@bar.com') }
12
+
13
+ before do
14
+ client.should_receive(:get_resume).once.and_raise(Errno::ECONNRESET)
15
+ client.should_receive(:get_resume).at_most(:once).and_return(full_resume)
16
+ end
17
+
18
+ it 'retries, working around the connection errors' do
19
+ resume.real_contact_email.should == 'foo@bar.com'
20
+ end
21
+
22
+ it 'uses connection_retry_count to determine how many times to retry' do
23
+ client.connection_retry_count = 0
24
+
25
+ expect {
26
+ resume.real_contact_email
27
+ }.to raise_error(Errno::ECONNRESET)
28
+ end
29
+ end
30
+
31
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: career_builder
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 1
10
- version: 0.2.1
9
+ - 2
10
+ version: 0.2.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Michael Guterl
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-04 00:00:00 -04:00
18
+ date: 2011-04-11 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -178,7 +178,9 @@ files:
178
178
  - spec/career_builder/client/authentication_spec.rb
179
179
  - spec/career_builder/client/get_resume_spec.rb
180
180
  - spec/career_builder/client/resume_actions_remaining_today_spec.rb
181
+ - spec/career_builder/client_spec.rb
181
182
  - spec/career_builder/resume/lazy_collection_spec.rb
183
+ - spec/career_builder/resume_spec.rb
182
184
  - spec/career_builder_spec.rb
183
185
  - spec/spec.opts
184
186
  - spec/spec_helper.rb
@@ -222,7 +224,9 @@ test_files:
222
224
  - spec/career_builder/client/authentication_spec.rb
223
225
  - spec/career_builder/client/get_resume_spec.rb
224
226
  - spec/career_builder/client/resume_actions_remaining_today_spec.rb
227
+ - spec/career_builder/client_spec.rb
225
228
  - spec/career_builder/resume/lazy_collection_spec.rb
229
+ - spec/career_builder/resume_spec.rb
226
230
  - spec/career_builder_spec.rb
227
231
  - spec/spec_helper.rb
228
232
  - spec/support/webmock.rb