Module: Pact::PactFile
- Extended by:
- PactFile
- Included in:
- ConsumerContract, PactFile
- Defined in:
- lib/pact/consumer_contract/pact_file.rb
Instance Method Summary collapse
Instance Method Details
#read(uri, options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/pact/consumer_contract/pact_file.rb', line 7 def read uri, = {} pact = open(uri.to_s) { | file | file.read } if [:save_pactfile_to_tmp] save_pactfile_to_tmp pact, ::File.basename(uri.to_s) end pact rescue StandardError => e $stderr.puts "Error reading file from #{uri}" $stderr.puts "#{e.to_s} #{e.backtrace.join("\n")}" raise e end |
#save_pactfile_to_tmp(pact, name) ⇒ Object
19 20 21 22 |
# File 'lib/pact/consumer_contract/pact_file.rb', line 19 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} end |