Class: Stella::Config
- Inherits:
-
Storable
- Object
- Storable
- Stella::Config
show all
- Includes:
- Gibbler::Complex
- Defined in:
- lib/stella/config.rb
Defined Under Namespace
Classes: AlreadyInitialized
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.blast ⇒ Object
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/stella/config.rb', line 45
def self.blast
if File.exists? USER_PATH
Stella.li "Blasting #{USER_PATH}"
FileUtils.rm_rf File.dirname(USER_PATH)
end
if File.exists? PROJECT_PATH
Stella.li "Blasting #{PROJECT_PATH}"
FileUtils.rm_rf File.dirname(PROJECT_PATH)
end
end
|
.each_path(&blk) ⇒ Object
13
14
15
16
17
18
|
# File 'lib/stella/config.rb', line 13
def self.each_path(&blk)
[PROJECT_PATH, USER_PATH].each do |path|
Stella.ld "Loading #{path}"
blk.call(path) if File.exists? path
end
end
|
.init ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/stella/config.rb', line 29
def self.init
raise AlreadyInitialized, PROJECT_PATH if File.exists? PROJECT_PATH
dir = File.dirname USER_PATH
Dir.mkdir(dir, 0700) unless File.exists? dir
unless File.exists? USER_PATH
Stella.li "Creating #{USER_PATH} (Add your credentials here)"
Stella::Utils.write_to_file(USER_PATH, DEFAULT_CONFIG, 'w', 0600)
end
dir = File.dirname PROJECT_PATH
Dir.mkdir(dir, 0700) unless File.exists? dir
Stella.li "Creating #{PROJECT_PATH}"
Stella::Utils.write_to_file(PROJECT_PATH, 'target:', 'w', 0600)
end
|
.refresh ⇒ Object
20
21
22
23
24
25
26
27
|
# File 'lib/stella/config.rb', line 20
def self.refresh
conf = {}
Stella::Config.each_path do |path|
tmp = YAML.load_file path
conf.merge! tmp if tmp
end
from_hash conf
end
|
Instance Method Details
#default? ⇒ Boolean
Returns true when the current config matches the default config
11
|
# File 'lib/stella/config.rb', line 11
def default?; to_hash.gibbler == DEFAULT_CONFIG_HASH; end
|