cliutils 1.2.2 → 1.2.3
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/HISTORY.md +9 -3
- data/README.md +1 -1
- data/lib/cliutils/configurator.rb +4 -4
- data/lib/cliutils/prefs.rb +10 -10
- data/lib/cliutils/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8d4b5956a8169f6d9921d0ed268188a65578fc9
|
4
|
+
data.tar.gz: fc2066b9c99902a3db434abceb0811ce6285eae5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 746e189a28faa6d4cc66653bfab9bd4c804bac063516432c2ebfb214fa10ed178f371e44f86ba223ac4ce84d881d5fca43c2daa3a809a066381772e5930c3280
|
7
|
+
data.tar.gz: 1cb57fd665d770383fca928c5aa7951e8a635e4f082d445649633e90873717b2ef0ae145459c093ae09bc1d838a4ece89daae44f3b19661c104f57e573f0c731
|
data/HISTORY.md
CHANGED
@@ -1,14 +1,20 @@
|
|
1
|
-
# 1.
|
1
|
+
# 1.2.3 (2014-04-05)
|
2
|
+
|
3
|
+
* Fixed a bug in ingest_prefs
|
4
|
+
* Fixed a bug in pref prompting
|
5
|
+
* Fixed a bug with including a Configurator in prefs
|
6
|
+
|
7
|
+
# 1.2.2 (2014-04-03)
|
2
8
|
|
3
9
|
* Modified loading of configuration values
|
4
10
|
* Updated documentation
|
5
11
|
|
6
|
-
# 1.
|
12
|
+
# 1.2.1 (2014-04-03)
|
7
13
|
|
8
14
|
* Updated documentation
|
9
15
|
* Added additional testing
|
10
16
|
|
11
|
-
# 1.
|
17
|
+
# 1.2.0 (2014-04-03)
|
12
18
|
|
13
19
|
* Changed Requirements => Prerequisites in Prefs
|
14
20
|
* Added Validators to Prefs
|
data/README.md
CHANGED
@@ -220,7 +220,7 @@ include CLIUtils::Configuration
|
|
220
220
|
### Loading a Configuration File
|
221
221
|
|
222
222
|
```Ruby
|
223
|
-
CLIUtils::Configuration.configuration =
|
223
|
+
CLIUtils::Configuration.configuration = '~/.my-app-config'
|
224
224
|
```
|
225
225
|
|
226
226
|
If there's data in there, it will be consumed into `configuration`'s `data` property.
|
@@ -55,10 +55,10 @@ module CLIUtils
|
|
55
55
|
# @param [Prefs] prefs The Prefs class to examine
|
56
56
|
# @return [void]
|
57
57
|
def ingest_prefs(prefs)
|
58
|
-
fail 'Invaid Prefs class' if !prefs.kind_of?(Prefs)
|
59
|
-
prefs.
|
60
|
-
add_section(p
|
61
|
-
@data[p
|
58
|
+
fail 'Invaid Prefs class' if !prefs.kind_of?(Prefs)
|
59
|
+
prefs.prompts.each do |p|
|
60
|
+
add_section(p.config_section.to_sym) unless @data.key?(p.config_section.to_sym)
|
61
|
+
@data[p.config_section.to_sym].merge!(p.config_key.to_sym => p.answer)
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
data/lib/cliutils/prefs.rb
CHANGED
@@ -16,7 +16,7 @@ module CLIUtils
|
|
16
16
|
|
17
17
|
# Stores answers to prompt questions.
|
18
18
|
# @return [Array]
|
19
|
-
attr_reader :
|
19
|
+
attr_reader :prompts
|
20
20
|
|
21
21
|
# Reads prompt data from and stores it.
|
22
22
|
# @param [<String, Hash, Array>] data Filepath to YAML, Hash, or Array
|
@@ -25,14 +25,14 @@ module CLIUtils
|
|
25
25
|
def initialize(data, configurator = nil)
|
26
26
|
@answers = []
|
27
27
|
@configurator = configurator
|
28
|
-
@
|
28
|
+
@prompts = []
|
29
29
|
|
30
30
|
case data
|
31
31
|
when String
|
32
32
|
if File.exists?(data)
|
33
33
|
@config_path = data
|
34
34
|
data = YAML::load_file(data).deep_symbolize_keys
|
35
|
-
@
|
35
|
+
@prompts = _generate_prefs(data)
|
36
36
|
else
|
37
37
|
fail "Invalid configuration file: #{ data }"
|
38
38
|
end
|
@@ -40,11 +40,11 @@ module CLIUtils
|
|
40
40
|
@config_path = nil
|
41
41
|
data = {:prompts => data} unless data.keys[0] == :prompts
|
42
42
|
data.deep_symbolize_keys!
|
43
|
-
@
|
43
|
+
@prompts = _generate_prefs(data)
|
44
44
|
when Array
|
45
45
|
@config_path = nil
|
46
46
|
data = {:prompts => data}.deep_symbolize_keys
|
47
|
-
@
|
47
|
+
@prompts = _generate_prefs(data)
|
48
48
|
else
|
49
49
|
fail 'Invalid configuration data'
|
50
50
|
end
|
@@ -56,11 +56,11 @@ module CLIUtils
|
|
56
56
|
# complete, questions w/ prerequisites are examined.
|
57
57
|
# @return [void]
|
58
58
|
def ask
|
59
|
-
@
|
59
|
+
@prompts.reject { |p| p.prereqs }.each do |p|
|
60
60
|
_deliver_prompt(p)
|
61
61
|
end
|
62
62
|
|
63
|
-
@
|
63
|
+
@prompts.find_all { |p| p.prereqs }.each do |p|
|
64
64
|
_deliver_prompt(p) if _prereqs_fulfilled?(p)
|
65
65
|
end
|
66
66
|
end
|
@@ -73,9 +73,9 @@ module CLIUtils
|
|
73
73
|
# @return [void]
|
74
74
|
def _deliver_prompt(p)
|
75
75
|
default = p.default
|
76
|
-
|
76
|
+
|
77
77
|
unless @configurator.nil?
|
78
|
-
unless @configurator.data[p.
|
78
|
+
unless @configurator.data[p.config_section.to_sym].nil?
|
79
79
|
config_val = @configurator.data[p.config_section.to_sym][p.config_key.to_sym]
|
80
80
|
default = config_val unless config_val.nil?
|
81
81
|
end
|
@@ -109,7 +109,7 @@ module CLIUtils
|
|
109
109
|
def _prereqs_fulfilled?(p)
|
110
110
|
ret = true
|
111
111
|
p.prereqs.each do |req|
|
112
|
-
a = @
|
112
|
+
a = @prompts.detect do |answer|
|
113
113
|
answer.config_key == req[:config_key] &&
|
114
114
|
answer.answer == req[:config_value]
|
115
115
|
end
|
data/lib/cliutils/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cliutils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Bach
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|