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