Class: Leeloo::PrivateLocalFileSystemPreferences
Constant Summary
collapse
- DEFAULT_PATH =
"#{Dir.home}/.leeloo"
Instance Attribute Summary
Attributes inherited from Preferences
#default
Instance Method Summary
collapse
Methods inherited from Preferences
#initialize, #keystore, #keystores
Instance Method Details
#add_keystore(keystore) ⇒ Object
86
87
88
89
90
|
# File 'lib/leeloo/preferences.rb', line 86
def add_keystore keystore
super keystore
FileUtils.mkdir_p keystore["path"]
File.write("#{@path}/keystores", @keystores.to_yaml)
end
|
#keystore_of(keystore_name) ⇒ Object
73
74
75
76
|
# File 'lib/leeloo/preferences.rb', line 73
def keystore_of keystore_name
keystore = @keystores.find { |keystore| keystore["name"] == keystore_name }
KeystoreFactory::create keystore
end
|
#load(path = DEFAULT_PATH) ⇒ Object
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/leeloo/preferences.rb', line 48
def load(path=DEFAULT_PATH)
@path = path
if File.exist? "#{path}/keystores"
@keystores = YAML.load_file "#{path}/keystores"
end
if File.exist? "#{path}/config"
config = YAML.load_file "#{path}/config"
set_default_keystore config["keystore"]
else
default_keystore = {
'name' => "private",
'path' => "#{path}/private",
'cypher' => "gpg",
'vc' => "git"
}
add_keystore default_keystore
set_default_keystore "private"
keystore_of("private").init
end
self
end
|
#remove_keystore(name) ⇒ Object
92
93
94
95
|
# File 'lib/leeloo/preferences.rb', line 92
def remove_keystore name
super name
File.write("#{@path}/keystores", @keystores.to_yaml)
end
|
#set_default_keystore(name) ⇒ Object
78
79
80
81
82
83
84
|
# File 'lib/leeloo/preferences.rb', line 78
def set_default_keystore name
super name
config = {
"keystore" => name
}
File.write("#{@path}/config", config.to_yaml)
end
|