module Pacto
FIXME: RakeTask
is a huge class, refactor this please rubocop:disable ClassLength
Constants
- VERSION
Public Class Methods
clear!()
click to toggle source
# File lib/pacto.rb, line 62 def clear! Pacto.configuration.provider.reset! @modes = nil @configuration = nil @registry = nil Pacto::ValidationRegistry.instance.reset! end
configuration()
click to toggle source
# File lib/pacto.rb, line 54 def configuration @configuration ||= Configuration.new end
configure() { |configuration| ... }
click to toggle source
# File lib/pacto.rb, line 70 def configure yield(configuration) end
contract_factory()
click to toggle source
# File lib/pacto.rb, line 50 def contract_factory @factory = ContractFactory.new end
contract_registry()
click to toggle source
# File lib/pacto.rb, line 58 def contract_registry @registry ||= ContractRegistry.new end
contracts_for(request_signature)
click to toggle source
# File lib/pacto.rb, line 74 def contracts_for(request_signature) contract_registry.contracts_for(request_signature) end
generate!()
click to toggle source
# File lib/pacto/core/modes.rb, line 3 def generate! modes << :generate end
generating?()
click to toggle source
# File lib/pacto/core/modes.rb, line 11 def generating? modes.include? :generate end
load_contract(contract_path, host)
click to toggle source
# File lib/pacto.rb, line 90 def load_contract(contract_path, host) load_contracts(contract_path, host).contracts.first end
load_contracts(contracts_path, host)
click to toggle source
# File lib/pacto.rb, line 94 def load_contracts(contracts_path, host) files = ContractFiles.for(contracts_path) contracts = contract_factory.build(files, host) contracts.each do |contract| contract_registry.register(contract) end ContractList.new(contracts) end
stop_generating!()
click to toggle source
# File lib/pacto/core/modes.rb, line 7 def stop_generating! modes.delete :generate end
stop_validating!()
click to toggle source
# File lib/pacto/core/modes.rb, line 19 def stop_validating! modes.delete :validate end
validate!()
click to toggle source
# File lib/pacto/core/modes.rb, line 15 def validate! modes << :validate end
validate_contract(contract)
click to toggle source
# File lib/pacto.rb, line 78 def validate_contract(contract) Pacto::MetaSchema.new.validate contract puts "Validating #{contract}" true rescue InvalidContract => exception puts 'Validation errors detected' exception.errors.each do |error| puts " Error: #{error}" end false end
validating?()
click to toggle source
# File lib/pacto/core/modes.rb, line 23 def validating? modes.include? :validate end
Private Class Methods
modes()
click to toggle source
# File lib/pacto/core/modes.rb, line 29 def modes @modes ||= [] end