<commit_before># encoding: UTF-8

require "json-schema"
require "hypercharge/schema/version"
require "hypercharge/schema/fixture"


module Hypercharge
	module Schema

		# validates a hash with JSON-Schema
		def self.validate(type, data, *opts = {})
      opts.merge!({ version: :draft3 })
			JSON::Validator.fully_validate(schema_path_for(type), data, opts)
		end

		# returns the path for a JSON-Schema
		# @param [Hypercharge::Payment::Type, Hypercharge::PaymentTransaction::Type] type  the type
		# @return [String] path
		def self.schema_path_for(type)
			File.expand_path("../../../../json/#{type}.json", __FILE__)
		end

		# yields with json schema files full path.
		# If you need the schema as hash, please feel free to IO.read() and JSON.parse().
		def self.each
			Dir[File.expand_path("../../../../json/*.json", __FILE__)].each do |path|
				yield path
			end
		end
	end<commit_msg>Backwards compatibility added for validation options.<commit_after># encoding: UTF-8

require "json-schema"
require "hypercharge/schema/version"
require "hypercharge/schema/fixture"


module Hypercharge
	module Schema

		# validates a hash with JSON-Schema
		def self.validate(type, data, opts = {})
      opts.merge!({ version: :draft3 })
			JSON::Validator.fully_validate(schema_path_for(type), data, opts)
		end

		# returns the path for a JSON-Schema
		# @param [Hypercharge::Payment::Type, Hypercharge::PaymentTransaction::Type] type  the type
		# @return [String] path
		def self.schema_path_for(type)
			File.expand_path("../../../../json/#{type}.json", __FILE__)
		end

		# yields with json schema files full path.
		# If you need the schema as hash, please feel free to IO.read() and JSON.parse().
		def self.each
			Dir[File.expand_path("../../../../json/*.json", __FILE__)].each do |path|
				yield path
			end
		end
	end
{'fraction_non_alphanumeric': 0.14027397260273972, 'fraction_numerical': 0.002191780821917808, 'mean_word_length': 3.670076726342711, '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': '4798735', 'n_tokens_mistral': 624, 'n_tokens_neox': 561, 'n_words': 166}