Constantize sigils
This commit is contained in:
parent
e260fc7bb0
commit
7223906613
|
@ -29,7 +29,10 @@ module Pigeon
|
|||
BLCK_NS = "blocked"
|
||||
# ^ Internal namespaces for PStore keys
|
||||
|
||||
BLOB_HEADER = "&"
|
||||
BLOB_SIGIL = "&"
|
||||
SIGNATURE_SIGIL = "%"
|
||||
IDENTITY_SIGIL = "@"
|
||||
STRING_SIGIL = "\""
|
||||
BLOB_FOOTER = ".sha256"
|
||||
end
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ module Pigeon
|
|||
puts "TODO: Add #readonly? method and disallow edits after save"
|
||||
# TODO: Sanitize, validate inputs.
|
||||
case value[0]
|
||||
when "%", "@", "&", "\"" # TODO: Use constants, not literals.
|
||||
when BLOB_SIGIL, SIGNATURE_SIGIL, IDENTITY_SIGIL, STRING_SIGIL
|
||||
self.body[key] = value
|
||||
else
|
||||
self.body[key] = value.inspect
|
||||
|
|
|
@ -32,11 +32,11 @@ module Pigeon
|
|||
store[BLOB_NS][hex_digest] = data
|
||||
end
|
||||
|
||||
[BLOB_HEADER, hex_digest, BLOB_FOOTER].join("")
|
||||
[BLOB_SIGIL, hex_digest, BLOB_FOOTER].join("")
|
||||
end
|
||||
|
||||
def get_blob(hex_digest)
|
||||
hd = hex_digest.gsub(BLOB_HEADER, "").gsub(BLOB_FOOTER, "")
|
||||
hd = hex_digest.gsub(BLOB_SIGIL, "").gsub(BLOB_FOOTER, "")
|
||||
store.transaction(true) do
|
||||
store[BLOB_NS] ||= {}
|
||||
store[BLOB_NS][hd]
|
||||
|
|
Loading…
Reference in New Issue