Pigeon-Ruby/dist/pigeon/bundle.rb

21 lines
610 B
Ruby
Raw Normal View History

module Pigeon
class Bundle
def self.create(file_path = DEFAULT_BUNDLE_PATH)
s = Pigeon::Storage.current
2020-04-06 12:32:19 +00:00
content = s
.find_all(Pigeon::LocalIdentity.current.multihash)
.map { |multihash| s.read_message(multihash) }
2020-04-06 12:32:19 +00:00
.sort_by(&:depth)
.map { |message| message.render }
.join(BUNDLE_MESSAGE_SEPARATOR)
File.write(file_path, content + CR)
end
def self.ingest(file_path = DEFAULT_BUNDLE_PATH)
2020-03-31 12:30:44 +00:00
bundle = File.read(file_path)
tokens = Pigeon::Lexer.tokenize(bundle)
2020-04-10 12:13:42 +00:00
Pigeon::Parser.parse(tokens) #.map(&:save!)
end
end
end