allscripts_unity_client 2.0.5 → 2.1.0
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.
- checksums.yaml +4 -4
- data/README.md +20 -0
- data/allscripts_unity_client.gemspec +2 -1
- data/lib/allscripts_unity_client.rb +1 -0
- data/lib/allscripts_unity_client/client.rb +27 -20
- data/lib/allscripts_unity_client/client_driver.rb +9 -0
- data/lib/allscripts_unity_client/client_options.rb +6 -1
- data/lib/allscripts_unity_client/json_client_driver.rb +13 -10
- data/lib/allscripts_unity_client/json_unity_response.rb +0 -2
- data/lib/allscripts_unity_client/new_relic_support.rb +19 -0
- data/lib/allscripts_unity_client/soap_client_driver.rb +5 -2
- data/lib/allscripts_unity_client/version.rb +1 -1
- data/spec/allscripts_unity_client_spec.rb +2 -2
- data/spec/client_driver_spec.rb +2 -1
- data/spec/client_options_spec.rb +17 -1
- data/spec/client_spec.rb +1 -1
- data/spec/factories/client_driver_factory.rb +4 -0
- data/spec/factories/client_options.rb +1 -0
- data/spec/factories/unity_request_factory.rb +2 -0
- data/spec/factories/unity_response_factory.rb +2 -0
- data/spec/json_client_driver_spec.rb +8 -2
- data/spec/json_unity_request_spec.rb +1 -1
- data/spec/json_unity_response_spec.rb +1 -1
- data/spec/new_relic_support_spec.rb +49 -0
- data/spec/soap_client_driver_spec.rb +2 -1
- data/spec/support/new_relic.rb +16 -0
- data/spec/support/shared_examples_for_client_driver.rb +12 -0
- data/spec/timezone_spec.rb +1 -1
- data/spec/unity_request_spec.rb +1 -1
- data/spec/unity_response_spec.rb +1 -1
- data/spec/utilities_spec.rb +2 -2
- metadata +21 -8
- data/spec/factories/json_client_driver_factory.rb +0 -3
- data/spec/factories/json_unity_request_factory.rb +0 -3
- data/spec/factories/json_unity_response_factory.rb +0 -3
- data/spec/factories/soap_client_driver_factory.rb +0 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 88cc45a2484b53948ae52a7175a9c633b8cf8108
         | 
| 4 | 
            +
              data.tar.gz: c792e3083d2727be7872e47e932348699ceb416f
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 20d968b2549340bd6fc496e95bab512970db94bae8f3637d0609c0859fdf1b33f640164eee30e77da9c9f3e223c0c7de428565285a6f9d5245900e7b8e56be61
         | 
| 7 | 
            +
              data.tar.gz: 01714c07e5f1568d03b15e27f653d7c4efa8b3571b053bb5f9ebdb2b6473e651ca9116534b6a319e1106e5035ee66635fcc7d3cc6efe3ad41e1c7eec464d2090
         | 
    
        data/README.md
    CHANGED
    
    | @@ -244,6 +244,26 @@ unity_client = AllscriptsUnityClient.create({ | |
| 244 244 | 
             
            This gem uses the [american_date](http://rubygems.org/gems/american_date) gem to force `Date.parse` to
         | 
| 245 245 | 
             
            accept USA locale dates by default. There are currently no plans to support other locales. Pull requests welcome.
         | 
| 246 246 |  | 
| 247 | 
            +
            ### New Relic support
         | 
| 248 | 
            +
             | 
| 249 | 
            +
            New Relic is supported for tracing Unity HTTP requests and the overall time processing the reqeusts takes. To enable
         | 
| 250 | 
            +
            New Relic, simply require the gem in your project and enable it on the client:
         | 
| 251 | 
            +
             | 
| 252 | 
            +
            ```ruby
         | 
| 253 | 
            +
            require 'newrelic_rpm'
         | 
| 254 | 
            +
            NewRelic::Agent.manual_start
         | 
| 255 | 
            +
             | 
| 256 | 
            +
            unity_client = AllscriptsUnityClient.create({
         | 
| 257 | 
            +
              base_unity_url: "http://unity.base.url",
         | 
| 258 | 
            +
              appname: "appname",
         | 
| 259 | 
            +
              username: "username",
         | 
| 260 | 
            +
              password: "password",
         | 
| 261 | 
            +
              new_relic: true
         | 
| 262 | 
            +
            })
         | 
| 263 | 
            +
            ```
         | 
| 264 | 
            +
             | 
| 265 | 
            +
            For more information on the New Relic gem, go here: (https://github.com/newrelic/rpm)
         | 
| 266 | 
            +
             | 
| 247 267 | 
             
            ## Examples
         | 
| 248 268 |  | 
| 249 269 | 
             
            ### GetServerInfo SOAP
         | 
| @@ -29,11 +29,12 @@ Gem::Specification.new do |gem| | |
| 29 29 | 
             
              gem.add_runtime_dependency 'nokogiri', '< 1.6', '>= 1.4.0'
         | 
| 30 30 | 
             
              gem.add_runtime_dependency 'nori', '~> 2.3.0'
         | 
| 31 31 | 
             
              gem.add_runtime_dependency 'american_date', '~> 1.1.0'
         | 
| 32 | 
            +
              gem.add_runtime_dependency 'oj', '~> 2.9.8'
         | 
| 32 33 |  | 
| 33 34 | 
             
              gem.add_development_dependency 'factory_girl', '~> 4.4.0'
         | 
| 34 35 | 
             
              gem.add_development_dependency 'rake', '~> 10.3.1'
         | 
| 35 36 | 
             
              gem.add_development_dependency 'faker', '~> 1.3.0'
         | 
| 36 | 
            -
              gem.add_development_dependency 'rspec', '~> 3.0.0 | 
| 37 | 
            +
              gem.add_development_dependency 'rspec', '~> 3.0.0'
         | 
| 37 38 | 
             
              gem.add_development_dependency 'simplecov', '~> 0.8.2'
         | 
| 38 39 | 
             
              gem.add_development_dependency 'webmock', '~> 1.17.4'
         | 
| 39 40 | 
             
              gem.add_development_dependency 'coveralls', '~> 0.7.0'
         | 
| @@ -9,6 +9,7 @@ require 'allscripts_unity_client/client_driver' | |
| 9 9 | 
             
            require 'allscripts_unity_client/client_options'
         | 
| 10 10 | 
             
            require 'allscripts_unity_client/soap_client_driver'
         | 
| 11 11 | 
             
            require 'allscripts_unity_client/json_client_driver'
         | 
| 12 | 
            +
            require 'allscripts_unity_client/new_relic_support'
         | 
| 12 13 |  | 
| 13 14 | 
             
            module AllscriptsUnityClient
         | 
| 14 15 | 
             
              class APIError < RuntimeError
         | 
| @@ -501,26 +501,33 @@ module AllscriptsUnityClient | |
| 501 501 | 
             
                  # Generate XML structure for rxxml
         | 
| 502 502 | 
             
                  builder = Nokogiri::XML::Builder.new do |xml|
         | 
| 503 503 | 
             
                    xml.saverx {
         | 
| 504 | 
            -
                      xml.field('name' => 'transid', 'value' => rxxml[:transid]) unless rxxml[:transid] | 
| 505 | 
            -
                      xml.field('name' => 'PharmID', 'value' => rxxml[:pharmid]) unless rxxml[:pharmid] | 
| 506 | 
            -
                      xml.field('name' => 'DDI', 'value' => rxxml[:ddi]) unless rxxml[:ddi] | 
| 507 | 
            -
                      xml.field('name' => 'GPPCCode', 'value' => rxxml[:gppccode]) unless rxxml[:gppccode] | 
| 508 | 
            -
                      xml.field('name' => 'GPPCText', 'value' => rxxml[:gppctext]) unless rxxml[:gppctext] | 
| 509 | 
            -
                      xml.field('name' => 'GPPCCustom', 'value' => rxxml[:gppccustom]) unless rxxml[:gppccustom] | 
| 510 | 
            -
                      xml.field('name' => 'Sig', 'value' => rxxml[:sig]) unless rxxml[:sig] | 
| 511 | 
            -
                      xml.field('name' => 'QuanPresc', 'value' => rxxml[:quanpresc]) unless rxxml[:quanpresc] | 
| 512 | 
            -
                      xml.field('name' => 'Refills', 'value' => rxxml[:refills]) unless rxxml[:refills] | 
| 513 | 
            -
                      xml.field('name' => 'DAW', 'value' => rxxml[:daw]) unless rxxml[:daw] | 
| 514 | 
            -
                      xml.field('name' => 'DaysSupply', 'value' => rxxml[:dayssupply]) unless rxxml[:dayssupply] | 
| 515 | 
            -
                      xml.field('name' => 'startdate', 'value' => utc_to_local(Date.parse(rxxml[:startdate].to_s))) unless rxxml[:startdate] | 
| 516 | 
            -
                      xml.field('name' => 'historicalflag', 'value' => rxxml[:historicalflag]) unless rxxml[:historicalflag] | 
| 517 | 
            -
                      xml.field('name' => 'rxaction', 'value' => rxxml[:rxaction]) unless rxxml[:rxaction] | 
| 518 | 
            -
                      xml.field('name' => 'delivery', 'value' => rxxml[:delivery]) unless rxxml[:delivery] | 
| 519 | 
            -
                      xml.field('name' => 'ignorepharmzero', 'value' => rxxml[:ignorepharmzero]) unless rxxml[:ignorepharmzero] | 
| 520 | 
            -
                      xml.field('name' => 'orderedbyid', 'value' => rxxml[:orderedbyid]) unless rxxml[:orderedbyid] | 
| 521 | 
            -
                      xml.field('name' => 'newqty', 'value' => rxxml[:newqty]) unless rxxml[:newqty] | 
| 522 | 
            -
                      xml.field('name' => 'newrefills', 'value' => rxxml[:newrefills]) unless rxxml[:newrefills] | 
| 523 | 
            -
                      xml.field('name' => 'comments', 'value' => rxxml[:comments]) unless rxxml[:comments] | 
| 504 | 
            +
                      xml.field('name' => 'transid', 'value' => rxxml[:transid]) unless rxxml[:transid]
         | 
| 505 | 
            +
                      xml.field('name' => 'PharmID', 'value' => rxxml[:pharmid]) unless rxxml[:pharmid]
         | 
| 506 | 
            +
                      xml.field('name' => 'DDI', 'value' => rxxml[:ddi]) unless rxxml[:ddi]
         | 
| 507 | 
            +
                      xml.field('name' => 'GPPCCode', 'value' => rxxml[:gppccode]) unless rxxml[:gppccode]
         | 
| 508 | 
            +
                      xml.field('name' => 'GPPCText', 'value' => rxxml[:gppctext]) unless rxxml[:gppctext]
         | 
| 509 | 
            +
                      xml.field('name' => 'GPPCCustom', 'value' => rxxml[:gppccustom]) unless rxxml[:gppccustom]
         | 
| 510 | 
            +
                      xml.field('name' => 'Sig', 'value' => rxxml[:sig]) unless rxxml[:sig]
         | 
| 511 | 
            +
                      xml.field('name' => 'QuanPresc', 'value' => rxxml[:quanpresc]) unless rxxml[:quanpresc]
         | 
| 512 | 
            +
                      xml.field('name' => 'Refills', 'value' => rxxml[:refills]) unless rxxml[:refills]
         | 
| 513 | 
            +
                      xml.field('name' => 'DAW', 'value' => rxxml[:daw]) unless rxxml[:daw]
         | 
| 514 | 
            +
                      xml.field('name' => 'DaysSupply', 'value' => rxxml[:dayssupply]) unless rxxml[:dayssupply]
         | 
| 515 | 
            +
                      xml.field('name' => 'startdate', 'value' => utc_to_local(Date.parse(rxxml[:startdate].to_s))) unless rxxml[:startdate]
         | 
| 516 | 
            +
                      xml.field('name' => 'historicalflag', 'value' => rxxml[:historicalflag]) unless rxxml[:historicalflag]
         | 
| 517 | 
            +
                      xml.field('name' => 'rxaction', 'value' => rxxml[:rxaction]) unless rxxml[:rxaction]
         | 
| 518 | 
            +
                      xml.field('name' => 'delivery', 'value' => rxxml[:delivery]) unless rxxml[:delivery]
         | 
| 519 | 
            +
                      xml.field('name' => 'ignorepharmzero', 'value' => rxxml[:ignorepharmzero]) unless rxxml[:ignorepharmzero]
         | 
| 520 | 
            +
                      xml.field('name' => 'orderedbyid', 'value' => rxxml[:orderedbyid]) unless rxxml[:orderedbyid]
         | 
| 521 | 
            +
                      xml.field('name' => 'newqty', 'value' => rxxml[:newqty]) unless rxxml[:newqty]
         | 
| 522 | 
            +
                      xml.field('name' => 'newrefills', 'value' => rxxml[:newrefills]) unless rxxml[:newrefills]
         | 
| 523 | 
            +
                      xml.field('name' => 'comments', 'value' => rxxml[:comments]) unless rxxml[:comments]
         | 
| 524 | 
            +
                      xml.field('name' => 'orderstatus', 'value' => rxxml[:order_status]) unless rxxml[:order_status]
         | 
| 525 | 
            +
             | 
| 526 | 
            +
                      if rxxml[:problems]
         | 
| 527 | 
            +
                        rxxml[:problems].each do |problem|
         | 
| 528 | 
            +
                          xml.field('name' => 'Problem', 'value' => problem)
         | 
| 529 | 
            +
                        end
         | 
| 530 | 
            +
                      end
         | 
| 524 531 | 
             
                    }
         | 
| 525 532 | 
             
                  end
         | 
| 526 533 |  | 
| @@ -8,6 +8,15 @@ module AllscriptsUnityClient | |
| 8 8 |  | 
| 9 9 | 
             
                def initialize(options)
         | 
| 10 10 | 
             
                  @options = ClientOptions.new(options)
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                  # If New Relic support is enabled, setup method tracing
         | 
| 13 | 
            +
                  if @options.new_relic
         | 
| 14 | 
            +
                    NewRelicSupport.enable_method_tracer(self)
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                    class << self
         | 
| 17 | 
            +
                      add_method_tracer :magic
         | 
| 18 | 
            +
                    end
         | 
| 19 | 
            +
                  end
         | 
| 11 20 | 
             
                end
         | 
| 12 21 |  | 
| 13 22 | 
             
                def security_token?
         | 
| @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            module AllscriptsUnityClient
         | 
| 2 2 | 
             
              class ClientOptions
         | 
| 3 | 
            -
                attr_accessor :proxy, :logger, :ca_file, :ca_path, :timeout
         | 
| 3 | 
            +
                attr_accessor :proxy, :logger, :ca_file, :ca_path, :timeout, :new_relic
         | 
| 4 4 | 
             
                attr_reader :base_unity_url, :username, :password, :appname, :timezone
         | 
| 5 5 |  | 
| 6 6 | 
             
                def initialize(options = {})
         | 
| @@ -12,6 +12,7 @@ module AllscriptsUnityClient | |
| 12 12 | 
             
                  @ca_file = options[:ca_file]
         | 
| 13 13 | 
             
                  @ca_path = options[:ca_path]
         | 
| 14 14 | 
             
                  @timeout = options[:timeout]
         | 
| 15 | 
            +
                  @new_relic = options[:new_relic]
         | 
| 15 16 |  | 
| 16 17 | 
             
                  self.timezone = options[:timezone]
         | 
| 17 18 | 
             
                  self.base_unity_url = options[:base_unity_url]
         | 
| @@ -78,5 +79,9 @@ module AllscriptsUnityClient | |
| 78 79 | 
             
                def timeout?
         | 
| 79 80 | 
             
                  !@timeout.to_s.strip.empty?
         | 
| 80 81 | 
             
                end
         | 
| 82 | 
            +
             | 
| 83 | 
            +
                def new_relic?
         | 
| 84 | 
            +
                  !@new_relic.nil?
         | 
| 85 | 
            +
                end
         | 
| 81 86 | 
             
              end
         | 
| 82 87 | 
             
            end
         | 
| @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            require ' | 
| 1 | 
            +
            require 'oj'
         | 
| 2 2 | 
             
            require 'faraday'
         | 
| 3 3 | 
             
            require 'em-http-request'
         | 
| 4 4 |  | 
| @@ -22,17 +22,20 @@ module AllscriptsUnityClient | |
| 22 22 | 
             
                def magic(parameters = {})
         | 
| 23 23 | 
             
                  request_data = JSONUnityRequest.new(parameters, @options.timezone, @options.appname, @security_token)
         | 
| 24 24 |  | 
| 25 | 
            -
                  response =  | 
| 26 | 
            -
             | 
| 27 | 
            -
                     | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 25 | 
            +
                  response = nil
         | 
| 26 | 
            +
                  NewRelicSupport.trace_execution_scoped_if_available(JSONClientDriver, ["Custom/UnityJSON/#{parameters[:action]}"]) do
         | 
| 27 | 
            +
                    response = @connection.post do |request|
         | 
| 28 | 
            +
                      request.url "#{UNITY_JSON_ENDPOINT}/MagicJson"
         | 
| 29 | 
            +
                      request.headers['Content-Type'] = 'application/json'
         | 
| 30 | 
            +
                      request.body = Oj.dump(request_data.to_hash, mode: :compat)
         | 
| 31 | 
            +
                      set_request_timeout(request)
         | 
| 30 32 |  | 
| 31 | 
            -
             | 
| 33 | 
            +
                      start_timer
         | 
| 34 | 
            +
                    end
         | 
| 32 35 | 
             
                  end
         | 
| 33 36 | 
             
                  end_timer
         | 
| 34 37 |  | 
| 35 | 
            -
                  response =  | 
| 38 | 
            +
                  response = Oj.load(response.body, mode: :strict)
         | 
| 36 39 |  | 
| 37 40 | 
             
                  raise_if_response_error(response)
         | 
| 38 41 | 
             
                  log_magic(request_data)
         | 
| @@ -55,7 +58,7 @@ module AllscriptsUnityClient | |
| 55 58 | 
             
                  response = @connection.post do |request|
         | 
| 56 59 | 
             
                    request.url "#{UNITY_JSON_ENDPOINT}/GetToken"
         | 
| 57 60 | 
             
                    request.headers['Content-Type'] = 'application/json'
         | 
| 58 | 
            -
                    request.body =  | 
| 61 | 
            +
                    request.body = Oj.dump(request_data, mode: :compat)
         | 
| 59 62 | 
             
                    set_request_timeout(request)
         | 
| 60 63 |  | 
| 61 64 | 
             
                    start_timer
         | 
| @@ -80,7 +83,7 @@ module AllscriptsUnityClient | |
| 80 83 | 
             
                  response = @connection.post do |request|
         | 
| 81 84 | 
             
                    request.url "#{UNITY_JSON_ENDPOINT}/RetireSecurityToken"
         | 
| 82 85 | 
             
                    request.headers['Content-Type'] = 'application/json'
         | 
| 83 | 
            -
                    request.body =  | 
| 86 | 
            +
                    request.body = Oj.dump(request_data, mode: :compat)
         | 
| 84 87 | 
             
                    set_request_timeout(request)
         | 
| 85 88 |  | 
| 86 89 | 
             
                    start_timer
         | 
| @@ -0,0 +1,19 @@ | |
| 1 | 
            +
            module AllscriptsUnityClient
         | 
| 2 | 
            +
              module NewRelicSupport
         | 
| 3 | 
            +
                def self.enable_method_tracer(instance)
         | 
| 4 | 
            +
                  class << instance
         | 
| 5 | 
            +
                    if !respond_to?(:trace_execution_scoped) && !respond_to?(:add_method_tracer)
         | 
| 6 | 
            +
                      extend ::NewRelic::Agent::MethodTracer
         | 
| 7 | 
            +
                    end
         | 
| 8 | 
            +
                  end
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                def self.trace_execution_scoped_if_available(klass, scope)
         | 
| 12 | 
            +
                  if klass.respond_to?(:trace_execution_scoped)
         | 
| 13 | 
            +
                    klass.trace_execution_scoped(scope, &Proc.new)
         | 
| 14 | 
            +
                  else
         | 
| 15 | 
            +
                    yield if block_given?
         | 
| 16 | 
            +
                  end
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
            end
         | 
| @@ -59,10 +59,13 @@ module AllscriptsUnityClient | |
| 59 59 | 
             
                    soap_action: "#{UNITY_ENDPOINT_NAMESPACE}/Magic"
         | 
| 60 60 | 
             
                  }
         | 
| 61 61 |  | 
| 62 | 
            +
                  response = nil
         | 
| 62 63 | 
             
                  begin
         | 
| 63 64 | 
             
                    start_timer
         | 
| 64 | 
            -
                     | 
| 65 | 
            -
             | 
| 65 | 
            +
                    NewRelicSupport.trace_execution_scoped_if_available(SOAPClientDriver, ["Custom/UnitySOAP/#{parameters[:action]}"]) do
         | 
| 66 | 
            +
                      response = @savon_client.call('Magic', call_data)
         | 
| 67 | 
            +
                      end_timer
         | 
| 68 | 
            +
                    end
         | 
| 66 69 | 
             
                  rescue Savon::SOAPFault => e
         | 
| 67 70 | 
             
                    raise APIError, e.message
         | 
| 68 71 | 
             
                  end
         | 
    
        data/spec/client_driver_spec.rb
    CHANGED
    
    | @@ -1,9 +1,10 @@ | |
| 1 1 | 
             
            require 'spec_helper'
         | 
| 2 2 |  | 
| 3 | 
            -
            describe  | 
| 3 | 
            +
            describe AllscriptsUnityClient::ClientDriver do
         | 
| 4 4 | 
             
              it_behaves_like 'a client driver'
         | 
| 5 5 |  | 
| 6 6 | 
             
              subject { build(:client_driver) }
         | 
| 7 | 
            +
              let(:new_relic_client_driver) { build(:client_driver, new_relic: true) }
         | 
| 7 8 |  | 
| 8 9 | 
             
              describe '#client_type' do
         | 
| 9 10 | 
             
                it { expect(subject.client_type).to be(:none) }
         | 
    
        data/spec/client_options_spec.rb
    CHANGED
    
    | @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            require 'spec_helper'
         | 
| 2 2 |  | 
| 3 | 
            -
            describe  | 
| 3 | 
            +
            describe AllscriptsUnityClient::ClientOptions do
         | 
| 4 4 | 
             
              subject { build(:client_options) }
         | 
| 5 5 |  | 
| 6 6 | 
             
              let(:url_with_slash) { 'http://www.example.com/' }
         | 
| @@ -182,4 +182,20 @@ describe 'ClientOptions' do | |
| 182 182 | 
             
                  end
         | 
| 183 183 | 
             
                end
         | 
| 184 184 | 
             
              end
         | 
| 185 | 
            +
             | 
| 186 | 
            +
              describe '#new_relic?' do
         | 
| 187 | 
            +
                context 'when new_relic is nil' do
         | 
| 188 | 
            +
                  it 'returns false' do
         | 
| 189 | 
            +
                    subject.new_relic = nil
         | 
| 190 | 
            +
                    expect(subject.new_relic?).to be_falsey
         | 
| 191 | 
            +
                  end
         | 
| 192 | 
            +
                end
         | 
| 193 | 
            +
             | 
| 194 | 
            +
                context 'when timeout is not nil' do
         | 
| 195 | 
            +
                  it 'returns true' do
         | 
| 196 | 
            +
                    subject.new_relic = true
         | 
| 197 | 
            +
                    expect(subject.new_relic?).to be_truthy
         | 
| 198 | 
            +
                  end
         | 
| 199 | 
            +
                end
         | 
| 200 | 
            +
              end
         | 
| 185 201 | 
             
            end
         | 
    
        data/spec/client_spec.rb
    CHANGED
    
    
| @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            require 'spec_helper'
         | 
| 2 2 |  | 
| 3 | 
            -
            describe  | 
| 3 | 
            +
            describe AllscriptsUnityClient::JSONClientDriver do
         | 
| 4 4 | 
             
              it_behaves_like 'a client driver'
         | 
| 5 5 |  | 
| 6 6 | 
             
              subject do
         | 
| @@ -9,6 +9,7 @@ describe 'JSONClientDriver' do | |
| 9 9 | 
             
                client_driver
         | 
| 10 10 | 
             
              end
         | 
| 11 11 |  | 
| 12 | 
            +
              let(:new_relic_client_driver) { build(:json_client_driver, new_relic: true) }
         | 
| 12 13 | 
             
              let(:get_server_info) { FixtureLoader.load_file('get_server_info.json') }
         | 
| 13 14 | 
             
              let(:get_security_token) { FixtureLoader.load_file('get_security_token.json') }
         | 
| 14 15 | 
             
              let(:retire_security_token) { FixtureLoader.load_file('retire_security_token.json') }
         | 
| @@ -23,7 +24,7 @@ describe 'JSONClientDriver' do | |
| 23 24 | 
             
              end
         | 
| 24 25 |  | 
| 25 26 | 
             
              let(:json_hash) do
         | 
| 26 | 
            -
                 | 
| 27 | 
            +
                Oj.dump(hash, mode: :strict)
         | 
| 27 28 | 
             
              end
         | 
| 28 29 |  | 
| 29 30 | 
             
              describe '#initialize' do
         | 
| @@ -51,6 +52,11 @@ describe 'JSONClientDriver' do | |
| 51 52 | 
             
                  expect(WebMock).to have_requested(:post, 'http://www.example.com/Unity/UnityService.svc/json/MagicJson').with(body: /\{"Action":(null|"[^"]*"),"AppUserID":(null|"[^"]*"),"Appname":(null|"[^"]*"),"PatientID":(null|"[^"]*"),"Token":(null|"[^"]*"),"Parameter1":(null|"[^"]*"),"Parameter2":(null|"[^"]*"),"Parameter3":(null|"[^"]*"),"Parameter4":(null|"[^"]*"),"Parameter5":(null|"[^"]*"),"Parameter6":(null|"[^"]*"),"Data":(null|"[^"]*")\}/, headers: { 'Content-Type' => 'application/json' })
         | 
| 52 53 | 
             
                end
         | 
| 53 54 |  | 
| 55 | 
            +
                it 'should serialize DateTime to iso8601 when given' do
         | 
| 56 | 
            +
                  subject.magic(parameter1: DateTime.now)
         | 
| 57 | 
            +
                  expect(WebMock).to have_requested(:post, 'http://www.example.com/Unity/UnityService.svc/json/MagicJson').with(body: /\{"Action":(null|"[^"]*"),"AppUserID":(null|"[^"]*"),"Appname":(null|"[^"]*"),"PatientID":(null|"[^"]*"),"Token":(null|"[^"]*"),"Parameter1":"\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(-|\+)\d{2}:\d{2}","Parameter2":(null|"[^"]*"),"Parameter3":(null|"[^"]*"),"Parameter4":(null|"[^"]*"),"Parameter5":(null|"[^"]*"),"Parameter6":(null|"[^"]*"),"Data":(null|"[^"]*")\}/, headers: { 'Content-Type' => 'application/json' })
         | 
| 58 | 
            +
                end
         | 
| 59 | 
            +
             | 
| 54 60 | 
             
                it 'should call start_timer' do
         | 
| 55 61 | 
             
                  subject.magic
         | 
| 56 62 | 
             
                  expect(subject).to have_received(:start_timer)
         | 
| @@ -0,0 +1,49 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe AllscriptsUnityClient::NewRelicSupport do
         | 
| 4 | 
            +
              subject { described_class }
         | 
| 5 | 
            +
              let(:scope) { ['scope'] }
         | 
| 6 | 
            +
              let(:block) { lambda {} }
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              before :all do
         | 
| 9 | 
            +
                # Mock a test class for NewRelic mixin tests.
         | 
| 10 | 
            +
                class NewRelicSupportTest
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              describe '.enable_method_tracer' do
         | 
| 15 | 
            +
                context 'when given an object that does not have the NewRelic::Agent::MethodTracer module mixed in' do
         | 
| 16 | 
            +
                  it 'mixes in the NewRelic::Agent::MethodTracer module' do
         | 
| 17 | 
            +
                    allow(NewRelicSupportTest).to receive(:extend)
         | 
| 18 | 
            +
                    subject.enable_method_tracer(NewRelicSupportTest.new)
         | 
| 19 | 
            +
                    expect(NewRelicSupportTest).to have_received(:extend).with(::NewRelic::Agent::MethodTracer)
         | 
| 20 | 
            +
                  end
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                context 'when given an object that does have the NewRelic::Agent::MethodTracer module mixed in' do
         | 
| 24 | 
            +
                  it 'does not mix in the NewRelic::Agent::MethodTracer module' do
         | 
| 25 | 
            +
                    allow(NewRelicSupportTest).to receive(:extend)
         | 
| 26 | 
            +
                    allow(NewRelicSupportTest).to receive(:trace_execution_scoped)
         | 
| 27 | 
            +
                    allow(NewRelicSupportTest).to receive(:add_method_tracer)
         | 
| 28 | 
            +
                    subject.enable_method_tracer(NewRelicSupportTest.new)
         | 
| 29 | 
            +
                    expect(NewRelicSupportTest).not_to have_received(:extend).with(::NewRelic::Agent::MethodTracer)
         | 
| 30 | 
            +
                  end
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
              describe '.trace_execution_scoped_if_available' do
         | 
| 35 | 
            +
                context 'when a class does not have trace_execution_scoped and is given block' do
         | 
| 36 | 
            +
                  it 'will yield to the block' do
         | 
| 37 | 
            +
                    expect { |b| subject.trace_execution_scoped_if_available(NewRelicSupportTest, scope, &b) }.to yield_control
         | 
| 38 | 
            +
                  end
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                context 'when a class has trace_execution_scoped and is given a block' do
         | 
| 42 | 
            +
                  it 'will pass the block to trace_execution_scoped' do
         | 
| 43 | 
            +
                    allow(NewRelicSupportTest).to receive(:trace_execution_scoped)
         | 
| 44 | 
            +
                    subject.trace_execution_scoped_if_available(NewRelicSupportTest, scope, &block)
         | 
| 45 | 
            +
                    expect(NewRelicSupportTest).to have_received(:trace_execution_scoped).with(scope)
         | 
| 46 | 
            +
                  end
         | 
| 47 | 
            +
                end
         | 
| 48 | 
            +
              end
         | 
| 49 | 
            +
            end
         | 
| @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            require 'spec_helper'
         | 
| 2 2 |  | 
| 3 | 
            -
            describe  | 
| 3 | 
            +
            describe AllscriptsUnityClient::SOAPClientDriver do
         | 
| 4 4 | 
             
              include Savon::SpecHelper
         | 
| 5 5 | 
             
              it_behaves_like 'a client driver'
         | 
| 6 6 |  | 
| @@ -10,6 +10,7 @@ describe 'SOAPClientDriver' do | |
| 10 10 | 
             
                client_driver
         | 
| 11 11 | 
             
              end
         | 
| 12 12 |  | 
| 13 | 
            +
              let(:new_relic_client_driver) { build(:soap_client_driver, new_relic: true) }
         | 
| 13 14 | 
             
              let(:get_server_info) { FixtureLoader.load_file('get_server_info.xml') }
         | 
| 14 15 | 
             
              let(:get_security_token) { FixtureLoader.load_file('get_security_token.xml') }
         | 
| 15 16 | 
             
              let(:retire_security_token) { FixtureLoader.load_file('retire_security_token.xml') }
         | 
| @@ -0,0 +1,16 @@ | |
| 1 | 
            +
            RSpec.configure do |config|
         | 
| 2 | 
            +
              config.before(:suite) do
         | 
| 3 | 
            +
                # Mock the NewRelic::Agent::MethodTracer module
         | 
| 4 | 
            +
                module NewRelic
         | 
| 5 | 
            +
                  module Agent
         | 
| 6 | 
            +
                    module MethodTracer
         | 
| 7 | 
            +
                      def trace_execution_scoped
         | 
| 8 | 
            +
                      end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                      def add_method_tracer
         | 
| 11 | 
            +
                      end
         | 
| 12 | 
            +
                    end
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
            end
         | 
| @@ -1,4 +1,16 @@ | |
| 1 1 | 
             
            shared_examples 'a client driver' do
         | 
| 2 | 
            +
              describe '#initialize' do
         | 
| 3 | 
            +
                context 'when options.new_relic is true' do
         | 
| 4 | 
            +
                  it 'enables NewRelic tracing' do
         | 
| 5 | 
            +
                    allow(AllscriptsUnityClient::NewRelicSupport).to receive(:enable_method_tracer)
         | 
| 6 | 
            +
                    allow(described_class).to receive(:add_method_tracer)
         | 
| 7 | 
            +
                    new_relic_client_driver
         | 
| 8 | 
            +
                    expect(AllscriptsUnityClient::NewRelicSupport).to have_received(:enable_method_tracer).with(new_relic_client_driver)
         | 
| 9 | 
            +
                    expect(described_class).to have_received(:add_method_tracer).with(:magic)
         | 
| 10 | 
            +
                  end
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
             | 
| 2 14 | 
             
              describe '#security_token?' do
         | 
| 3 15 | 
             
                context 'when @security_token is nil' do
         | 
| 4 16 | 
             
                  it do
         | 
    
        data/spec/timezone_spec.rb
    CHANGED
    
    
    
        data/spec/unity_request_spec.rb
    CHANGED
    
    
    
        data/spec/unity_response_spec.rb
    CHANGED
    
    
    
        data/spec/utilities_spec.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: allscripts_unity_client
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2.0 | 
| 4 | 
            +
              version: 2.1.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Ash Gupta
         | 
| @@ -9,7 +9,7 @@ authors: | |
| 9 9 | 
             
            autorequire: 
         | 
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 | 
            -
            date: 2014- | 
| 12 | 
            +
            date: 2014-07-02 00:00:00.000000000 Z
         | 
| 13 13 | 
             
            dependencies:
         | 
| 14 14 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 15 15 | 
             
              name: savon
         | 
| @@ -115,6 +115,20 @@ dependencies: | |
| 115 115 | 
             
                - - ~>
         | 
| 116 116 | 
             
                  - !ruby/object:Gem::Version
         | 
| 117 117 | 
             
                    version: 1.1.0
         | 
| 118 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 119 | 
            +
              name: oj
         | 
| 120 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 121 | 
            +
                requirements:
         | 
| 122 | 
            +
                - - ~>
         | 
| 123 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 124 | 
            +
                    version: 2.9.8
         | 
| 125 | 
            +
              type: :runtime
         | 
| 126 | 
            +
              prerelease: false
         | 
| 127 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 128 | 
            +
                requirements:
         | 
| 129 | 
            +
                - - ~>
         | 
| 130 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 131 | 
            +
                    version: 2.9.8
         | 
| 118 132 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 119 133 | 
             
              name: factory_girl
         | 
| 120 134 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -163,14 +177,14 @@ dependencies: | |
| 163 177 | 
             
                requirements:
         | 
| 164 178 | 
             
                - - ~>
         | 
| 165 179 | 
             
                  - !ruby/object:Gem::Version
         | 
| 166 | 
            -
                    version: 3.0.0 | 
| 180 | 
            +
                    version: 3.0.0
         | 
| 167 181 | 
             
              type: :development
         | 
| 168 182 | 
             
              prerelease: false
         | 
| 169 183 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 170 184 | 
             
                requirements:
         | 
| 171 185 | 
             
                - - ~>
         | 
| 172 186 | 
             
                  - !ruby/object:Gem::Version
         | 
| 173 | 
            -
                    version: 3.0.0 | 
| 187 | 
            +
                    version: 3.0.0
         | 
| 174 188 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 175 189 | 
             
              name: simplecov
         | 
| 176 190 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -236,6 +250,7 @@ files: | |
| 236 250 | 
             
            - lib/allscripts_unity_client/json_client_driver.rb
         | 
| 237 251 | 
             
            - lib/allscripts_unity_client/json_unity_request.rb
         | 
| 238 252 | 
             
            - lib/allscripts_unity_client/json_unity_response.rb
         | 
| 253 | 
            +
            - lib/allscripts_unity_client/new_relic_support.rb
         | 
| 239 254 | 
             
            - lib/allscripts_unity_client/soap_client_driver.rb
         | 
| 240 255 | 
             
            - lib/allscripts_unity_client/timezone.rb
         | 
| 241 256 | 
             
            - lib/allscripts_unity_client/unity_request.rb
         | 
| @@ -250,11 +265,7 @@ files: | |
| 250 265 | 
             
            - spec/factories/client_driver_factory.rb
         | 
| 251 266 | 
             
            - spec/factories/client_factory.rb
         | 
| 252 267 | 
             
            - spec/factories/client_options.rb
         | 
| 253 | 
            -
            - spec/factories/json_client_driver_factory.rb
         | 
| 254 | 
            -
            - spec/factories/json_unity_request_factory.rb
         | 
| 255 | 
            -
            - spec/factories/json_unity_response_factory.rb
         | 
| 256 268 | 
             
            - spec/factories/magic_request_factory.rb
         | 
| 257 | 
            -
            - spec/factories/soap_client_driver_factory.rb
         | 
| 258 269 | 
             
            - spec/factories/timezone_factory.rb
         | 
| 259 270 | 
             
            - spec/factories/unity_request_factory.rb
         | 
| 260 271 | 
             
            - spec/factories/unity_response_factory.rb
         | 
| @@ -281,10 +292,12 @@ files: | |
| 281 292 | 
             
            - spec/json_client_driver_spec.rb
         | 
| 282 293 | 
             
            - spec/json_unity_request_spec.rb
         | 
| 283 294 | 
             
            - spec/json_unity_response_spec.rb
         | 
| 295 | 
            +
            - spec/new_relic_support_spec.rb
         | 
| 284 296 | 
             
            - spec/soap_client_driver_spec.rb
         | 
| 285 297 | 
             
            - spec/spec_helper.rb
         | 
| 286 298 | 
             
            - spec/support/factory_girl.rb
         | 
| 287 299 | 
             
            - spec/support/fixture_loader.rb
         | 
| 300 | 
            +
            - spec/support/new_relic.rb
         | 
| 288 301 | 
             
            - spec/support/shared_examples_for_client_driver.rb
         | 
| 289 302 | 
             
            - spec/support/shared_examples_for_unity_request.rb
         | 
| 290 303 | 
             
            - spec/support/shared_examples_for_unity_response.rb
         |