Class: GitChain::Storage
- Inherits:
-
Object
- Object
- GitChain::Storage
- Defined in:
- lib/git_chain/storage.rb
Constant Summary collapse
- FILE_NAME =
".git_chains"- FORMAT_VERSION =
"1"
Instance Attribute Summary collapse
-
#file_name ⇒ Object
readonly
Returns the value of attribute file_name.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#initialize(path: nil, file_name: nil) ⇒ Storage
constructor
A new instance of Storage.
- #print ⇒ Object
- #print_branch(branch:) ⇒ Object
- #record_for(child) ⇒ Object
- #save_data ⇒ Object
- #update_record(child:, parent:, base:) ⇒ Object
Constructor Details
Instance Attribute Details
#file_name ⇒ Object (readonly)
Returns the value of attribute file_name.
5 6 7 |
# File 'lib/git_chain/storage.rb', line 5 def file_name @file_name end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
5 6 7 |
# File 'lib/git_chain/storage.rb', line 5 def file_path @file_path end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
5 6 7 |
# File 'lib/git_chain/storage.rb', line 5 def path @path end |
Instance Method Details
#print ⇒ Object
31 32 33 |
# File 'lib/git_chain/storage.rb', line 31 def print pp data end |
#print_branch(branch:) ⇒ Object
35 36 37 |
# File 'lib/git_chain/storage.rb', line 35 def print_branch(branch: ) pp record_for(branch) end |
#record_for(child) ⇒ Object
13 14 15 |
# File 'lib/git_chain/storage.rb', line 13 def record_for(child) records[child.to_sym] end |
#save_data ⇒ Object
27 28 29 |
# File 'lib/git_chain/storage.rb', line 27 def save_data File.write(file_path, data.to_json) end |
#update_record(child:, parent:, base:) ⇒ Object
17 18 19 20 21 22 23 24 25 |
# File 'lib/git_chain/storage.rb', line 17 def update_record(child:, parent:, base:) records[child.to_sym] = { parent: parent, child: child, base: base, } save_data end |