Rename more methods
This commit is contained in:
parent
8fed4dc0bc
commit
589b683a12
|
@ -128,13 +128,13 @@ module Pigeon
|
|||
desc "create", "Create a pigeon bundle file"
|
||||
|
||||
def create(file_path = Pigeon::DEFAULT_BUNDLE_PATH)
|
||||
db.save_bundle(file_path)
|
||||
db.export_bundle(file_path)
|
||||
end
|
||||
|
||||
desc "ingest", "Ingest a pigeon bundle file"
|
||||
|
||||
def ingest(file_path = Pigeon::DEFAULT_BUNDLE_PATH)
|
||||
db.publish_bundle(file_path)
|
||||
db.import_bundle(file_path)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ module Pigeon
|
|||
end
|
||||
|
||||
# === BUNDLES
|
||||
def save_bundle(file_path = DEFAULT_BUNDLE_PATH)
|
||||
def export_bundle(file_path = DEFAULT_BUNDLE_PATH)
|
||||
# Fetch messages for all peers
|
||||
peers = all_peers + [who_am_i.multihash]
|
||||
messages = peers.map do |peer|
|
||||
|
@ -118,7 +118,7 @@ module Pigeon
|
|||
File.write(File.join(file_path, "gossip.pgn"), content + CR)
|
||||
end
|
||||
|
||||
def publish_bundle(file_path = DEFAULT_BUNDLE_PATH)
|
||||
def import_bundle(file_path = DEFAULT_BUNDLE_PATH)
|
||||
bundle = File.read(File.join(file_path, "gossip.pgn"))
|
||||
tokens = Pigeon::Lexer.tokenize(bundle)
|
||||
Pigeon::Parser.parse(self, tokens)
|
||||
|
|
|
@ -26,28 +26,28 @@ RSpec.describe Pigeon::Message do
|
|||
|
||||
it "creates a bundle" do
|
||||
expected_bundle = create_fake_messages.map(&:render).join("\n\n") + "\n"
|
||||
db.save_bundle
|
||||
db.export_bundle
|
||||
actual_bundle = File.read(File.join(Pigeon::DEFAULT_BUNDLE_PATH, "gossip.pgn"))
|
||||
expect(expected_bundle).to eq(actual_bundle)
|
||||
end
|
||||
|
||||
it "does not crash when ingesting old messages" do
|
||||
create_fake_messages
|
||||
db.save_bundle
|
||||
db.publish_bundle
|
||||
db.export_bundle
|
||||
db.import_bundle
|
||||
end
|
||||
|
||||
it "does not ingest messages from blocked peers" do
|
||||
db.reset_database
|
||||
antagonist = "@PPJQ3Q36W258VQ1NKYY2G7VW24J8NMAACHXCD83GCQ3K8F4C9X2G.ed25519"
|
||||
db.block_peer(antagonist)
|
||||
db.publish_bundle("./spec/fixtures/x")
|
||||
db.import_bundle("./spec/fixtures/x")
|
||||
expect(db.all_messages.count).to eq(0)
|
||||
end
|
||||
|
||||
it "ingests a bundle's blobs" do
|
||||
db.reset_database
|
||||
db.publish_bundle("./spec/fixtures/has_blobs")
|
||||
db.import_bundle("./spec/fixtures/has_blobs")
|
||||
expect(db.all_messages.count).to eq(0)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -30,7 +30,7 @@ RSpec.describe Pigeon::Lexer do
|
|||
end
|
||||
|
||||
it "ingests and reconstructs a bundle" do
|
||||
messages = db.publish_bundle("./spec/fixtures/normal")
|
||||
messages = db.import_bundle("./spec/fixtures/normal")
|
||||
expect(messages.length).to eq(10)
|
||||
expect(messages.map(&:class).uniq).to eq([Pigeon::Message])
|
||||
re_bundled = messages.map(&:render).join("\n\n") + "\n"
|
||||
|
|
|
@ -48,7 +48,7 @@ RSpec.describe Pigeon::Storage do
|
|||
end
|
||||
|
||||
it "finds all authored by a particular feed" do
|
||||
ingested_messages = db.publish_bundle("./spec/fixtures/normal")
|
||||
ingested_messages = db.import_bundle("./spec/fixtures/normal")
|
||||
author = ingested_messages.first.author.multihash
|
||||
actual_messages = db.all_messages(author)
|
||||
search_results = db.all_messages(author)
|
||||
|
|
|
@ -15,13 +15,13 @@
|
|||
# peer_blocked?
|
||||
# who_am_i
|
||||
# new_draft
|
||||
# publish_bundle
|
||||
# import_bundle
|
||||
# publish_draft
|
||||
# read_message
|
||||
# remove_peer
|
||||
# reset_database
|
||||
# reset_draft
|
||||
# save_bundle
|
||||
# export_bundle
|
||||
# save_draft
|
||||
# update_draft
|
||||
|
||||
|
@ -33,4 +33,4 @@ db = Pigeon::Database.new(path: "new.db")
|
|||
db.add_message("description", body)
|
||||
files.map { |file| db.add_blob(file) }
|
||||
binding.pry
|
||||
db.save_bundle("./spec/fixtures/has_blobs")
|
||||
db.export_bundle("./spec/fixtures/has_blobs")
|
||||
|
|
Loading…
Reference in New Issue