Skip to content

Commit b92e2c5

Browse files
authored
Merge pull request #300 from ekopranototjoa/rubyv3
Update to Ruby v3.0
2 parents 051da6f + 4ede114 commit b92e2c5

16 files changed

+44
-40
lines changed

cb-api.gemspec

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
1+
$LOAD_PATH.push File.expand_path('lib', __dir__)
22

33
require 'cb/version'
44

@@ -17,17 +17,17 @@ Gem::Specification.new do |s|
1717
s.require_path = 'lib'
1818

1919
s.add_dependency 'httparty', '~> 0.11'
20-
s.add_dependency 'json', '~> 1.7', '>= 1.7.7'
20+
s.add_dependency 'json', '~> 2.3', '>= 2.3.0'
2121
s.add_dependency 'nori', '~> 2.2'
2222
s.add_dependency 'nokogiri', '~> 1.0'
2323

2424
s.add_development_dependency 'rake', '>= 0.8.7'
25-
s.add_development_dependency 'webmock', '~> 1.9'
25+
s.add_development_dependency 'webmock', '~> 3.14'
2626
s.add_development_dependency 'simplecov', '>= 0.7.1'
2727
s.add_development_dependency 'rspec', '~> 3.4'
28-
s.add_development_dependency 'rdoc', '~> 3.12.2'
28+
s.add_development_dependency 'rdoc', '~> 6.4'
2929
s.add_development_dependency 'rspec-pride', '~> 3.0'
30-
s.add_development_dependency 'pry', '0.9.12.1'
30+
s.add_development_dependency 'pry', '0.14.1'
3131
s.add_development_dependency 'rb-readline', '~> 0.5.0'
3232
s.add_development_dependency 'codeclimate-test-reporter'
3333
end

lib/cb/clients/base.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ def cb_client(headers: {}, use_default_params: true)
1616
@cb_client ||= Cb::Utils::Api.instance(headers: headers, use_default_params: use_default_params)
1717
end
1818

19-
def headers(args, accept_header: 'application/json')
19+
def headers(accept_header: 'application/json', **args)
2020
{
21-
'Accept' => accept_header,
22-
'Authorization' => "Bearer #{ args[:oauth_token] }",
23-
'Content-Type' => 'application/json'
21+
'Accept' => accept_header,
22+
'Authorization' => "Bearer #{args[:oauth_token]}",
23+
'Content-Type' => 'application/json'
2424
}
2525
end
2626
end

lib/cb/clients/browser_id.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class BrowserID < Base
1515
class << self
1616
# https://careerbuilder.readme.io/docs/consumerbrowser-id
1717
def get(args={})
18-
cb_client.cb_get(Cb.configuration.uri_browser_id, headers: headers(args))
18+
cb_client.cb_get(Cb.configuration.uri_browser_id, headers: headers(**args))
1919
end
2020
end
2121
end

lib/cb/clients/cover_letters.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ class << self
1616
def get(args={})
1717
uri = Cb.configuration.uri_cover_letters
1818
uri += "/#{ args[:id] }" if args[:id]
19-
cb_client.cb_get(uri, headers: headers(args))
19+
cb_client.cb_get(uri, headers: headers(**args))
2020
end
2121

2222
def create(args={})
2323
cb_client.cb_put(Cb.configuration.uri_cover_letters,
2424
body: body(args),
25-
headers: headers(args))
25+
headers: headers(**args))
2626
end
2727

2828
def delete(args={})
29-
cb_client.cb_delete(uri_with_id(args), body: body(args), headers: headers(args))
29+
cb_client.cb_delete(uri_with_id(args), body: body(args), headers: headers(**args))
3030
end
3131

3232
def update(args={})
33-
cb_client.cb_post(uri_with_id(args), body: body(args), headers: headers(args))
33+
cb_client.cb_post(uri_with_id(args), body: body(args), headers: headers(**args))
3434
end
3535

3636
private

lib/cb/clients/email_subscriptions.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module Clients
1414
class EmailSubscriptions < Base
1515
class << self
1616
def get(args = {})
17-
cb_client.cb_get(Cb.configuration.uri_subscription_retrieve, query: query(args), headers: headers(args))
17+
cb_client.cb_get(Cb.configuration.uri_subscription_retrieve, query: query(args), headers: headers(**args))
1818
end
1919

2020
def post(args = {})
@@ -32,7 +32,7 @@ def query(args = {})
3232
end
3333

3434
def post_headers(args = {})
35-
headers(args).merge('Content-Type' => 'application/xml')
35+
headers(**args).merge('Content-Type' => 'application/xml')
3636
end
3737

3838
def body(args = {})

lib/cb/clients/expired_job.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ExpiredJob < Base
1616
def self.get(args={})
1717
uri = Cb.configuration.uri_job_expired
1818
query_params = { 'JobDID' => args[:job_did] }
19-
cb_client.cb_get(uri, headers: headers(args), query: query_params)
19+
cb_client.cb_get(uri, headers: headers(**args), query: query_params)
2020
end
2121
end
2222
end

lib/cb/clients/job_insights.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module Clients
1414
class JobInsights < Base
1515
def self.get(args={})
1616
uri = "#{ Cb.configuration.uri_job_insights }/#{ args[:id] }"
17-
cb_client.cb_get(uri, headers: headers(args))
17+
cb_client.cb_get(uri, headers: headers(**args))
1818
end
1919
end
2020
end

lib/cb/clients/resume_insights.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module Clients
1414
class ResumeInsights < Base
1515
def self.keywords(args={})
1616
uri = "#{ Cb.configuration.uri_keyword_insights }/#{ args[:id] }"
17-
cb_client.cb_get(uri, headers: headers(args))
17+
cb_client.cb_get(uri, headers: headers(**args))
1818
end
1919
end
2020
end

lib/cb/clients/saved_jobs.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@ class << self
1616
def get(args = {})
1717
uri = Cb.configuration.uri_saved_job
1818
uri += "/#{ args[:id] }" if args[:id]
19-
cb_client.cb_get(uri, headers: headers(args))
19+
cb_client.cb_get(uri, headers: headers(**args))
2020
end
2121

2222
def create(args = {})
2323
cb_client.cb_put(Cb.configuration.uri_saved_job,
2424
body: body(args),
25-
headers: headers(args))
25+
headers: headers(**args))
2626
end
2727

2828
def delete(args = {})
29-
cb_client.cb_delete(uri_with_id(args), body: body(args), headers: headers(args))
29+
cb_client.cb_delete(uri_with_id(args), body: body(args), headers: headers(**args))
3030
end
3131

3232
def update(args = {})
33-
cb_client.cb_post(uri_with_id(args), body: body(args), headers: headers(args))
33+
cb_client.cb_post(uri_with_id(args), body: body(args), headers: headers(**args))
3434
end
3535

3636
private

lib/cb/clients/user_profile.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class UserProfile < Base
1515
class << self
1616
# https://careerbuilder.readme.io/docs/consumeruser-profile
1717
def get(args={})
18-
cb_client.cb_get(Cb.configuration.uri_user_profile, headers: headers(args))
18+
cb_client.cb_get(Cb.configuration.uri_user_profile, headers: headers(**args))
1919
end
2020
end
2121
end

lib/cb/utils/validator.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ def process_response_body(response)
5353
end
5454

5555
def try_parse_json(body)
56-
JSON.parse(body)
56+
json = JSON.parse(body)
57+
json = try_parse_json(json) if json.is_a? String
58+
json
5759
rescue JSON::ParserError
5860
nil
5961
end

lib/cb/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@
99
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1010
# See the License for the specific language governing permissions and limitations under the License.
1111
module Cb
12-
VERSION = '23.2.1'
12+
VERSION = '24.0'
1313
end

spec/cb/client_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ module Cb
6161

6262
it 'should call the api using post' do
6363
expect(mock_api).to receive(:timed_http_request)
64-
.with(:post, base_uri, 'parts unknown', query: nil, headers: nil, body: nil)
64+
.with(:post, base_uri, 'parts unknown', { query: nil, headers: nil, body: nil })
6565
.and_return({})
6666

6767
@client.execute(@request)
@@ -80,7 +80,7 @@ module Cb
8080

8181
it 'should call the api using get' do
8282
expect(mock_api).to receive(:timed_http_request)
83-
.with(:get, base_uri, 'parts unknown', query: nil, headers: nil, body: nil)
83+
.with(:get, base_uri, 'parts unknown', { query: nil, headers: nil, body: nil })
8484
.and_return({})
8585

8686
@client.execute(@request)
@@ -99,7 +99,7 @@ module Cb
9999

100100
it 'should call the api using put' do
101101
expect(mock_api).to receive(:timed_http_request)
102-
.with(:put, base_uri, 'parts unknown', query: nil, headers: nil, body: nil)
102+
.with(:put, base_uri, 'parts unknown', { query: nil, headers: nil, body: nil })
103103
.and_return({})
104104

105105
@client.execute(@request)
@@ -125,7 +125,7 @@ module Cb
125125

126126
it 'should call the api using post' do
127127
expect(mock_api).to receive(:timed_http_request)
128-
.with(:post, base_uri, 'parts unknown', query: nil, headers: nil, body: nil)
128+
.with(:post, base_uri, 'parts unknown', { query: nil, headers: nil, body: nil })
129129
.and_yield('test')
130130
.and_return({})
131131

@@ -145,7 +145,7 @@ module Cb
145145

146146
it 'should call the api using get' do
147147
expect(mock_api).to receive(:timed_http_request)
148-
.with(:get, base_uri, 'parts unknown', query: nil, headers: nil, body: nil)
148+
.with(:get, base_uri, 'parts unknown', { query: nil, headers: nil, body: nil })
149149
.and_yield('test')
150150
.and_return({})
151151

@@ -165,7 +165,7 @@ module Cb
165165

166166
it 'should call the api using put' do
167167
expect(mock_api).to receive(:timed_http_request)
168-
.with(:put, base_uri, 'parts unknown', query: nil, headers: nil, body: nil)
168+
.with(:put, base_uri, 'parts unknown', { query: nil, headers: nil, body: nil })
169169
.and_yield('test')
170170
.and_return({})
171171

spec/cb/clients/base_client_spec.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,17 @@ module Cb
2525
end
2626

2727
it 'defaults Accept to application/json' do
28-
headers = Cb::Clients::Base.headers({})
28+
headers = Cb::Clients::Base.headers()
2929
expect(headers['Accept']).to eq 'application/json'
3030
end
3131

3232
it 'accepts an optional param to change Accept header' do
33-
headers = Cb::Clients::Base.headers({}, accept_header: 'application/json;version=1.1')
33+
headers = Cb::Clients::Base.headers(accept_header: 'application/json;version=1.1')
3434
expect(headers['Accept']).to eq 'application/json;version=1.1'
3535
end
3636

3737
it 'defaults Content-Type to application/json' do
38-
headers = Cb::Clients::Base.headers({})
38+
headers = Cb::Clients::Base.headers()
3939
expect(headers['Content-Type']).to eq 'application/json'
4040
end
4141
end

spec/spec_helper.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,12 @@
1717
add_group 'clients', 'lib/cb/clients'
1818
add_group 'criteria', 'lib/cb/criteria'
1919
add_group 'responses', 'lib/cb/responses'
20-
formatter SimpleCov::Formatter::MultiFormatter[
21-
SimpleCov::Formatter::HTMLFormatter,
22-
CodeClimate::TestReporter::Formatter
23-
]
20+
formatter SimpleCov::Formatter::MultiFormatter.new(
21+
[
22+
SimpleCov::Formatter::HTMLFormatter,
23+
# CodeClimate::TestReporter::Formatter
24+
]
25+
)
2426
end
2527

2628
require 'rubygems'

spec/support/response_stubs/application.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@ Results:
2929
ExternalUserID: XR******************
3030
redirectURL:
3131
Errors: []
32-
Timestamp: 2013-12-05T14:02:51.9490777-05:00
32+
Timestamp: '2013-12-05T14:02:51.9490777-05:00'
3333
Status: Success

0 commit comments

Comments
 (0)