<commit_before>require 'open-uri'
require 'rspec'
require 'rspec/core'
require 'rspec/core/formatters/documentation_formatter'
require_relative 'rspec'

module Pact
	module Producer
		class PactSpecRunner
			def self.run(consumer_expectations, options = {})

				consumer_expectations.each do | consumer_expectation |
					require consumer_expectation[:support_file]
					describe "Pact in #{consumer_expectation[:uri]}" do
						open(consumer_expectation[:uri]) do | file |
							honour_pact JSON.load(file.read), {consumer: consumer_expectation[:consumer]}
						end
					end
				end

				config = ::RSpec.configuration
				config.color = true

				unless options[:silent]
					config.error_stream = $stderr
					config.output_stream = $stdout
				end

				formatter = ::RSpec::Core::Formatters::DocumentationFormatter.new(config.output)
				reporter =  ::RSpec::Core::Reporter.new(formatter)
				config.instance_variable_set(:@reporter, reporter)

				config.reporter.report(::RSpec::world.example_count, nil) do |reporter|
				  begin
				    config.run_hook(:before, :suite)
				    ::RSpec::world.example_groups.ordered.map {|g| g.run(reporter)}.all? ? 0 : config.failure_exit_code
				  ensure
				    config.run_hook(:after, :suite)
				  end
				end
			end
		end
	end
end<commit_msg>Broke up horrible long PactSpecRunner.run method into separate methods.<commit_after>require 'open-uri'
require 'rspec'
require 'rspec/core'
require 'rspec/core/formatters/documentation_formatter'
require_relative 'rspec'

module Pact
	module Producer
		class PactSpecRunner

			def self.run(spec_definitions, options = {})
				initialize_specs spec_definitions
				configure_rspec options
				run_specs
			end

			private

			def self.initialize_specs spec_definitions
				spec_definitions.each do | spec_definition |
					require spec_definition[:support_file]
					describe "Pact in #{spec_definition[:uri]}" do
						open(spec_definition[:uri]) do | file |
							honour_pact JSON.load(file.read), {consumer: spec_definition[:consumer]}
						end
					end
				end
			end

			def self.configure_rspec options
				config = ::RSpec.configuration
				config.color = true

				unless options[:silent]
					config.error_stream = $stderr
					config.output_stream = $stdout
				end

				formatter = ::RSpec::Core::Formatters::DocumentationFormatter.new(config.output)
				reporter =  ::RSpec::Core::Reporter.new(formatter)
				config.instance_variable_set(:@reporter, reporter)
			end

			def self.run_specs
				config = ::RSpec.configuration
				world = ::RSpec::world
				config.reporter.report(world.example_count, nil) do |reporter|
				  begin
				    config.run_hook(:before, :suite)
				    world.example_groups.ordered.map {|g| g.run(reporter)}.all? ? 0 : config.failure_exit_code
				  ensure
				    config.run_hook(:after, :suite)
				  end
				end
			end
		end
	end
end
{'fraction_non_alphanumeric': 0.10240334378265413, 'fraction_numerical': 0.0006966213862765587, 'mean_word_length': 3.669918699186992, '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': '1441566', 'n_tokens_mistral': 1138, 'n_tokens_neox': 878, 'n_words': 182}