Skip to content

Commit 796be8a

Browse files
committed
Fix build.
1 parent 7bf249f commit 796be8a

6 files changed

+39
-41
lines changed

test/simplecov.rb .simplecov

File renamed without changes.

Gemfile.lock

+9-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
PATH
22
remote: .
33
specs:
4-
fhir_client (1.6.0)
4+
fhir_client (1.6.1)
55
activesupport (>= 3)
66
addressable (>= 2.3)
7-
fhir_models (>= 1.6.0)
7+
fhir_models (>= 1.6.1)
88
oauth2 (~> 1.1)
9+
rack (~> 1.6)
910
rest-client (~> 1.8)
1011
tilt (>= 1.1)
1112

@@ -30,7 +31,7 @@ GEM
3031
unf (>= 0.0.5, < 1.0.0)
3132
faraday (0.9.2)
3233
multipart-post (>= 1.2, < 3)
33-
fhir_models (1.6.0)
34+
fhir_models (1.6.1)
3435
bcp47 (>= 0.3)
3536
date_time_precision (>= 0.8)
3637
mime-types (>= 1.16, < 3)
@@ -39,7 +40,7 @@ GEM
3940
http-cookie (1.0.2)
4041
domain_name (~> 0.5)
4142
i18n (0.7.0)
42-
json (1.8.2)
43+
json (2.0.2)
4344
jwt (1.5.4)
4445
method_source (0.8.2)
4546
mime-types (2.99.2)
@@ -69,9 +70,9 @@ GEM
6970
http-cookie (>= 1.0.2, < 2.0)
7071
mime-types (>= 1.16, < 3.0)
7172
netrc (~> 0.7)
72-
simplecov (0.10.0)
73+
simplecov (0.12.0)
7374
docile (~> 1.1.0)
74-
json (~> 1.8)
75+
json (>= 1.8, < 3)
7576
simplecov-html (~> 0.10.0)
7677
simplecov-html (0.10.0)
7778
slop (3.6.0)
@@ -80,7 +81,7 @@ GEM
8081
turn (0.9.7)
8182
ansi
8283
minitest (~> 4)
83-
tzinfo (0.3.49)
84+
tzinfo (0.3.51)
8485
unf (0.1.4)
8586
unf_ext
8687
unf_ext (0.0.7.2)
@@ -97,4 +98,4 @@ DEPENDENCIES
9798
turn
9899

99100
BUNDLED WITH
100-
1.11.2
101+
1.12.5

fhir_client.gemspec

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ Gem::Specification.new do |s|
77
s.email = "[email protected]"
88
s.homepage = "https://github.com/hl7-fhir/fhir-svn"
99
s.authors = ["Andre Quina", "Jason Walonoski", "Janoo Fernandes"]
10-
s.version = '1.6.0'
10+
s.version = '1.6.1'
1111

1212
s.files = s.files = `git ls-files`.split("\n")
1313

14-
s.add_dependency 'fhir_models', '>= 1.6.0'
14+
s.add_dependency 'fhir_models', '>= 1.6.1'
1515
s.add_dependency 'tilt', '>= 1.1'
1616
s.add_dependency 'rest-client', '~> 1.8'
1717
s.add_dependency 'oauth2', '~> 1.1'
1818
s.add_dependency 'activesupport', '>= 3'
1919
s.add_dependency 'addressable', '>= 2.3'
20+
s.add_dependency 'rack', '~> 1.6'
2021
s.add_development_dependency 'pry'
2122
end
2223

lib/client_interface.rb

+26-26
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class Client
3030
# @return
3131
#
3232
def initialize(baseServiceUrl)
33-
$LOG.info "Initializing client with #{@baseServiceUrl}"
33+
FHIR.logger.info "Initializing client with #{@baseServiceUrl}"
3434
@baseServiceUrl = baseServiceUrl
3535
@use_format_param = false
3636
@default_format = FHIR::Formats::ResourceFormat::RESOURCE_XML
@@ -40,7 +40,7 @@ def initialize(baseServiceUrl)
4040

4141
# Set the client to use no authentication mechanisms
4242
def set_no_auth
43-
$LOG.info "Configuring the client to use no authentication."
43+
FHIR.logger.info "Configuring the client to use no authentication."
4444
@use_oauth2_auth = false
4545
@use_basic_auth = false
4646
@security_headers = {}
@@ -49,7 +49,7 @@ def set_no_auth
4949

5050
# Set the client to use HTTP Basic Authentication
5151
def set_basic_auth(client,secret)
52-
$LOG.info "Configuring the client to use HTTP Basic authentication."
52+
FHIR.logger.info "Configuring the client to use HTTP Basic authentication."
5353
token = Base64.encode64("#{client}:#{secret}")
5454
value = "Basic #{token}"
5555
@security_headers = { 'Authorization' => value }
@@ -60,7 +60,7 @@ def set_basic_auth(client,secret)
6060

6161
# Set the client to use Bearer Token Authentication
6262
def set_bearer_token(token)
63-
$LOG.info "Configuring the client to use Bearer Token authentication."
63+
FHIR.logger.info "Configuring the client to use Bearer Token authentication."
6464
value = "Bearer #{token}"
6565
@security_headers = { 'Authorization' => value }
6666
@use_oauth2_auth = false
@@ -74,7 +74,7 @@ def set_bearer_token(token)
7474
# authorizePath -- absolute path of authorization endpoint
7575
# tokenPath -- absolute path of token endpoint
7676
def set_oauth2_auth(client,secret,authorizePath,tokenPath)
77-
$LOG.info "Configuring the client to use OpenID Connect OAuth2 authentication."
77+
FHIR.logger.info "Configuring the client to use OpenID Connect OAuth2 authentication."
7878
@use_oauth2_auth = true
7979
@use_basic_auth = false
8080
@security_headers = {}
@@ -146,7 +146,7 @@ def get_oauth2_metadata_from_conformance
146146
end
147147
end
148148
rescue Exception => e
149-
$LOG.error 'Failed to locate SMART-on-FHIR OAuth2 Security Extensions.'
149+
FHIR.logger.error 'Failed to locate SMART-on-FHIR OAuth2 Security Extensions.'
150150
end
151151
options.delete_if{|k,v|v.nil?}
152152
options.clear if options.keys.size!=2
@@ -199,15 +199,15 @@ def fhir_headers(options={})
199199
end
200200

201201
def parse_reply(klass, format, response)
202-
$LOG.info "Parsing response with {klass: #{klass}, format: #{format}, code: #{response.code}}."
202+
FHIR.logger.info "Parsing response with {klass: #{klass}, format: #{format}, code: #{response.code}}."
203203
return nil if ![200,201].include? response.code
204204
res = nil
205205
begin
206206
res = FHIR.from_contents(response.body)
207207
res.client = self if !res.nil?
208-
$LOG.warn "Expected #{klass} but got #{res.class}" if res.class!=klass
208+
FHIR.logger.warn "Expected #{klass} but got #{res.class}" if res.class!=klass
209209
rescue Exception => e
210-
$LOG.error "Failed to parse #{format} as resource #{klass}: #{e.message} %n #{e.backtrace.join("\n")} #{response}"
210+
FHIR.logger.error "Failed to parse #{format} as resource #{klass}: #{e.message} %n #{e.backtrace.join("\n")} #{response}"
211211
nil
212212
end
213213
res
@@ -290,7 +290,7 @@ def scrubbed_response_headers(result)
290290

291291
def get(path, headers)
292292
url = URI(build_url(path)).to_s
293-
$LOG.info "GETTING: #{url}"
293+
FHIR.logger.info "GETTING: #{url}"
294294
headers = clean_headers(headers)
295295
if @use_oauth2_auth
296296
# @client.refresh!
@@ -311,7 +311,7 @@ def get(path, headers)
311311
:headers => response.headers,
312312
:body => response.body
313313
}
314-
$LOG.info "GET - Request: #{req.to_s}, Response: #{response.body.force_encoding("UTF-8")}"
314+
FHIR.logger.info "GET - Request: #{req.to_s}, Response: #{response.body.force_encoding("UTF-8")}"
315315
@reply = FHIR::ClientReply.new(req, res)
316316
else
317317
headers.merge!(@security_headers) if @use_basic_auth
@@ -321,7 +321,7 @@ def get(path, headers)
321321
response = e.response if e.response
322322
end
323323

324-
$LOG.info "GET - Request: #{response.request.to_json}, Response: #{response.body.force_encoding("UTF-8")}"
324+
FHIR.logger.info "GET - Request: #{response.request.to_json}, Response: #{response.body.force_encoding("UTF-8")}"
325325
response.request.args[:path] = response.request.args[:url].gsub(@baseServiceUrl,'')
326326
headers = response.headers.inject({}){ |h,(k,v)| h[k.to_s.gsub('_','-')] = v.to_s; h}
327327
res = {
@@ -336,7 +336,7 @@ def get(path, headers)
336336

337337
def post(path, resource, headers)
338338
url = URI(build_url(path)).to_s
339-
$LOG.info "POSTING: #{url}"
339+
FHIR.logger.info "POSTING: #{url}"
340340
headers = clean_headers(headers)
341341
payload = request_payload(resource, headers) if resource
342342
if @use_oauth2_auth
@@ -358,12 +358,12 @@ def post(path, resource, headers)
358358
:headers => response.headers,
359359
:body => response.body
360360
}
361-
$LOG.info "POST - Request: #{req.to_s}, Response: #{response.body.force_encoding("UTF-8")}"
361+
FHIR.logger.info "POST - Request: #{req.to_s}, Response: #{response.body.force_encoding("UTF-8")}"
362362
@reply = FHIR::ClientReply.new(req, res)
363363
else
364364
headers.merge!(@security_headers) if @use_basic_auth
365365
@client.post(url, payload, headers){ |response, request, result|
366-
$LOG.info "POST - Request: #{request.to_json}, Response: #{response.force_encoding("UTF-8")}"
366+
FHIR.logger.info "POST - Request: #{request.to_json}, Response: #{response.force_encoding("UTF-8")}"
367367
request.args[:path] = url.gsub(@baseServiceUrl,'')
368368
res = {
369369
:code => result.code,
@@ -377,7 +377,7 @@ def post(path, resource, headers)
377377

378378
def put(path, resource, headers)
379379
url = URI(build_url(path)).to_s
380-
$LOG.info "PUTTING: #{url}"
380+
FHIR.logger.info "PUTTING: #{url}"
381381
headers = clean_headers(headers)
382382
payload = request_payload(resource, headers) if resource
383383
if @use_oauth2_auth
@@ -399,12 +399,12 @@ def put(path, resource, headers)
399399
:headers => response.headers,
400400
:body => response.body
401401
}
402-
$LOG.info "PUT - Request: #{req.to_s}, Response: #{response.body.force_encoding("UTF-8")}"
402+
FHIR.logger.info "PUT - Request: #{req.to_s}, Response: #{response.body.force_encoding("UTF-8")}"
403403
@reply = FHIR::ClientReply.new(req, res)
404404
else
405405
headers.merge!(@security_headers) if @use_basic_auth
406406
@client.put(url, payload, headers){ |response, request, result|
407-
$LOG.info "PUT - Request: #{request.to_json}, Response: #{response.force_encoding("UTF-8")}"
407+
FHIR.logger.info "PUT - Request: #{request.to_json}, Response: #{response.force_encoding("UTF-8")}"
408408
request.args[:path] = url.gsub(@baseServiceUrl,'')
409409
res = {
410410
:code => result.code,
@@ -418,7 +418,7 @@ def put(path, resource, headers)
418418

419419
def patch(path, patchset, headers)
420420
url = URI(build_url(path)).to_s
421-
$LOG.info "PATCHING: #{url}"
421+
FHIR.logger.info "PATCHING: #{url}"
422422
headers = clean_headers(headers)
423423
payload = request_patch_payload(patchset, headers['format'])
424424
if @use_oauth2_auth
@@ -440,13 +440,13 @@ def patch(path, patchset, headers)
440440
:headers => response.headers,
441441
:body => response.body
442442
}
443-
$LOG.info "PATCH - Request: #{req.to_s}, Response: #{response.body.force_encoding("UTF-8")}"
443+
FHIR.logger.info "PATCH - Request: #{req.to_s}, Response: #{response.body.force_encoding("UTF-8")}"
444444
@reply = FHIR::ClientReply.new(req, res)
445445
else
446446
headers.merge!(@security_headers) if @use_basic_auth
447447
# url = 'http://requestb.in/o8juy3o8'
448448
@client.patch(url, payload, headers){ |response, request, result|
449-
$LOG.info "PATCH - Request: #{request.to_json}, Response: #{response.force_encoding("UTF-8")}"
449+
FHIR.logger.info "PATCH - Request: #{request.to_json}, Response: #{response.force_encoding("UTF-8")}"
450450
request.args[:path] = url.gsub(@baseServiceUrl,'')
451451
res = {
452452
:code => result.code,
@@ -460,7 +460,7 @@ def patch(path, patchset, headers)
460460

461461
def delete(path, headers)
462462
url = URI(build_url(path)).to_s
463-
$LOG.info "DELETING: #{url}"
463+
FHIR.logger.info "DELETING: #{url}"
464464
headers = clean_headers(headers)
465465
if @use_oauth2_auth
466466
# @client.refresh!
@@ -481,12 +481,12 @@ def delete(path, headers)
481481
:headers => response.headers,
482482
:body => response.body
483483
}
484-
$LOG.info "DELETE - Request: #{req.to_s}, Response: #{response.body.force_encoding("UTF-8")}"
484+
FHIR.logger.info "DELETE - Request: #{req.to_s}, Response: #{response.body.force_encoding("UTF-8")}"
485485
@reply = FHIR::ClientReply.new(req, res)
486486
else
487487
headers.merge!(@security_headers) if @use_basic_auth
488488
@client.delete(url, headers){ |response, request, result|
489-
$LOG.info "DELETE - Request: #{request.to_json}, Response: #{response.force_encoding("UTF-8")}"
489+
FHIR.logger.info "DELETE - Request: #{request.to_json}, Response: #{response.force_encoding("UTF-8")}"
490490
request.args[:path] = url.gsub(@baseServiceUrl,'')
491491
res = {
492492
:code => result.code,
@@ -501,9 +501,9 @@ def delete(path, headers)
501501
def head(path, headers)
502502
headers.merge!(@security_headers) unless @security_headers.blank?
503503
url = URI(build_url(path)).to_s
504-
$LOG.info "HEADING: #{url}"
504+
FHIR.logger.info "HEADING: #{url}"
505505
RestClient.head(url, headers){ |response, request, result|
506-
$LOG.info "HEAD - Request: #{request.to_json}, Response: #{response.force_encoding("UTF-8")}"
506+
FHIR.logger.info "HEAD - Request: #{request.to_json}, Response: #{response.force_encoding("UTF-8")}"
507507
request.args[:path] = url.gsub(@baseServiceUrl,'')
508508
res = {
509509
:code => result.code,

lib/fhir_client.rb

-4
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,6 @@
99
require 'oauth2'
1010
require 'active_support/core_ext'
1111

12-
# Simple and verbose loggers
13-
RestClient.log = Logger.new("fhir_client.log", 10, 1024000)
14-
$LOG = Logger.new("fhir_client_verbose.log", 10, 1024000)
15-
1612
root = File.expand_path '..', File.dirname(File.absolute_path(__FILE__))
1713
Dir.glob(File.join(root, 'lib','sections','**','*.rb')).each do |file|
1814
require file

test/test_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require_relative "./simplecov"
1+
require 'simplecov'
22
require_relative '../lib/fhir_client'
33

44
require 'pry'

0 commit comments

Comments
 (0)