mixlib-config 2.2.1 → 2.2.2
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/Gemfile +5 -0
- data/Rakefile +24 -9
- data/lib/mixlib/config.rb +15 -10
- data/lib/mixlib/config/version.rb +1 -1
- data/mixlib-config.gemspec +28 -0
- data/spec/mixlib/config_spec.rb +42 -42
- data/spec/spec_helper.rb +5 -4
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a3b6ad6191a68a770d664217782576fa3f99174
|
4
|
+
data.tar.gz: 37892ffb3b86d0331353473ef9a018411fd87844
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a5dbeb190acc013e73d094a75495b066f3c53ea8b9f7bc66808dfc0e1ba6dba52cc7955a8e66f2aedd1fe445f5b8136f2a2a27b7f367c819da52979f6f75028
|
7
|
+
data.tar.gz: e88d63510083684bea77e3c7e3ea9f09c4aad9b84a7282efd0304c334980a6fd1b2d626de2650736df25272d3e2f9e5a32d0af646d3c08b202320866398f2361
|
data/Gemfile
ADDED
data/Rakefile
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
1
|
+
require "bundler"
|
2
|
+
require "rubygems"
|
3
|
+
require "rubygems/package_task"
|
4
|
+
require "rdoc/task"
|
5
|
+
require "rspec/core/rake_task"
|
6
|
+
require "mixlib/config/version"
|
6
7
|
|
7
8
|
Bundler::GemHelper.install_tasks
|
8
9
|
|
@@ -10,14 +11,28 @@ task :default => :spec
|
|
10
11
|
|
11
12
|
desc "Run specs"
|
12
13
|
RSpec::Core::RakeTask.new(:spec) do |spec|
|
13
|
-
spec.pattern =
|
14
|
+
spec.pattern = "spec/**/*_spec.rb"
|
14
15
|
end
|
15
16
|
|
16
17
|
gem_spec = eval(File.read("mixlib-config.gemspec"))
|
17
18
|
|
18
19
|
RDoc::Task.new do |rdoc|
|
19
|
-
rdoc.rdoc_dir =
|
20
|
+
rdoc.rdoc_dir = "rdoc"
|
20
21
|
rdoc.title = "mixlib-config #{gem_spec.version}"
|
21
|
-
rdoc.rdoc_files.include(
|
22
|
-
rdoc.rdoc_files.include(
|
22
|
+
rdoc.rdoc_files.include("README*")
|
23
|
+
rdoc.rdoc_files.include("lib/**/*.rb")
|
24
|
+
end
|
25
|
+
|
26
|
+
begin
|
27
|
+
require "github_changelog_generator/task"
|
28
|
+
|
29
|
+
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
30
|
+
config.issues = false
|
31
|
+
config.future_release = Mixlib::Config::VERSION
|
32
|
+
config.enhancement_labels = "enhancement,Enhancement,New Feature,Feature".split(",")
|
33
|
+
config.bug_labels = "bug,Bug,Improvement,Upstream Bug".split(",")
|
34
|
+
config.exclude_labels = "duplicate,question,invalid,wontfix,no_changelog,Exclude From Changelog,Question,Discussion".split(",")
|
35
|
+
end
|
36
|
+
rescue LoadError
|
37
|
+
puts "github_changelog_generator is not available. gem install github_changelog_generator to generate changelogs"
|
23
38
|
end
|
data/lib/mixlib/config.rb
CHANGED
@@ -18,11 +18,11 @@
|
|
18
18
|
# limitations under the License.
|
19
19
|
#
|
20
20
|
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
24
|
-
require
|
25
|
-
require
|
21
|
+
require "mixlib/config/version"
|
22
|
+
require "mixlib/config/configurable"
|
23
|
+
require "mixlib/config/unknown_config_option_error"
|
24
|
+
require "mixlib/config/reopened_config_context_with_configurable_error"
|
25
|
+
require "mixlib/config/reopened_configurable_with_config_context_error"
|
26
26
|
|
27
27
|
module Mixlib
|
28
28
|
module Config
|
@@ -34,6 +34,11 @@ module Mixlib
|
|
34
34
|
base.configuration = Hash.new
|
35
35
|
base.configurables = Hash.new
|
36
36
|
base.config_contexts = Hash.new
|
37
|
+
base.initialize_mixlib_config
|
38
|
+
end
|
39
|
+
|
40
|
+
def initialize_mixlib_config
|
41
|
+
@config_strict_mode = nil
|
37
42
|
end
|
38
43
|
|
39
44
|
# Loads a given ruby file, and runs instance_eval against it in the context of the current
|
@@ -52,7 +57,7 @@ module Mixlib
|
|
52
57
|
# === Parameters
|
53
58
|
# block<Block>:: A block that is called with self.configuration as the argument.
|
54
59
|
def configure(&block)
|
55
|
-
|
60
|
+
yield(self.configuration)
|
56
61
|
end
|
57
62
|
|
58
63
|
# Get the value of a config option
|
@@ -280,7 +285,7 @@ module Mixlib
|
|
280
285
|
define_attr_accessor_methods(symbol)
|
281
286
|
end
|
282
287
|
if block
|
283
|
-
|
288
|
+
yield(configurables[symbol])
|
284
289
|
end
|
285
290
|
configurables[symbol]
|
286
291
|
end
|
@@ -403,7 +408,7 @@ module Mixlib
|
|
403
408
|
# symbol<Symbol>:: Name of the method (variable setter)
|
404
409
|
# value<Object>:: Value to be set in config hash
|
405
410
|
#
|
406
|
-
def internal_set(symbol,value)
|
411
|
+
def internal_set(symbol, value)
|
407
412
|
if configurables.has_key?(symbol)
|
408
413
|
configurables[symbol].set(self.configuration, value)
|
409
414
|
elsif config_contexts.has_key?(symbol)
|
@@ -433,7 +438,7 @@ module Mixlib
|
|
433
438
|
end
|
434
439
|
end
|
435
440
|
|
436
|
-
def internal_get_or_set(symbol
|
441
|
+
def internal_get_or_set(symbol, *args)
|
437
442
|
num_args = args.length
|
438
443
|
# Setting
|
439
444
|
if num_args > 0
|
@@ -448,7 +453,7 @@ module Mixlib
|
|
448
453
|
# When Ruby 1.8.7 is no longer supported, this stuff can be done with define_singleton_method!
|
449
454
|
meta = class << self; self; end
|
450
455
|
# Setter
|
451
|
-
meta.send :define_method, "#{symbol
|
456
|
+
meta.send :define_method, "#{symbol}=".to_sym do |value|
|
452
457
|
internal_set(symbol, value)
|
453
458
|
end
|
454
459
|
# Getter
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
$:.unshift(File.dirname(__FILE__) + "/lib")
|
4
|
+
require "mixlib/config/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "mixlib-config"
|
8
|
+
s.version = Mixlib::Config::VERSION
|
9
|
+
|
10
|
+
s.authors = ["Chef Software, Inc."]
|
11
|
+
s.email = "legal@chef.io"
|
12
|
+
s.extra_rdoc_files = [
|
13
|
+
"LICENSE",
|
14
|
+
"README.md",
|
15
|
+
]
|
16
|
+
s.files = [ "LICENSE", "NOTICE", "README.md", "Gemfile", "Rakefile" ] + Dir.glob("*.gemspec") +
|
17
|
+
Dir.glob("{lib,spec}/**/*", File::FNM_DOTMATCH).reject { |f| File.directory?(f) }
|
18
|
+
s.homepage = "http://www.chef.io"
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
s.rubygems_version = "1.8.23"
|
21
|
+
s.summary = "A class based configuration library"
|
22
|
+
s.description = s.summary
|
23
|
+
s.license = "Apache-2.0"
|
24
|
+
|
25
|
+
s.add_development_dependency "rake"
|
26
|
+
s.add_development_dependency "rspec", "~> 2.99"
|
27
|
+
s.add_development_dependency "rdoc"
|
28
|
+
end
|
data/spec/mixlib/config_spec.rb
CHANGED
@@ -18,15 +18,10 @@
|
|
18
18
|
|
19
19
|
require File.expand_path(File.join(File.dirname(__FILE__), "..", "spec_helper"))
|
20
20
|
|
21
|
-
class ConfigIt
|
22
|
-
extend ::Mixlib::Config
|
23
|
-
end
|
24
|
-
|
25
|
-
|
26
21
|
describe Mixlib::Config do
|
27
22
|
before(:each) do
|
28
23
|
ConfigIt.configure do |c|
|
29
|
-
c[:alpha] =
|
24
|
+
c[:alpha] = "omega"
|
30
25
|
c[:foo] = nil
|
31
26
|
end
|
32
27
|
end
|
@@ -34,9 +29,9 @@ describe Mixlib::Config do
|
|
34
29
|
it "should load a config file" do
|
35
30
|
File.stub(:exists?).and_return(true)
|
36
31
|
File.stub(:readable?).and_return(true)
|
37
|
-
IO.stub(:read).with(
|
32
|
+
IO.stub(:read).with("config.rb").and_return("alpha = 'omega'\nfoo = 'bar'")
|
38
33
|
lambda {
|
39
|
-
ConfigIt.from_file(
|
34
|
+
ConfigIt.from_file("config.rb")
|
40
35
|
}.should_not raise_error
|
41
36
|
end
|
42
37
|
|
@@ -53,18 +48,18 @@ describe Mixlib::Config do
|
|
53
48
|
end
|
54
49
|
|
55
50
|
it "should allow the error to bubble up when it's anything other than IOError" do
|
56
|
-
IO.stub(:read).with(
|
51
|
+
IO.stub(:read).with("config.rb").and_return("@#asdf")
|
57
52
|
lambda {
|
58
|
-
ConfigIt.from_file(
|
53
|
+
ConfigIt.from_file("config.rb")
|
59
54
|
}.should raise_error(SyntaxError)
|
60
55
|
end
|
61
56
|
|
62
57
|
it "should allow you to reference a value by index" do
|
63
|
-
ConfigIt[:alpha].should ==
|
58
|
+
ConfigIt[:alpha].should == "omega"
|
64
59
|
end
|
65
60
|
|
66
61
|
it "should allow you to reference a value by string index" do
|
67
|
-
ConfigIt[
|
62
|
+
ConfigIt["alpha"].should == "omega"
|
68
63
|
end
|
69
64
|
|
70
65
|
it "should allow you to set a value by index" do
|
@@ -73,7 +68,7 @@ describe Mixlib::Config do
|
|
73
68
|
end
|
74
69
|
|
75
70
|
it "should allow you to set a value by string index" do
|
76
|
-
ConfigIt[
|
71
|
+
ConfigIt["alpha"] = "one"
|
77
72
|
ConfigIt[:alpha].should == "one"
|
78
73
|
end
|
79
74
|
|
@@ -127,7 +122,7 @@ describe Mixlib::Config do
|
|
127
122
|
ConfigIt.configure { |c| c[:cookbook_path] = "monkey_rabbit"; c[:otherthing] = "boo" }
|
128
123
|
end
|
129
124
|
|
130
|
-
{:cookbook_path => "monkey_rabbit", :otherthing => "boo"}.each do |k,v|
|
125
|
+
{ :cookbook_path => "monkey_rabbit", :otherthing => "boo" }.each do |k, v|
|
131
126
|
it "should allow you to retrieve the config value for #{k} via []" do
|
132
127
|
ConfigIt[k].should == v
|
133
128
|
end
|
@@ -174,8 +169,8 @@ describe Mixlib::Config do
|
|
174
169
|
end
|
175
170
|
|
176
171
|
it "should multiply an integer by 1000 via from-file, too" do
|
177
|
-
IO.stub(:read).with(
|
178
|
-
@klass.from_file(
|
172
|
+
IO.stub(:read).with("config.rb").and_return("test_method 99")
|
173
|
+
@klass.from_file("config.rb")
|
179
174
|
@klass.test_method.should == 99000
|
180
175
|
end
|
181
176
|
|
@@ -226,18 +221,23 @@ describe Mixlib::Config do
|
|
226
221
|
end
|
227
222
|
end
|
228
223
|
|
229
|
-
|
224
|
+
after do
|
225
|
+
Object.send :remove_method, :daemonizeme
|
226
|
+
Object.send :remove_method, :'daemonizeme='
|
227
|
+
end
|
228
|
+
|
229
|
+
it "Normal classes call the extra method" do
|
230
230
|
normal_class = Class.new
|
231
231
|
normal_class.extend(::Mixlib::Config)
|
232
232
|
lambda { normal_class.daemonizeme }.should raise_error(NopeError)
|
233
233
|
end
|
234
234
|
|
235
|
-
it
|
235
|
+
it "Configurables with the same name as the extra method can be set" do
|
236
236
|
@klass.daemonizeme = 10
|
237
237
|
@klass[:daemonizeme].should == 10
|
238
238
|
end
|
239
239
|
|
240
|
-
it
|
240
|
+
it "Configurables with the same name as the extra method can be retrieved" do
|
241
241
|
@klass[:daemonizeme] = 10
|
242
242
|
@klass.daemonizeme.should == 10
|
243
243
|
end
|
@@ -309,7 +309,7 @@ describe Mixlib::Config do
|
|
309
309
|
@klass.extend(::Mixlib::Config)
|
310
310
|
@klass.class_eval do
|
311
311
|
default :x, 4
|
312
|
-
default(:attr) { x*2 }
|
312
|
+
default(:attr) { x * 2 }
|
313
313
|
end
|
314
314
|
end
|
315
315
|
|
@@ -379,8 +379,8 @@ describe Mixlib::Config do
|
|
379
379
|
end
|
380
380
|
|
381
381
|
it "reset clears it to its default" do
|
382
|
-
@klass.attr <<
|
383
|
-
@klass.attr.should == [
|
382
|
+
@klass.attr << "x"
|
383
|
+
@klass.attr.should == [ "x" ]
|
384
384
|
@klass.reset
|
385
385
|
@klass.attr.should == []
|
386
386
|
end
|
@@ -394,12 +394,12 @@ describe Mixlib::Config do
|
|
394
394
|
end
|
395
395
|
|
396
396
|
it "save should save the new value if it gets set" do
|
397
|
-
@klass.attr <<
|
398
|
-
(saved = @klass.save).should == { :attr => [
|
397
|
+
@klass.attr << "x"
|
398
|
+
(saved = @klass.save).should == { :attr => [ "x" ] }
|
399
399
|
@klass.reset
|
400
400
|
@klass.attr.should == []
|
401
401
|
@klass.restore(saved)
|
402
|
-
@klass.attr.should == [
|
402
|
+
@klass.attr.should == [ "x" ]
|
403
403
|
end
|
404
404
|
|
405
405
|
it "save should save the new value even if it is set to its default value" do
|
@@ -435,12 +435,12 @@ describe Mixlib::Config do
|
|
435
435
|
end
|
436
436
|
|
437
437
|
it "save should save the new value if it gets set" do
|
438
|
-
@klass.attr[:hi] =
|
439
|
-
(saved = @klass.save).should == { :attr => { :hi =>
|
438
|
+
@klass.attr[:hi] = "lo"
|
439
|
+
(saved = @klass.save).should == { :attr => { :hi => "lo" } }
|
440
440
|
@klass.reset
|
441
441
|
@klass.attr.should == {}
|
442
442
|
@klass.restore(saved)
|
443
|
-
@klass.save.should == { :attr => { :hi =>
|
443
|
+
@klass.save.should == { :attr => { :hi => "lo" } }
|
444
444
|
end
|
445
445
|
|
446
446
|
it "save should save the new value even if it is set to its default value" do
|
@@ -457,14 +457,14 @@ describe Mixlib::Config do
|
|
457
457
|
before :each do
|
458
458
|
@klass = Class.new
|
459
459
|
@klass.extend(::Mixlib::Config)
|
460
|
-
@klass.class_eval { default :attr,
|
460
|
+
@klass.class_eval { default :attr, "hello" }
|
461
461
|
end
|
462
462
|
|
463
463
|
it "reset clears it to its default" do
|
464
|
-
@klass.attr <<
|
465
|
-
@klass.attr.should ==
|
464
|
+
@klass.attr << " world"
|
465
|
+
@klass.attr.should == "hello world"
|
466
466
|
@klass.reset
|
467
|
-
@klass.attr.should ==
|
467
|
+
@klass.attr.should == "hello"
|
468
468
|
end
|
469
469
|
|
470
470
|
it "save should not save anything for it" do
|
@@ -472,25 +472,25 @@ describe Mixlib::Config do
|
|
472
472
|
end
|
473
473
|
|
474
474
|
it "save with include_defaults should save all defaults" do
|
475
|
-
@klass.save(true).should == { :attr =>
|
475
|
+
@klass.save(true).should == { :attr => "hello" }
|
476
476
|
end
|
477
477
|
|
478
478
|
it "save should save the new value if it gets set" do
|
479
|
-
@klass.attr <<
|
480
|
-
(saved = @klass.save).should == { :attr =>
|
479
|
+
@klass.attr << " world"
|
480
|
+
(saved = @klass.save).should == { :attr => "hello world" }
|
481
481
|
@klass.reset
|
482
|
-
@klass.attr.should ==
|
482
|
+
@klass.attr.should == "hello"
|
483
483
|
@klass.restore(saved)
|
484
|
-
@klass.attr.should ==
|
484
|
+
@klass.attr.should == "hello world"
|
485
485
|
end
|
486
486
|
|
487
487
|
it "save should save the new value even if it is set to its default value" do
|
488
|
-
@klass.attr
|
489
|
-
(saved = @klass.save).should == { :attr =>
|
488
|
+
@klass.attr "hello world"
|
489
|
+
(saved = @klass.save).should == { :attr => "hello world" }
|
490
490
|
@klass.reset
|
491
491
|
@klass.save.should == {}
|
492
492
|
@klass.restore(saved)
|
493
|
-
@klass.save.should == { :attr =>
|
493
|
+
@klass.save.should == { :attr => "hello world" }
|
494
494
|
end
|
495
495
|
end
|
496
496
|
|
@@ -563,7 +563,7 @@ describe Mixlib::Config do
|
|
563
563
|
@klass.class_eval do
|
564
564
|
configurable(:attr) do |c|
|
565
565
|
c.defaults_to(4)
|
566
|
-
c.writes_value { |value| value*2 }
|
566
|
+
c.writes_value { |value| value * 2 }
|
567
567
|
end
|
568
568
|
end
|
569
569
|
end
|
@@ -638,7 +638,7 @@ describe Mixlib::Config do
|
|
638
638
|
@klass = Class.new
|
639
639
|
@klass.extend(::Mixlib::Config)
|
640
640
|
@klass.class_eval do
|
641
|
-
configurable(:attr).defaults_to(4).writes_value { |value| value*2 }
|
641
|
+
configurable(:attr).defaults_to(4).writes_value { |value| value * 2 }
|
642
642
|
end
|
643
643
|
end
|
644
644
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
$TESTING=true
|
2
|
-
$:.push File.join(File.dirname(__FILE__),
|
1
|
+
$TESTING = true
|
2
|
+
$:.push File.join(File.dirname(__FILE__), "..", "lib")
|
3
3
|
|
4
|
-
require
|
5
|
-
require
|
4
|
+
require "rspec"
|
5
|
+
require "mixlib/config"
|
6
6
|
|
7
7
|
class ConfigIt
|
8
8
|
extend Mixlib::Config
|
@@ -12,4 +12,5 @@ RSpec.configure do |config|
|
|
12
12
|
config.filter_run :focus => true
|
13
13
|
config.run_all_when_everything_filtered = true
|
14
14
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
15
|
+
config.warnings = true
|
15
16
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mixlib-config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chef Software, Inc.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -60,6 +60,7 @@ extra_rdoc_files:
|
|
60
60
|
- LICENSE
|
61
61
|
- README.md
|
62
62
|
files:
|
63
|
+
- Gemfile
|
63
64
|
- LICENSE
|
64
65
|
- NOTICE
|
65
66
|
- README.md
|
@@ -70,6 +71,7 @@ files:
|
|
70
71
|
- lib/mixlib/config/reopened_configurable_with_config_context_error.rb
|
71
72
|
- lib/mixlib/config/unknown_config_option_error.rb
|
72
73
|
- lib/mixlib/config/version.rb
|
74
|
+
- mixlib-config.gemspec
|
73
75
|
- spec/mixlib/config_spec.rb
|
74
76
|
- spec/spec_helper.rb
|
75
77
|
homepage: http://www.chef.io
|
@@ -92,9 +94,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
94
|
version: '0'
|
93
95
|
requirements: []
|
94
96
|
rubyforge_project:
|
95
|
-
rubygems_version: 2.
|
97
|
+
rubygems_version: 2.6.6
|
96
98
|
signing_key:
|
97
99
|
specification_version: 4
|
98
100
|
summary: A class based configuration library
|
99
101
|
test_files: []
|
100
|
-
has_rdoc:
|