Module: Pact::Support::ExpandFileList

Defined in:
lib/pact/support/expand_file_list.rb

Class Method Summary collapse

Class Method Details

.call(pact_files) ⇒ Object



4
5
6
7
8
9
# File 'lib/pact/support/expand_file_list.rb', line 4

def self.call pact_files
  pact_files
    .collect{ |path| unixify_path(path) }
    .collect{ | path | expand_path(path) }
    .flatten
end

.expand_path(path) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/pact/support/expand_file_list.rb', line 15

def self.expand_path(path)
  if File.directory?(path)
    Dir.glob(File.join(path, "*.json"))
  elsif Dir.glob(path).any?
    Dir.glob(path)
  else
    path
  end
end

.unixify_path(path) ⇒ Object



11
12
13
# File 'lib/pact/support/expand_file_list.rb', line 11

def self.unixify_path(path)
  path.gsub(/\\+/, '/')
end