Sha256: f53d36ea1cb09117d040193f86da0610ca4d1d4222ba3060d90b0d28bd3a199c

Contents?: true

Size: 600 Bytes

Versions: 3

Compression:

Stored size: 600 Bytes

Contents

module Pacto
  module CLI
    module Helpers
      def each_contract(*contracts)
        [*contracts].each do |contract|
          if File.file? contract
            yield contract
          else # Should we assume it's a dir, or also support glob patterns?
            contracts = Dir[File.join(contract, '**/*{.json.erb,.json}')]
            fail Pacto::UI.colorize("No contracts found in directory #{contract}", :yellow) if contracts.empty?

            contracts.sort.each do |contract_file|
              yield contract_file
            end
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pacto-0.4.0.rc3 lib/pacto/cli/helpers.rb
pacto-0.4.0.rc2 lib/pacto/cli/helpers.rb
pacto-0.4.0.rc1 lib/pacto/cli/helpers.rb