Class: ZKSync::Archive
- Inherits:
-
Object
- Object
- ZKSync::Archive
- Defined in:
- lib/zksync/archive.rb
Instance Attribute Summary collapse
-
#file_index ⇒ Object
readonly
Returns the value of attribute file_index.
-
#fs_base_path ⇒ Object
readonly
Returns the value of attribute fs_base_path.
-
#keystore ⇒ Object
readonly
Returns the value of attribute keystore.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
-
#add(fs_paths) ⇒ Object
add fs-paths to the archive.
- #add_file(fs_path) ⇒ Object
- #commit ⇒ Object
- #file_at_path(archive_path) ⇒ Object
-
#initialize(passphrase, fs_base_path, root) ⇒ Archive
constructor
A new instance of Archive.
- #inode_for_path(archive_path) ⇒ Object
-
#list ⇒ Object
list of all archive paths in this archive.
- #rm(*archive_paths) ⇒ Object
Constructor Details
#initialize(passphrase, fs_base_path, root) ⇒ Archive
Returns a new instance of Archive.
22 23 24 25 26 27 |
# File 'lib/zksync/archive.rb', line 22 def initialize(passphrase, fs_base_path, root) @root = root @fs_base_path = fs_base_path @keystore = KeyStore.new(Key.new(passphrase, type: :passphrase)) @file_index = CryptoFileIndex.new("@@index", self) end |
Instance Attribute Details
#file_index ⇒ Object (readonly)
Returns the value of attribute file_index.
20 21 22 |
# File 'lib/zksync/archive.rb', line 20 def file_index @file_index end |
#fs_base_path ⇒ Object (readonly)
Returns the value of attribute fs_base_path.
20 21 22 |
# File 'lib/zksync/archive.rb', line 20 def fs_base_path @fs_base_path end |
#keystore ⇒ Object (readonly)
Returns the value of attribute keystore.
20 21 22 |
# File 'lib/zksync/archive.rb', line 20 def keystore @keystore end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
20 21 22 |
# File 'lib/zksync/archive.rb', line 20 def root @root end |
Instance Method Details
#add(fs_paths) ⇒ Object
add fs-paths to the archive. returns array of paths that were not added successfully. archive paths are stored relative to basepath
31 32 33 34 35 |
# File 'lib/zksync/archive.rb', line 31 def add(fs_paths) [*fs_paths] .map { |fs_path| File.(fs_path) } .reject { |fs_path| add_file(fs_path) } end |
#add_file(fs_path) ⇒ Object
60 61 62 63 |
# File 'lib/zksync/archive.rb', line 60 def add_file(fs_path) archive_path = Pathname.new(fs_path).relative_path_from(Pathname.new(fs_base_path)).to_s @file_index.add(archive_path, fs_path) end |
#commit ⇒ Object
46 47 48 |
# File 'lib/zksync/archive.rb', line 46 def commit @file_index.write end |
#file_at_path(archive_path) ⇒ Object
50 51 52 |
# File 'lib/zksync/archive.rb', line 50 def file_at_path(archive_path) @file_index.file_at_path(archive_path) end |
#inode_for_path(archive_path) ⇒ Object
54 55 56 |
# File 'lib/zksync/archive.rb', line 54 def inode_for_path(archive_path) @file_index.inode_for_path(archive_path) end |
#list ⇒ Object
list of all archive paths in this archive
38 39 40 |
# File 'lib/zksync/archive.rb', line 38 def list @file_index.list end |
#rm(*archive_paths) ⇒ Object
42 43 44 |
# File 'lib/zksync/archive.rb', line 42 def rm(*archive_paths) archive_paths.each { |archive_path| @file_index.rm(archive_path) } end |