Module: Pact::PactFile
- Extended by:
- PactFile
- Included in:
- ConsumerContract, PactFile
- Defined in:
- lib/pact/consumer_contract/pact_file.rb
Defined Under Namespace
Classes: HttpError
Constant Summary collapse
- OPEN_TIMEOUT =
5
- READ_TIMEOUT =
5
- RETRY_LIMIT =
3
Instance Method Summary collapse
- #read(uri, options = {}) ⇒ Object
- #render_pact(uri_string, options) ⇒ Object
- #save_pactfile_to_tmp(pact, name) ⇒ Object
Instance Method Details
#read(uri, options = {}) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/pact/consumer_contract/pact_file.rb', line 22 def read uri, = {} uri_string = uri.to_s pact = render_pact(uri_string, ) if [:save_pactfile_to_tmp] save_pactfile_to_tmp pact, ::File.basename(uri_string) end pact rescue StandardError => e $stderr.puts "Error reading file from #{uri}" $stderr.puts "#{e.to_s} #{e.backtrace.join("\n")}" raise e end |
#render_pact(uri_string, options) ⇒ Object
42 43 44 |
# File 'lib/pact/consumer_contract/pact_file.rb', line 42 def render_pact(uri_string, ) local?(uri_string) ? get_local(uri_string, ) : get_remote_with_retry(uri_string, ) end |
#save_pactfile_to_tmp(pact, name) ⇒ Object
35 36 37 38 39 40 |
# File 'lib/pact/consumer_contract/pact_file.rb', line 35 def save_pactfile_to_tmp pact, name ::FileUtils.mkdir_p Pact.configuration.tmp_dir ::File.open(Pact.configuration.tmp_dir + "/#{name}", "w") { |file| file << pact} rescue Errno::EROFS # do nothing, probably on RunKit end |