def generate_contracts(input_dir, output_dir, host)
      WebMock.allow_net_connect!
      generator = Pacto::Generator.contract_generator
      puts "Generating contracts from partial contracts in #{input_dir} and recording to #{output_dir}\n\n"

      failed_contracts = []
      each_contract(input_dir) do |contract_file|
        begin
          contract = generator.generate_from_partial_contract(contract_file, host)
          output_file = File.expand_path(File.basename(contract_file), output_dir)
          output_file = File.open(output_file, 'wb')
          output_file.write contract
          output_file.flush
          output_file.close
        rescue InvalidContract => e
          failed_contracts << contract_file
          puts Pacto::UI.colorize(e.message, :red)
        end
      end

      if failed_contracts.empty?
        puts Pacto::UI.colorize('Successfully generated all contracts', :green)
      else
        fail Pacto::UI.colorize("The following contracts could not be generated: #{failed_contracts.join ','}", :red)
      end
    end
def generate_contracts(input_dir, output_dir, host)
      WebMock.allow_net_connect!
      generator = Pacto::Generator.contract_generator
      puts "Generating contracts from partial contracts in #{input_dir} and recording to #{output_dir}\n\n"

      failed_contracts = []
      each_contract(input_dir) do |contract_file|
        begin
          contract = generator.generate_from_partial_contract(contract_file, host)
          output_file = File.expand_path(File.basename(contract_file), output_dir)
          output_file = File.open(output_file, 'wb')
          output_file.write contract
          output_file.flush
          output_file.close
        rescue InvalidContract => e
          failed_contracts << contract_file
          puts Pacto::UI.colorize(e.message, :red)
        end
      end

      if failed_contracts.empty?
        puts Pacto::UI.colorize('Successfully generated all contracts', :green)
      else
        fail Pacto::UI.colorize("The following contracts could not be generated: #{failed_contracts.join ','}", :red)
      end
    end
rubocop:enable MethodLength
 FIXME: generate_contracts is a big method =(. Needs refactoring
 rubocop:disable MethodLength