More string constants

This commit is contained in:
Netscape Navigator 2020-05-14 08:32:57 -05:00
parent b06eda6356
commit 9ec6861624
5 changed files with 8 additions and 9 deletions

View File

@ -47,7 +47,6 @@ See `kitchen_sink.sh` examples.
# Current Status
- [ ] Change message templates to render headers in this order: `author`, `prev`, `lipmaa`, `depth`, `kind`.
- [ ] Make location of blob folder configurable?
- [ ] Change `@`, `%`, `&` to `feed.`, `mesg.`, `blob.`, respectively. Better readability, easier onboarding, URL friendly.
- [ ] Update Dev docs in protocol spec to reflect changes to `lipmaa` header.
- [ ] Update spec document CLI usage examples to reflect API changes in 2020.

View File

@ -10,7 +10,7 @@ module Pigeon
PIGEON_DB_PATH = File.join("pigeon.db")
DEFAULT_BUNDLE_PATH = File.join(Dir.pwd, "bundle")
PIGEON_BLOB_PATH = File.join(Dir.home, "pigeon_sha256")
DEFAULT_BLOB_DIR = File.join(Dir.home, "pigeon_sha256")
MESSAGE_FILE = "messages.pgn"
# MESSAGE TEMPLATE CONSTANTS:
HEADER_TPL = "author <%= author %>\nkind <%= kind %>\nprev <%= prev %>\ndepth <%= depth %>\nlipmaa <%= lipmaa %>\n\n"

View File

@ -161,10 +161,10 @@ module Pigeon
.map do |mhash|
rel_path = Helpers.hash2file_path(mhash)
from = File.join([file_path] + rel_path)
to = File.join([PIGEON_BLOB_PATH] + rel_path)
to = File.join([DEFAULT_BLOB_DIR] + rel_path)
if (File.file?(from) && !File.file?(to))
data = File.read(from)
Helpers.write_to_disk(PIGEON_BLOB_PATH, mhash, data)
Helpers.write_to_disk(DEFAULT_BLOB_DIR, mhash, data)
end
end
messages

View File

@ -67,7 +67,7 @@ module Pigeon
def get_blob(blob_multihash)
path1 = File.join(Helpers.hash2file_path(blob_multihash))
path2 = File.join(PIGEON_BLOB_PATH, path1)
path2 = File.join(DEFAULT_BLOB_DIR, path1)
File.read(path2) if File.file?(path2)
end
@ -125,14 +125,14 @@ module Pigeon
end
def have_blob?(multihash)
path = File.join(PIGEON_BLOB_PATH, Helpers.hash2file_path(multihash))
path = File.join(DEFAULT_BLOB_DIR, Helpers.hash2file_path(multihash))
File.file?(path)
end
private
def write_to_disk(mhash, data)
Helpers.write_to_disk(PIGEON_BLOB_PATH, mhash, data)
Helpers.write_to_disk(DEFAULT_BLOB_DIR, mhash, data)
end
def bootstrap
@ -144,7 +144,7 @@ module Pigeon
store[MESSAGE_BY_DEPTH_NS] ||= {}
store[PEER_NS] ||= Set.new
end
Helpers.mkdir_p(PIGEON_BLOB_PATH)
Helpers.mkdir_p(DEFAULT_BLOB_DIR)
store
end

View File

@ -3,7 +3,7 @@ require "spec_helper"
RSpec.describe Pigeon::Message do
before(:each) do
puts "WARNING: This test deletes the blob dir! Fix ASAP"
`rm -rf #{Pigeon::PIGEON_BLOB_PATH}`
`rm -rf #{Pigeon::DEFAULT_BLOB_DIR}`
p = Pigeon::DEFAULT_BUNDLE_PATH
File.delete(p) if File.file?(p)
end