configliere 0.3.4 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +3 -0
- data/.watchr +20 -0
- data/CHANGELOG.textile +99 -3
- data/Gemfile +26 -0
- data/Gemfile.lock +54 -0
- data/README.textile +162 -138
- data/Rakefile +30 -21
- data/VERSION +1 -1
- data/bin/configliere +77 -77
- data/bin/configliere-decrypt +85 -0
- data/bin/configliere-delete +85 -0
- data/bin/configliere-dump +85 -0
- data/bin/configliere-encrypt +85 -0
- data/bin/configliere-list +85 -0
- data/bin/configliere-set +85 -0
- data/configliere.gemspec +53 -23
- data/examples/config_block_script.rb +9 -2
- data/examples/encrypted_script.rb +28 -16
- data/examples/env_var_script.rb +2 -2
- data/examples/help_message_demo.rb +16 -0
- data/examples/independent_config.rb +28 -0
- data/examples/prompt.rb +23 -0
- data/examples/simple_script.rb +28 -15
- data/examples/simple_script.yaml +1 -1
- data/lib/configliere.rb +22 -24
- data/lib/configliere/commandline.rb +135 -116
- data/lib/configliere/commands.rb +38 -54
- data/lib/configliere/config_block.rb +4 -2
- data/lib/configliere/config_file.rb +30 -52
- data/lib/configliere/crypter.rb +8 -5
- data/lib/configliere/deep_hash.rb +368 -0
- data/lib/configliere/define.rb +83 -89
- data/lib/configliere/encrypted.rb +17 -18
- data/lib/configliere/env_var.rb +5 -7
- data/lib/configliere/param.rb +37 -64
- data/lib/configliere/prompt.rb +23 -0
- data/spec/configliere/commandline_spec.rb +156 -57
- data/spec/configliere/commands_spec.rb +75 -30
- data/spec/configliere/config_block_spec.rb +10 -1
- data/spec/configliere/config_file_spec.rb +83 -55
- data/spec/configliere/crypter_spec.rb +3 -2
- data/spec/configliere/deep_hash_spec.rb +401 -0
- data/spec/configliere/define_spec.rb +121 -42
- data/spec/configliere/encrypted_spec.rb +53 -20
- data/spec/configliere/env_var_spec.rb +24 -4
- data/spec/configliere/param_spec.rb +25 -27
- data/spec/configliere/prompt_spec.rb +50 -0
- data/spec/configliere_spec.rb +3 -9
- data/spec/spec_helper.rb +17 -6
- metadata +110 -35
- data/lib/configliere/core_ext.rb +0 -2
- data/lib/configliere/core_ext/blank.rb +0 -93
- data/lib/configliere/core_ext/hash.rb +0 -108
- data/lib/configliere/core_ext/sash.rb +0 -170
- data/spec/configliere/core_ext/hash_spec.rb +0 -78
- data/spec/configliere/core_ext/sash_spec.rb +0 -312
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe "Configliere::Prompt" do
|
4
|
+
before do
|
5
|
+
@config = Configliere::Param.new
|
6
|
+
@config.use :prompt
|
7
|
+
@config.define :underpants, :description => 'boxers or briefs'
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'when the value is already set, #prompt_for' do
|
11
|
+
it 'returns the value' do
|
12
|
+
@config[:underpants] = :boxers
|
13
|
+
@config.prompt_for(:underpants).should == :boxers
|
14
|
+
end
|
15
|
+
it 'returns the value even if nil' do
|
16
|
+
@config[:underpants] = nil
|
17
|
+
@config.prompt_for(:underpants).should == nil
|
18
|
+
end
|
19
|
+
it 'returns the value even if nil' do
|
20
|
+
@config[:underpants] = false
|
21
|
+
@config.prompt_for(:underpants).should == false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'when prompting, #prompt_for' do
|
26
|
+
it 'prompts for a value if missing' do
|
27
|
+
@config.should_receive(:ask).with("surprise_param? ")
|
28
|
+
@config.prompt_for(:surprise_param)
|
29
|
+
end
|
30
|
+
it 'uses an explicit hint' do
|
31
|
+
@config.should_receive(:ask).with("underpants (wearing any)? ")
|
32
|
+
@config.prompt_for(:underpants, "wearing any")
|
33
|
+
end
|
34
|
+
it 'uses the description as hint if none given' do
|
35
|
+
@config.should_receive(:ask).with("underpants (boxers or briefs)? ")
|
36
|
+
@config.prompt_for(:underpants)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#resolve!' do
|
41
|
+
it 'calls super and returns self' do
|
42
|
+
Configliere::ParamParent.class_eval do def resolve!() dummy ; end ; end
|
43
|
+
@config.should_receive(:dummy)
|
44
|
+
@config.resolve!.should equal(@config)
|
45
|
+
Configliere::ParamParent.class_eval do def resolve!() self ; end ; end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
data/spec/configliere_spec.rb
CHANGED
@@ -1,21 +1,15 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
describe "Configliere" do
|
4
|
-
it 'creates a
|
5
|
-
mock_param = 'mock_param'
|
6
|
-
Configliere::Param.should_receive(:new).with(:this => :that).and_return(mock_param)
|
7
|
-
Configliere.new(:this => :that).should == mock_param
|
8
|
-
end
|
9
|
-
it 'creates a global variable Settings' do
|
4
|
+
it 'creates a global variable Settings, for universality' do
|
10
5
|
Settings.class.should == Configliere::Param
|
11
6
|
end
|
12
|
-
it 'creates a
|
7
|
+
it 'creates a global method Settings, so you can say Settings(:foo => :bar)' do
|
13
8
|
Settings.should_receive(:defaults).with(:foo => :bar)
|
14
9
|
Settings(:foo => :bar)
|
15
10
|
end
|
16
11
|
|
17
|
-
it 'requires
|
12
|
+
it 'requires corresponding plugins when you call use' do
|
18
13
|
lambda{ Configliere.use(:param, :foo) }.should raise_error(LoadError, 'no such file to load -- configliere/foo')
|
19
14
|
end
|
20
|
-
|
21
15
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,21 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'rubygems'
|
3
|
+
require 'spork'
|
4
|
+
require 'rspec'
|
3
5
|
|
4
|
-
|
5
|
-
|
6
|
-
|
6
|
+
Spork.prefork do
|
7
|
+
# Loading more in this block will cause your tests to run faster.
|
8
|
+
# However, changes don't take effect until you restart spork.
|
7
9
|
|
8
|
-
|
10
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
11
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
12
|
+
|
13
|
+
require 'configliere'
|
9
14
|
|
10
15
|
end
|
16
|
+
|
17
|
+
Spork.each_run do
|
18
|
+
# This code will be run each time you run your specs.
|
19
|
+
|
20
|
+
end
|
21
|
+
|
metadata
CHANGED
@@ -1,55 +1,118 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: configliere
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 3
|
8
|
-
- 4
|
9
|
-
version: 0.3.4
|
4
|
+
prerelease:
|
5
|
+
version: 0.4.4
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
8
|
+
- infochimps
|
12
9
|
- mrflip
|
13
10
|
autorequire:
|
14
11
|
bindir: bin
|
15
12
|
cert_chain: []
|
16
13
|
|
17
|
-
date: 2011-
|
18
|
-
default_executable:
|
14
|
+
date: 2011-05-16 00:00:00 -05:00
|
15
|
+
default_executable:
|
19
16
|
dependencies:
|
20
17
|
- !ruby/object:Gem::Dependency
|
21
|
-
name:
|
22
|
-
prerelease: false
|
18
|
+
name: bundler
|
23
19
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
20
|
none: false
|
25
21
|
requirements:
|
26
|
-
- -
|
22
|
+
- - ~>
|
27
23
|
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
- 1
|
30
|
-
- 2
|
31
|
-
- 9
|
32
|
-
version: 1.2.9
|
24
|
+
version: 1.0.12
|
33
25
|
type: :development
|
26
|
+
prerelease: false
|
34
27
|
version_requirements: *id001
|
35
28
|
- !ruby/object:Gem::Dependency
|
36
29
|
name: yard
|
37
|
-
prerelease: false
|
38
30
|
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ~>
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: 0.6.7
|
36
|
+
type: :development
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: *id002
|
39
|
+
- !ruby/object:Gem::Dependency
|
40
|
+
name: jeweler
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.5.2
|
47
|
+
type: :development
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: *id003
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: rspec
|
52
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ~>
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: 2.5.0
|
58
|
+
type: :development
|
59
|
+
prerelease: false
|
60
|
+
version_requirements: *id004
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: spork
|
63
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.9.0.rc5
|
69
|
+
type: :development
|
70
|
+
prerelease: false
|
71
|
+
version_requirements: *id005
|
72
|
+
- !ruby/object:Gem::Dependency
|
73
|
+
name: RedCloth
|
74
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
39
75
|
none: false
|
40
76
|
requirements:
|
41
77
|
- - ">="
|
42
78
|
- !ruby/object:Gem::Version
|
43
|
-
segments:
|
44
|
-
- 0
|
45
79
|
version: "0"
|
46
80
|
type: :development
|
47
|
-
|
81
|
+
prerelease: false
|
82
|
+
version_requirements: *id006
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: gorillib
|
85
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 0.0.4
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: *id007
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: highline
|
96
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.5.2
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: *id008
|
48
105
|
description: " You've got a script. It's got some settings. Some settings are for this module, some are for that module. Most of them don't change. Except on your laptop, where the paths are different. Or when you're in production mode. Or when you're testing from the command line.\n\n \"\" So, Consigliere of mine, I think you should tell your Don what everyone knows. \"\" -- Don Corleone\n\n\
|
49
106
|
Configliere manage settings from many sources: static constants, simple config files, environment variables, commandline options, straight ruby. You don't have to predefine anything, but you can ask configliere to type-convert, require, document or password-obscure any of its fields. Modules can define config settings independently of each other and the main program.\n"
|
50
|
-
email:
|
107
|
+
email: coders@infochimps.org
|
51
108
|
executables:
|
52
109
|
- configliere
|
110
|
+
- configliere-decrypt
|
111
|
+
- configliere-delete
|
112
|
+
- configliere-dump
|
113
|
+
- configliere-encrypt
|
114
|
+
- configliere-list
|
115
|
+
- configliere-set
|
53
116
|
extensions: []
|
54
117
|
|
55
118
|
extra_rdoc_files:
|
@@ -57,16 +120,28 @@ extra_rdoc_files:
|
|
57
120
|
- README.textile
|
58
121
|
files:
|
59
122
|
- .document
|
123
|
+
- .watchr
|
60
124
|
- CHANGELOG.textile
|
125
|
+
- Gemfile
|
126
|
+
- Gemfile.lock
|
61
127
|
- LICENSE
|
62
128
|
- README.textile
|
63
129
|
- Rakefile
|
64
130
|
- VERSION
|
65
131
|
- bin/configliere
|
132
|
+
- bin/configliere-decrypt
|
133
|
+
- bin/configliere-delete
|
134
|
+
- bin/configliere-dump
|
135
|
+
- bin/configliere-encrypt
|
136
|
+
- bin/configliere-list
|
137
|
+
- bin/configliere-set
|
66
138
|
- configliere.gemspec
|
67
139
|
- examples/config_block_script.rb
|
68
140
|
- examples/encrypted_script.rb
|
69
141
|
- examples/env_var_script.rb
|
142
|
+
- examples/help_message_demo.rb
|
143
|
+
- examples/independent_config.rb
|
144
|
+
- examples/prompt.rb
|
70
145
|
- examples/simple_script.rb
|
71
146
|
- examples/simple_script.yaml
|
72
147
|
- lib/configliere.rb
|
@@ -74,33 +149,31 @@ files:
|
|
74
149
|
- lib/configliere/commands.rb
|
75
150
|
- lib/configliere/config_block.rb
|
76
151
|
- lib/configliere/config_file.rb
|
77
|
-
- lib/configliere/core_ext.rb
|
78
|
-
- lib/configliere/core_ext/blank.rb
|
79
|
-
- lib/configliere/core_ext/hash.rb
|
80
|
-
- lib/configliere/core_ext/sash.rb
|
81
152
|
- lib/configliere/crypter.rb
|
153
|
+
- lib/configliere/deep_hash.rb
|
82
154
|
- lib/configliere/define.rb
|
83
155
|
- lib/configliere/encrypted.rb
|
84
156
|
- lib/configliere/env_var.rb
|
85
157
|
- lib/configliere/param.rb
|
158
|
+
- lib/configliere/prompt.rb
|
86
159
|
- spec/configliere/commandline_spec.rb
|
87
160
|
- spec/configliere/commands_spec.rb
|
88
161
|
- spec/configliere/config_block_spec.rb
|
89
162
|
- spec/configliere/config_file_spec.rb
|
90
|
-
- spec/configliere/core_ext/hash_spec.rb
|
91
|
-
- spec/configliere/core_ext/sash_spec.rb
|
92
163
|
- spec/configliere/crypter_spec.rb
|
164
|
+
- spec/configliere/deep_hash_spec.rb
|
93
165
|
- spec/configliere/define_spec.rb
|
94
166
|
- spec/configliere/encrypted_spec.rb
|
95
167
|
- spec/configliere/env_var_spec.rb
|
96
168
|
- spec/configliere/param_spec.rb
|
169
|
+
- spec/configliere/prompt_spec.rb
|
97
170
|
- spec/configliere_spec.rb
|
98
171
|
- spec/spec.opts
|
99
172
|
- spec/spec_helper.rb
|
100
173
|
has_rdoc: true
|
101
|
-
homepage: http://
|
102
|
-
licenses:
|
103
|
-
|
174
|
+
homepage: http://infochimps.com/labs
|
175
|
+
licenses:
|
176
|
+
- MIT
|
104
177
|
post_install_message:
|
105
178
|
rdoc_options: []
|
106
179
|
|
@@ -111,6 +184,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
111
184
|
requirements:
|
112
185
|
- - ">="
|
113
186
|
- !ruby/object:Gem::Version
|
187
|
+
hash: -4529011985775181084
|
114
188
|
segments:
|
115
189
|
- 0
|
116
190
|
version: "0"
|
@@ -119,13 +193,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
193
|
requirements:
|
120
194
|
- - ">="
|
121
195
|
- !ruby/object:Gem::Version
|
122
|
-
segments:
|
123
|
-
- 0
|
124
196
|
version: "0"
|
125
197
|
requirements: []
|
126
198
|
|
127
199
|
rubyforge_project:
|
128
|
-
rubygems_version: 1.
|
200
|
+
rubygems_version: 1.5.0
|
129
201
|
signing_key:
|
130
202
|
specification_version: 3
|
131
203
|
summary: Wise, discreet configuration management
|
@@ -133,17 +205,20 @@ test_files:
|
|
133
205
|
- examples/config_block_script.rb
|
134
206
|
- examples/encrypted_script.rb
|
135
207
|
- examples/env_var_script.rb
|
208
|
+
- examples/help_message_demo.rb
|
209
|
+
- examples/independent_config.rb
|
210
|
+
- examples/prompt.rb
|
136
211
|
- examples/simple_script.rb
|
137
212
|
- spec/configliere/commandline_spec.rb
|
138
213
|
- spec/configliere/commands_spec.rb
|
139
214
|
- spec/configliere/config_block_spec.rb
|
140
215
|
- spec/configliere/config_file_spec.rb
|
141
|
-
- spec/configliere/core_ext/hash_spec.rb
|
142
|
-
- spec/configliere/core_ext/sash_spec.rb
|
143
216
|
- spec/configliere/crypter_spec.rb
|
217
|
+
- spec/configliere/deep_hash_spec.rb
|
144
218
|
- spec/configliere/define_spec.rb
|
145
219
|
- spec/configliere/encrypted_spec.rb
|
146
220
|
- spec/configliere/env_var_spec.rb
|
147
221
|
- spec/configliere/param_spec.rb
|
222
|
+
- spec/configliere/prompt_spec.rb
|
148
223
|
- spec/configliere_spec.rb
|
149
224
|
- spec/spec_helper.rb
|
data/lib/configliere/core_ext.rb
DELETED
@@ -1,93 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# This is taken in whole from the extlib gem. Thanks y'all.
|
3
|
-
#
|
4
|
-
|
5
|
-
class Object
|
6
|
-
##
|
7
|
-
# Returns true if the object is nil or empty (if applicable)
|
8
|
-
#
|
9
|
-
# [].blank? #=> true
|
10
|
-
# [1].blank? #=> false
|
11
|
-
# [nil].blank? #=> false
|
12
|
-
#
|
13
|
-
# @return [TrueClass, FalseClass]
|
14
|
-
#
|
15
|
-
# @api public
|
16
|
-
def blank?
|
17
|
-
nil? || (respond_to?(:empty?) && empty?)
|
18
|
-
end unless method_defined?(:blank?)
|
19
|
-
end # class Object
|
20
|
-
|
21
|
-
class Numeric
|
22
|
-
##
|
23
|
-
# Numerics are never blank
|
24
|
-
#
|
25
|
-
# 0.blank? #=> false
|
26
|
-
# 1.blank? #=> false
|
27
|
-
# 6.54321.blank? #=> false
|
28
|
-
#
|
29
|
-
# @return [FalseClass]
|
30
|
-
#
|
31
|
-
# @api public
|
32
|
-
def blank?
|
33
|
-
false
|
34
|
-
end unless method_defined?(:blank?)
|
35
|
-
end # class Numeric
|
36
|
-
|
37
|
-
class NilClass
|
38
|
-
##
|
39
|
-
# Nil is always blank
|
40
|
-
#
|
41
|
-
# nil.blank? #=> true
|
42
|
-
#
|
43
|
-
# @return [TrueClass]
|
44
|
-
#
|
45
|
-
# @api public
|
46
|
-
def blank?
|
47
|
-
true
|
48
|
-
end unless method_defined?(:blank?)
|
49
|
-
end # class NilClass
|
50
|
-
|
51
|
-
class TrueClass
|
52
|
-
##
|
53
|
-
# True is never blank.
|
54
|
-
#
|
55
|
-
# true.blank? #=> false
|
56
|
-
#
|
57
|
-
# @return [FalseClass]
|
58
|
-
#
|
59
|
-
# @api public
|
60
|
-
def blank?
|
61
|
-
false
|
62
|
-
end unless method_defined?(:blank?)
|
63
|
-
end # class TrueClass
|
64
|
-
|
65
|
-
class FalseClass
|
66
|
-
##
|
67
|
-
# False is always blank.
|
68
|
-
#
|
69
|
-
# false.blank? #=> true
|
70
|
-
#
|
71
|
-
# @return [TrueClass]
|
72
|
-
#
|
73
|
-
# @api public
|
74
|
-
def blank?
|
75
|
-
true
|
76
|
-
end unless method_defined?(:blank?)
|
77
|
-
end # class FalseClass
|
78
|
-
|
79
|
-
class String
|
80
|
-
##
|
81
|
-
# Strips out whitespace then tests if the string is empty.
|
82
|
-
#
|
83
|
-
# "".blank? #=> true
|
84
|
-
# " ".blank? #=> true
|
85
|
-
# " hey ho ".blank? #=> false
|
86
|
-
#
|
87
|
-
# @return [TrueClass, FalseClass]
|
88
|
-
#
|
89
|
-
# @api public
|
90
|
-
def blank?
|
91
|
-
strip.empty?
|
92
|
-
end unless method_defined?(:blank?)
|
93
|
-
end # class String
|