~singpolyma/dhall-ruby

e7e13ce8b4951c049b33959c82171472f463c80f — Stephen Paul Weber 5 years ago f7ce55a
IntegrityCheck stores raw hash internally
3 files changed, 12 insertions(+), 4 deletions(-)

M lib/dhall/ast.rb
M lib/dhall/binary.rb
M lib/dhall/parser.rb
M lib/dhall/ast.rb => lib/dhall/ast.rb +6 -2
@@ 1203,7 1203,11 @@ module Dhall
			end

			def to_s
				"#{@protocol}:#{@data}"
				"#{@protocol}:#{hexdigest}"
			end

			def hexdigest
				@data&.unpack("H*")&.first&.encode(Encoding::UTF_8)
			end

			def check(expr)


@@ 1216,7 1220,7 @@ module Dhall
			end

			def as_json
				@protocol == :nocheck ? nil : [@protocol, @data]
				@protocol == :nocheck ? nil : [@protocol, hexdigest]
			end
		end


M lib/dhall/binary.rb => lib/dhall/binary.rb +5 -1
@@ 193,8 193,12 @@ module Dhall
		def self.decode(integrity_check, import_type, path_type, *parts)
			parts[0] = Dhall.decode(parts[0]) if path_type < 2 && !parts[0].nil?

			check = if integrity_check
				IntegrityCheck.new(integrity_check[0], [integrity_check[1]].pack("H*"))
			end

			new(
				IntegrityCheck.new(*integrity_check),
				check,
				IMPORT_TYPES[import_type],
				PATH_TYPES[path_type].new(*parts)
			)

M lib/dhall/parser.rb => lib/dhall/parser.rb +1 -1
@@ 525,7 525,7 @@ module Dhall
		module Hash
			def value
				protocol, data = string.split(/:/, 2)
				Dhall::Import::IntegrityCheck.new(protocol, data)
				Dhall::Import::IntegrityCheck.new(protocol, [data].pack("H*"))
			end
		end