Class: GitBlog::Storage

Inherits:
Object
  • Object
show all
Defined in:
lib/git-blog/storage.rb

Constant Summary collapse

BASE_PATH =
"~/.git-blog"

Class Method Summary collapse

Class Method Details

.commit_msg_script_pathObject



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_dictObject



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_pathObject



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_pathObject



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_pathObject



9
10
11
# File 'lib/git-blog/storage.rb', line 9

def self.storage_base_path
	File.expand_path BASE_PATH
end