2020-03-15 16:51:13 +00:00
|
|
|
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)
|
2020-04-06 12:35:27 +00:00
|
|
|
.map { |multihash| s.read_message(multihash) }
|
2020-04-06 12:32:19 +00:00
|
|
|
.sort_by(&:depth)
|
2020-03-15 16:51:13 +00:00
|
|
|
.map { |message| message.render }
|
|
|
|
.join(BUNDLE_MESSAGE_SEPARATOR)
|
2020-03-15 17:50:57 +00:00
|
|
|
File.write(file_path, content + CR)
|
2020-03-15 16:51:13 +00:00
|
|
|
end
|
|
|
|
|
2020-04-01 13:25:27 +00:00
|
|
|
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!)
|
2020-03-15 16:51:13 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|