<commit_before>module Pact
	class ConsumerContract

		attr_reader :interactions

		def initialize(opts)
			@interactions = opts[:interactions]
		end

		def as_json(options = {})
			{
				interactions: @interactions.collect(&:as_json)
			}
		end

		def to_json(options = {})
			as_json(options).to_json
		end

		def self.json_create(obj)
		  new({:interactions => obj['interactions']})
		end

		def self.from_json string
			deserialised_object = JSON.load(string)
			if deserialised_object.is_a? Hash
				ConsumerContract.new(interactions: deserialised_object['interactions'])
			elsif deserialised_object.is_a? Array #For backwards compatiblity
				ConsumerContract.new(interactions: deserialised_object)
			else
				raise "Don't know how to handle deserialized object #{deserialised_object}"
			end
		end

		def each
			interactions.each do | interaction |
				yield interaction
			end
		end
	end
end<commit_msg>Fixed the pretty generation of the json<commit_after>module Pact
	class ConsumerContract

		attr_reader :interactions

		def initialize(opts)
			@interactions = opts[:interactions]
		end

		def as_json(options = {})
			{
				interactions: @interactions.collect(&:as_json)
			}
		end

		def to_json(options = {})
			as_json(options).to_json(options)
		end

		def self.json_create(obj)
		  new({:interactions => obj['interactions']})
		end

		def self.from_json string
			deserialised_object = JSON.load(string)
			if deserialised_object.is_a? Hash
				ConsumerContract.new(interactions: deserialised_object['interactions'])
			elsif deserialised_object.is_a? Array #For backwards compatiblity
				ConsumerContract.new(interactions: deserialised_object)
			else
				raise "Don't know how to handle deserialized object #{deserialised_object}"
			end
		end

		def each
			interactions.each do | interaction |
				yield interaction
			end
		end
	end
end
{'fraction_non_alphanumeric': 0.08490059108006448, 'fraction_numerical': 0.0, 'mean_word_length': 4.129476584022038, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5190620', 'n_tokens_mistral': 704, 'n_tokens_neox': 583, 'n_words': 137}