Class: Pact::Provider::PactSource
- Inherits:
-
Object
- Object
- Pact::Provider::PactSource
- Defined in:
- lib/pact/provider/pact_source.rb
Instance Attribute Summary collapse
-
#uri ⇒ Object
readonly
PactURI class.
Instance Method Summary collapse
- #consumer_contract ⇒ Object
- #hal_entity ⇒ Object
-
#initialize(uri) ⇒ PactSource
constructor
A new instance of PactSource.
- #pact_hash ⇒ Object
- #pact_json ⇒ Object
- #pending? ⇒ Boolean
Constructor Details
#initialize(uri) ⇒ PactSource
Returns a new instance of PactSource.
12 13 14 |
# File 'lib/pact/provider/pact_source.rb', line 12 def initialize uri @uri = uri end |
Instance Attribute Details
#uri ⇒ Object (readonly)
PactURI class
10 11 12 |
# File 'lib/pact/provider/pact_source.rb', line 10 def uri @uri end |
Instance Method Details
#consumer_contract ⇒ Object
28 29 30 |
# File 'lib/pact/provider/pact_source.rb', line 28 def consumer_contract @consumer_contract ||= Pact::ConsumerContract.from_json(pact_json) end |
#hal_entity ⇒ Object
32 33 34 35 36 37 |
# File 'lib/pact/provider/pact_source.rb', line 32 def hal_entity http_client_keys = [:username, :password, :token] = uri..reject{ |k, _| !http_client_keys.include?(k) } http_client = Pact::Hal::HttpClient.new() Pact::Hal::Entity.new(uri, pact_hash, http_client) end |
#pact_hash ⇒ Object
20 21 22 |
# File 'lib/pact/provider/pact_source.rb', line 20 def pact_hash @pact_hash ||= JSON.load(pact_json, nil, { max_nesting: 50 }) end |
#pact_json ⇒ Object
16 17 18 |
# File 'lib/pact/provider/pact_source.rb', line 16 def pact_json @pact_json ||= Pact::PactFile.read(uri.uri, uri.) end |
#pending? ⇒ Boolean
24 25 26 |
# File 'lib/pact/provider/pact_source.rb', line 24 def pending? uri.[:pending] end |