remove Cache#validate_json_object - #92
This commit is contained in:
parent
5cb895f465
commit
d0cd0a14a4
@ -100,7 +100,6 @@ module Rscons
|
|||||||
# @return [void]
|
# @return [void]
|
||||||
def write
|
def write
|
||||||
@cache["version"] = VERSION
|
@cache["version"] = VERSION
|
||||||
validate_json_object(@cache)
|
|
||||||
File.open(CACHE_FILE, "w") do |fh|
|
File.open(CACHE_FILE, "w") do |fh|
|
||||||
fh.puts(JSON.dump(@cache))
|
fh.puts(JSON.dump(@cache))
|
||||||
end
|
end
|
||||||
@ -384,20 +383,5 @@ module Rscons
|
|||||||
@lookup_checksums[file] = Digest::MD5.hexdigest(File.read(file, mode: "rb")) rescue ""
|
@lookup_checksums[file] = Digest::MD5.hexdigest(File.read(file, mode: "rb")) rescue ""
|
||||||
end
|
end
|
||||||
|
|
||||||
# Validate that an object is one of a known set of values that can be
|
|
||||||
# serialized properly with JSON.
|
|
||||||
#
|
|
||||||
# @param o [Object]
|
|
||||||
# Object to validate.
|
|
||||||
def validate_json_object(o)
|
|
||||||
if o.is_a?(Array)
|
|
||||||
o.each {|v| validate_json_object(v)}
|
|
||||||
elsif o.is_a?(Hash)
|
|
||||||
o.each {|*kv| validate_json_object(kv)}
|
|
||||||
elsif [NilClass, TrueClass, FalseClass, String].none? {|c| o.is_a?(c)}
|
|
||||||
raise "Unexpected cache value for serialization: #{o.inspect}"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -65,12 +65,5 @@ module Rscons
|
|||||||
expect(build_from({}).send(:calculate_checksum, "fname")).to eq "the_checksum"
|
expect(build_from({}).send(:calculate_checksum, "fname")).to eq "the_checksum"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#validate_json_object" do
|
|
||||||
it "raises an error when an unexpected object is passed" do
|
|
||||||
cache = build_from({})
|
|
||||||
expect {cache.__send__(:validate_json_object, :symbol)}.to raise_error /Unexpected cache value/
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user