Sha256: 966cefe5a0cd6c0ddf84205567200331fc3939c0acf5d01d19040692fc724e09
Contents?: true
Size: 1.01 KB
Versions: 1
Compression:
Stored size: 1.01 KB
Contents
# -*- encoding : utf-8 -*- module Pacto class ContractFactory include Singleton include Logger def initialize @factories = {} end def add_factory(format, factory) @factories[format.to_sym] = factory end def remove_factory(format) @factories.delete format end def build(contract_files, host, format = :default) factory = @factories[format.to_sym] fail "No Contract factory registered for #{format}" if factory.nil? contract_files.map { |file| factory.build_from_file(file, host) }.flatten end def load_contracts(contracts_path, host, format = :default) factory = @factories[format.to_sym] files = factory.files_for(contracts_path) contracts = ContractFactory.build(files, host, format) contracts end class << self extend Forwardable def_delegators :instance, *ContractFactory.instance_methods(false) end end end require 'pacto/native_contract_factory' require 'pacto/swagger_contract_factory'
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
pacto-0.4.0.rc1 | lib/pacto/contract_factory.rb |