diff --git a/lib/orthanc.rb b/lib/orthanc.rb index 1fb527d..0a96b2e 100644 --- a/lib/orthanc.rb +++ b/lib/orthanc.rb @@ -1,5 +1,6 @@ require "orthanc/version" +require 'json' require 'rest-client' require 'recursive-open-struct' require 'plissken' diff --git a/lib/orthanc/client.rb b/lib/orthanc/client.rb index 7fdd8dd..3e24bcb 100644 --- a/lib/orthanc/client.rb +++ b/lib/orthanc/client.rb @@ -17,8 +17,16 @@ class Client include Response attr_accessor :base_uri - def initialize(host = "localhost", port = 8042) - self.base_uri = RestClient::Resource.new("http://#{host}:#{port}") + def initialize(host = "localhost", port = 8042, user = "", password = "") + host = ENV['ORTHANC_HOST'] if ENV['ORTHANC_HOST'] != nil + port = ENV['ORTHANC_PORT'] if ENV['ORTHANC_PORT'] != nil + user = ENV['ORTHANC_USER'] if ENV['ORTHANC_USER'] != nil + password = ENV['ORTHANC_PASSWORD'] if ENV['ORTHANC_PASSWORD'] != nil + if user != "" && password != "" + self.base_uri = RestClient::Resource.new("http://#{host}:#{port}", user, password) + else + self.base_uri = RestClient::Resource.new("http://#{host}:#{port}") + end end # ------------- General ------------- diff --git a/orthanc.gemspec b/orthanc.gemspec index 26af8d8..3d0851a 100644 --- a/orthanc.gemspec +++ b/orthanc.gemspec @@ -19,11 +19,11 @@ Gem::Specification.new do |spec| spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_development_dependency "bundler", "~> 1.9" - spec.add_development_dependency "rake", "~> 10.0" + spec.add_development_dependency "bundler", "~> 2.5" + spec.add_development_dependency "rake", "~> 13.2" - spec.add_dependency 'rest-client', "~> 1.8" - spec.add_dependency 'recursive-open-struct', "~> 0.6.3" + spec.add_dependency 'rest-client', "~> 2.1.0" + spec.add_dependency 'recursive-open-struct', "~> 1.1.3" spec.add_dependency 'plissken', "~> 0.2.0" end