Class: GitBlog::Storage
- Inherits:
-
Object
- Object
- GitBlog::Storage
- Defined in:
- lib/git-blog/storage.rb
Constant Summary collapse
- BASE_PATH =
"~/.git-blog"
Class Method Summary collapse
- .commit_msg_script_path ⇒ Object
- .config_dict ⇒ Object
- .config_path ⇒ Object
- .prepare_commit_msg_template_path ⇒ Object
- .save_config_dict(dict) ⇒ Object
- .storage_base_path ⇒ Object
Class Method Details
.commit_msg_script_path ⇒ Object
21 22 23 |
# File 'lib/git-blog/storage.rb', line 21 def self.commit_msg_script_path File.join storage_base_path, "commit-msg" end |
.config_dict ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/git-blog/storage.rb', line 25 def self.config_dict dict = nil path = Storage::config_path if File.exists? path dict = JSON.parse(File.read(path)) end dict end |
.config_path ⇒ Object
13 14 15 |
# File 'lib/git-blog/storage.rb', line 13 def self.config_path File.join storage_base_path, "config.json" end |
.prepare_commit_msg_template_path ⇒ Object
17 18 19 |
# File 'lib/git-blog/storage.rb', line 17 def self.prepare_commit_msg_template_path File.join storage_base_path, "prepare-commit-msg" end |
.save_config_dict(dict) ⇒ Object
36 37 38 39 40 |
# File 'lib/git-blog/storage.rb', line 36 def self.save_config_dict dict FileUtils.mkdir_p Storage::storage_base_path path = Storage::config_path File.open(path, "w") { |file| file.write dict.to_json } end |
.storage_base_path ⇒ Object
9 10 11 |
# File 'lib/git-blog/storage.rb', line 9 def self.storage_base_path File. BASE_PATH end |