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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1854c822720ec6193e9973bdf56d912e6060b4ec
4
- data.tar.gz: d3e7066e5cc1bc7252520122e05475c6e0dd787d
3
+ metadata.gz: f8d4b5956a8169f6d9921d0ed268188a65578fc9
4
+ data.tar.gz: fc2066b9c99902a3db434abceb0811ce6285eae5
5
5
  SHA512:
6
- metadata.gz: affe0adf4c8debf539318464cd12a82dc67801da37cabdbf9fd0c594acf828d658e9da5145c91c2eaee20c06be71054209dff296e9c1f7a7602ae38a752fd6b9
7
- data.tar.gz: bda380364bb52f92110f4f7827461910472022cb1ad087be42ffc34bff3f50cd5db3dd491de7acc648b84b8db50054dfef57476d8d968c15dca52bf85b83ad8c
6
+ metadata.gz: 746e189a28faa6d4cc66653bfab9bd4c804bac063516432c2ebfb214fa10ed178f371e44f86ba223ac4ce84d881d5fca43c2daa3a809a066381772e5930c3280
7
+ data.tar.gz: 1cb57fd665d770383fca928c5aa7951e8a635e4f082d445649633e90873717b2ef0ae145459c093ae09bc1d838a4ece89daae44f3b19661c104f57e573f0c731
data/HISTORY.md CHANGED
@@ -1,14 +1,20 @@
1
- # 1.1.1 (2014-04-03)
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.1.1 (2014-04-03)
12
+ # 1.2.1 (2014-04-03)
7
13
 
8
14
  * Updated documentation
9
15
  * Added additional testing
10
16
 
11
- # 1.1.0 (2014-04-03)
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 = ('~/.my-app-config')
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) || prefs.answers.nil?
59
- prefs.answers.each do |p|
60
- add_section(p[:section].to_sym) unless @data.key?(p[:section].to_sym)
61
- @data[p[:section].to_sym].merge!(p[:key].to_sym => p[:answer])
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
 
@@ -16,7 +16,7 @@ module CLIUtils
16
16
 
17
17
  # Stores answers to prompt questions.
18
18
  # @return [Array]
19
- attr_reader :prefs
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
- @prefs = []
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
- @prefs = _generate_prefs(data)
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
- @prefs = _generate_prefs(data)
43
+ @prompts = _generate_prefs(data)
44
44
  when Array
45
45
  @config_path = nil
46
46
  data = {:prompts => data}.deep_symbolize_keys
47
- @prefs = _generate_prefs(data)
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
- @prefs.reject { |p| p.prereqs }.each do |p|
59
+ @prompts.reject { |p| p.prereqs }.each do |p|
60
60
  _deliver_prompt(p)
61
61
  end
62
62
 
63
- @prefs.find_all { |p| p.prereqs }.each do |p|
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.section.to_sym].nil?
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 = @prefs.detect do |answer|
112
+ a = @prompts.detect do |answer|
113
113
  answer.config_key == req[:config_key] &&
114
114
  answer.answer == req[:config_value]
115
115
  end
@@ -1,4 +1,4 @@
1
1
  module CLIUtils
2
2
  # The current version of the gem
3
- VERSION = '1.2.2'
3
+ VERSION = '1.2.3'
4
4
  end
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.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-05 00:00:00.000000000 Z
11
+ date: 2014-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler