Class: SafeDb::FileTree
- Inherits:
-
Object
- Object
- SafeDb::FileTree
- Defined in:
- lib/model/file_tree.rb
Overview
This class knows the location of the main indices and crypt files and folders both for the master and branch lines.
More importantly, it knows where the master crypts and indices are given a book id, and also the branch crypts and indices, given a branch id.
Class Method Summary collapse
- .branch_crypts_filepath(book_id, branch_id, content_id) ⇒ Object
- .branch_crypts_folder(book_id, branch_id) ⇒ Object
-
.branch_indices_filepath(branch_id) ⇒ File
Get the path to the branch indices file for the branch ID specified in the parameter.
-
.master_crypts_filepath(book_id, content_id) ⇒ File
Find the path to the file that contains the book index within the master (not branch) line.
-
.master_crypts_folder(book_id) ⇒ File
Get the path to the folder that holds the master crypts for the book ID specified in the parameter.
Class Method Details
.branch_crypts_filepath(book_id, branch_id, content_id) ⇒ Object
34 35 36 |
# File 'lib/model/file_tree.rb', line 34 def self.branch_crypts_filepath( book_id, branch_id, content_id ) return File.join( branch_crypts_folder( book_id, branch_id ), "safedb.chapter.#{content_id}.txt" ) end |
.branch_crypts_folder(book_id, branch_id) ⇒ Object
39 40 41 |
# File 'lib/model/file_tree.rb', line 39 def self.branch_crypts_folder( book_id, branch_id ) return File.join( Indices::BRANCH_CRYPTS_FOLDER_PATH, "safedb-branch-#{book_id}-#{branch_id}" ) end |
.branch_indices_filepath(branch_id) ⇒ File
Get the path to the branch indices file for the branch ID specified in the parameter.
48 49 50 |
# File 'lib/model/file_tree.rb', line 48 def self.branch_indices_filepath( branch_id ) return File.join( Indices::BRANCH_INDICES_FOLDER_PATH, "safedb-indices-#{branch_id}.ini" ) end |
.master_crypts_filepath(book_id, content_id) ⇒ File
Find the path to the file that contains the book index within the master (not branch) line. We need the book identifier and the file’s content identifier to derive the path.
20 21 22 |
# File 'lib/model/file_tree.rb', line 20 def self.master_crypts_filepath( book_id, content_id ) return File.join( master_crypts_folder( book_id ), "safedb.chapter.#{content_id}.txt" ) end |
.master_crypts_folder(book_id) ⇒ File
Get the path to the folder that holds the master crypts for the book ID specified in the parameter.
29 30 31 |
# File 'lib/model/file_tree.rb', line 29 def self.master_crypts_folder( book_id ) return File.join( Indices::MASTER_CRYPTS_FOLDER_PATH, "safedb.book.#{book_id}" ) end |