<commit_before>require 'pact/shared/dsl'
require_relative 'mock_service'

module Pact::Messages::Consumer::DSL
  class MessageProvider
    extend Pact::DSL

    attr_accessor :service, :consumer_name, :provider_name

    def initialize provider_name, consumer_name
      @provider_name = provider_name
      @consumer_name = consumer_name
      @service = nil
    end

    dsl do
      def mock_service name, &block
        self.service = MockService.build(name, consumer_name, provider_name, &block)
      end
    end

    def finalize
      validate
    end

    private

    def validate<commit_msg>Make the mock_service block optional<commit_after>require 'pact/shared/dsl'
require_relative 'mock_service'

module Pact::Messages::Consumer::DSL
  class MessageProvider
    extend Pact::DSL

    attr_accessor :service, :consumer_name, :provider_name

    def initialize provider_name, consumer_name
      @provider_name = provider_name
      @consumer_name = consumer_name
      @service = nil
    end

    dsl do
      def mock_service name, &block
        self.service = MockService.build(name, consumer_name, provider_name, &block || proc {})
      end
    end

    def finalize
      validate
    end

    private

    def validate
{'fraction_non_alphanumeric': 0.06785137318255251, 'fraction_numerical': 0.0, 'mean_word_length': 3.1577181208053693, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4037102', 'n_tokens_mistral': 371, 'n_tokens_neox': 355, 'n_words': 94}