Module: Pact::FileName

Extended by:
FileName
Included in:
FileName
Defined in:
lib/pact/consumer_contract/file_name.rb

Instance Method Summary collapse

Instance Method Details

#file_name(consumer_name, provider_name, options = {}) ⇒ Object



5
6
7
8
# File 'lib/pact/consumer_contract/file_name.rb', line 5

def file_name consumer_name, provider_name, options = {}
  pid = options[:unique] ? "-#{Process.pid}" : ''
  "#{filenamify(consumer_name)}-#{filenamify(provider_name)}#{pid}.json"
end

#file_path(consumer_name, provider_name, pact_dir = Pact.configuration.pact_dir, options = {}) ⇒ Object



10
11
12
# File 'lib/pact/consumer_contract/file_name.rb', line 10

def file_path consumer_name, provider_name, pact_dir = Pact.configuration.pact_dir, options = {}
  File.join(windows_safe(pact_dir), file_name(consumer_name, provider_name, options))
end

#filenamify(name) ⇒ Object



14
15
16
# File 'lib/pact/consumer_contract/file_name.rb', line 14

def filenamify name
  name.downcase.gsub(/\s/, '_')
end

#windows_safe(pact_dir) ⇒ Object



18
19
20
# File 'lib/pact/consumer_contract/file_name.rb', line 18

def windows_safe(pact_dir)
  pact_dir.gsub("\\", "/")
end