sistero 0.4.7 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/sistero/config.rb +22 -1
- data/lib/sistero/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e4048930bcc2a2f632980319e5a83eaf034b50c
|
4
|
+
data.tar.gz: 83230f81639f17f0fb1cff7bc9cb4dc71d53fbdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 837b46f87178b4e135db4d75b2264145915d39e34d1e758364ef65fc3017e70b5867e2321eaed8d809bcab039f797eee36ca5772575ab5e25c39f11aa9623da7
|
7
|
+
data.tar.gz: 2eff0e18edd34cedbf42dbbcb4e561496d9fedb089b247a14bf0bf95e6c499261c61bf4fc2000ccb06f0ece362392a1d3e103fb5f815dd97daf202cd8c77a067
|
data/lib/sistero/config.rb
CHANGED
@@ -35,12 +35,18 @@ module Sistero
|
|
35
35
|
|
36
36
|
def initialize(opts = {})
|
37
37
|
# read defaults from config file
|
38
|
-
cfg_file_path = opts[:cfg_file_path]
|
38
|
+
cfg_file_path = opts[:cfg_file_path]
|
39
|
+
unless cfg_file_path
|
40
|
+
cfg_file_path = 'sistero.yaml'
|
41
|
+
cfg_file_path = "#{ENV['HOME']}/.config/#{APP_NAME}" unless File.exists? cfg_file_path
|
42
|
+
end
|
39
43
|
|
40
44
|
@defaults = Profile.new
|
41
45
|
@profiles = []
|
42
46
|
|
43
47
|
cfg = YAML.load_file cfg_file_path
|
48
|
+
postprocess_cfg cfg
|
49
|
+
|
44
50
|
cfg['defaults'].each do |key, value|
|
45
51
|
@defaults[key] = value
|
46
52
|
end
|
@@ -59,5 +65,20 @@ module Sistero
|
|
59
65
|
def to_s
|
60
66
|
@profiles.map(&:to_s).join "\n"
|
61
67
|
end
|
68
|
+
|
69
|
+
private
|
70
|
+
def postprocess_cfg config
|
71
|
+
if config.is_a? Array
|
72
|
+
config.map &method(:postprocess_cfg)
|
73
|
+
elsif config.is_a? Hash
|
74
|
+
if config.length == 1 and config.has_key? 'file'
|
75
|
+
File.read(config['file']).strip
|
76
|
+
else
|
77
|
+
config.update(config) { |key, val| postprocess_cfg val }
|
78
|
+
end
|
79
|
+
else
|
80
|
+
config
|
81
|
+
end
|
82
|
+
end
|
62
83
|
end
|
63
84
|
end
|
data/lib/sistero/version.rb
CHANGED