configurability 1.0.2 → 1.0.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.
- data.tar.gz.sig +0 -0
- data/ChangeLog +35 -2
- data/Rakefile +14 -12
- data/lib/configurability.rb +49 -19
- data/lib/configurability/deferredconfig.rb +29 -0
- data/rake/hg.rb +16 -3
- data/rake/packaging.rb +1 -1
- data/rake/testing.rb +1 -0
- data/spec/configurability/deferredconfig_spec.rb +56 -0
- data/spec/configurability_spec.rb +58 -11
- data/spec/lib/helpers.rb +7 -0
- metadata +14 -9
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
data/ChangeLog
CHANGED
@@ -1,9 +1,42 @@
|
|
1
|
-
|
1
|
+
28[tip] a2ae16f86c98 2010-11-29 15:43 -0800 ged
|
2
|
+
Added tag v1.0.3 for changeset 910ae8ac082f
|
3
|
+
|
4
|
+
27[v1.0.3] 910ae8ac082f 2010-11-29 15:43 -0800 ged
|
5
|
+
Added signature for changeset 49e98e6334dd
|
6
|
+
|
7
|
+
26[github/master,master]:25,24 49e98e6334dd 2010-11-29 15:32 -0800 ged
|
8
|
+
Merged with 24:7aec5228c2b0
|
9
|
+
|
10
|
+
25:22 ec3f030074dc 2010-11-29 15:31 -0800 ged
|
11
|
+
Propagate the installed config to objects that add Configurability after the config is loaded.
|
12
|
+
|
13
|
+
24 7aec5228c2b0 2010-10-29 18:00 -0700 ged
|
14
|
+
Added tag 1.0.2 for changeset ba2c849fde0d
|
15
|
+
|
16
|
+
23[1.0.2]:21 ba2c849fde0d 2010-10-29 18:00 -0700 ged
|
17
|
+
Added signature for changeset 8718e7f4ea1f
|
18
|
+
|
19
|
+
22 58cbefcef526 2010-11-29 15:29 -0800 ged
|
20
|
+
Updated build system
|
21
|
+
|
22
|
+
21 8718e7f4ea1f 2010-10-29 17:32 -0700 ged
|
23
|
+
Fixes for specs under 1.9.2.
|
24
|
+
|
25
|
+
20:17,19 17a6999c08b9 2010-10-29 17:29 -0700 ged
|
26
|
+
Merged with 17:e2bf2e43bccf
|
27
|
+
|
28
|
+
19 e2bf2e43bccf 2010-10-25 10:53 -0700 ged
|
2
29
|
Fixed require for RSpec 2 in the shared behavior.
|
3
30
|
|
4
|
-
|
31
|
+
18:15 5d18e28e387b 2010-10-25 10:48 -0700 ged
|
5
32
|
Converted tests to RSpec 2.
|
6
33
|
|
34
|
+
17 4bff6d5f7b6e 2010-08-08 10:26 -0700 ged
|
35
|
+
Added tag 1.0.1 for changeset e3605ccbe057
|
36
|
+
|
37
|
+
16[1.0.1] e3605ccbe057 2010-08-08 10:26 -0700 ged
|
38
|
+
Added signature for changeset 41bc1de0bf36
|
39
|
+
|
7
40
|
15 41bc1de0bf36 2010-08-04 18:51 -0700 ged
|
8
41
|
More Configurability::Config work
|
9
42
|
|
data/Rakefile
CHANGED
@@ -42,6 +42,7 @@ rescue LoadError
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
+
require 'pathname'
|
45
46
|
require 'rbconfig'
|
46
47
|
require 'rake'
|
47
48
|
require 'rake/testtask'
|
@@ -189,7 +190,6 @@ RDOC_OPTIONS = [
|
|
189
190
|
]
|
190
191
|
YARD_OPTIONS = [
|
191
192
|
'--use-cache',
|
192
|
-
'--no-private',
|
193
193
|
'--protected',
|
194
194
|
'-r', README_FILE,
|
195
195
|
'--exclude', 'extconf\\.rb',
|
@@ -217,16 +217,15 @@ DEPENDENCIES = {
|
|
217
217
|
|
218
218
|
# Developer Gem dependencies: gemname => version
|
219
219
|
DEVELOPMENT_DEPENDENCIES = {
|
220
|
-
'rake'
|
221
|
-
'rcodetools'
|
222
|
-
'rcov'
|
223
|
-
'
|
224
|
-
'RedCloth'
|
225
|
-
'rspec'
|
226
|
-
'ruby-termios'
|
227
|
-
'text-format'
|
228
|
-
'tmail'
|
229
|
-
'diff-lcs' => '>= 1.1.2',
|
220
|
+
'rake' => '~> 0.8.7',
|
221
|
+
'rcodetools' => '~> 0.7.0.0',
|
222
|
+
'rcov' => '~> 0.8.1.2.0',
|
223
|
+
'yard' => '~> 0.6.1',
|
224
|
+
'RedCloth' => '~> 4.2.3',
|
225
|
+
'rspec' => '~> 2.0.1',
|
226
|
+
'ruby-termios' => '~> 0.9.6',
|
227
|
+
'text-format' => '~> 1.0.0',
|
228
|
+
'tmail' => '~> 1.2.3.1',
|
230
229
|
}
|
231
230
|
|
232
231
|
# Non-gem requirements: packagename => version
|
@@ -247,9 +246,10 @@ GEMSPEC = Gem::Specification.new do |gem|
|
|
247
246
|
"section it requested.",
|
248
247
|
].join( "\n" )
|
249
248
|
|
250
|
-
gem.authors = "Michael Granger"
|
249
|
+
gem.authors = ["Michael Granger"]
|
251
250
|
gem.email = ["ged@FaerieMUD.org"]
|
252
251
|
gem.homepage = 'http://bitbucket.org/ged/configurability'
|
252
|
+
gem.licenses = ["BSD"]
|
253
253
|
|
254
254
|
gem.has_rdoc = true
|
255
255
|
gem.rdoc_options = RDOC_OPTIONS
|
@@ -272,6 +272,8 @@ GEMSPEC = Gem::Specification.new do |gem|
|
|
272
272
|
gem.cert_chain = [File.expand_path('~/.gem/ged-public_gem_cert.pem')]
|
273
273
|
|
274
274
|
|
275
|
+
gem.required_ruby_version = '>= 1.8.7'
|
276
|
+
|
275
277
|
DEPENDENCIES.each do |name, version|
|
276
278
|
version = '>= 0' if version.length.zero?
|
277
279
|
gem.add_runtime_dependency( name, version )
|
data/lib/configurability.rb
CHANGED
@@ -9,17 +9,21 @@ require 'yaml'
|
|
9
9
|
module Configurability
|
10
10
|
|
11
11
|
# Library version constant
|
12
|
-
VERSION = '1.0.
|
12
|
+
VERSION = '1.0.3'
|
13
13
|
|
14
14
|
# Version-control revision constant
|
15
|
-
REVISION = %q$Revision:
|
15
|
+
REVISION = %q$Revision: ec3f030074dc $
|
16
16
|
|
17
|
-
require 'configurability/logformatter
|
17
|
+
require 'configurability/logformatter'
|
18
|
+
require 'configurability/deferredconfig'
|
18
19
|
|
19
20
|
|
20
21
|
### The objects that have had Configurability added to them
|
21
22
|
@configurable_objects = []
|
22
23
|
|
24
|
+
### The loaded config (if there is one)
|
25
|
+
@loaded_config = nil
|
26
|
+
|
23
27
|
### Logging
|
24
28
|
@default_logger = Logger.new( $stderr )
|
25
29
|
@default_logger.level = $DEBUG ? Logger::DEBUG : Logger::WARN
|
@@ -36,6 +40,10 @@ module Configurability
|
|
36
40
|
# added to them
|
37
41
|
attr_accessor :configurable_objects
|
38
42
|
|
43
|
+
# @return [Object] the loaded configuration (after ::configure_objects
|
44
|
+
# has been called at least once)
|
45
|
+
attr_accessor :loaded_config
|
46
|
+
|
39
47
|
# @return [Logger::Formatter] the log formatter that will be used when the logging
|
40
48
|
# subsystem is reset
|
41
49
|
attr_accessor :default_log_formatter
|
@@ -55,6 +63,13 @@ module Configurability
|
|
55
63
|
self.log.debug "Adding Configurability to %p" % [ object ]
|
56
64
|
super
|
57
65
|
self.configurable_objects << object
|
66
|
+
|
67
|
+
# If the config has already been propagated, add deferred configuration to the extending
|
68
|
+
# object in case it overrides #configure later.
|
69
|
+
if (( config = self.loaded_config ))
|
70
|
+
self.install_config( config, object )
|
71
|
+
object.extend( Configurability::DeferredConfig )
|
72
|
+
end
|
58
73
|
end
|
59
74
|
|
60
75
|
|
@@ -69,7 +84,9 @@ module Configurability
|
|
69
84
|
### object itself doesn't have a name, the name of its class will be used instead.
|
70
85
|
def self::make_key_from_object( object )
|
71
86
|
if object.respond_to?( :name )
|
72
|
-
|
87
|
+
name = object.name
|
88
|
+
name = 'anonymous' if name.nil? || name.empty?
|
89
|
+
return name.sub( /.*::/, '' ).gsub( /\W+/, '_' ).downcase.to_sym
|
73
90
|
elsif object.class.name && !object.class.name.empty?
|
74
91
|
return object.class.name.sub( /.*::/, '' ).gsub( /\W+/, '_' ).downcase.to_sym
|
75
92
|
else
|
@@ -87,26 +104,20 @@ module Configurability
|
|
87
104
|
self.log.debug "Splitting up config %p between %d objects with configurability." %
|
88
105
|
[ config, self.configurable_objects.length ]
|
89
106
|
|
107
|
+
self.loaded_config = config
|
108
|
+
|
90
109
|
self.configurable_objects.each do |obj|
|
91
|
-
|
92
|
-
self.log.debug "Configuring %p with the %p section of the config." %
|
93
|
-
[ obj, section ]
|
94
|
-
|
95
|
-
if config.respond_to?( section )
|
96
|
-
self.log.debug " config has a %p method; using that" % [ section ]
|
97
|
-
obj.configure( config.send(section) )
|
98
|
-
elsif config.respond_to?( :[] )
|
99
|
-
self.log.debug " config has a an index operator method; using that"
|
100
|
-
obj.configure( config[section] || config[section.to_s] )
|
101
|
-
else
|
102
|
-
self.log.warn " don't know how to get the %p section of the config from %p" %
|
103
|
-
[ section, config ]
|
104
|
-
obj.configure( nil )
|
105
|
-
end
|
110
|
+
self.install_config( config, obj )
|
106
111
|
end
|
107
112
|
end
|
108
113
|
|
109
114
|
|
115
|
+
### If a configuration has been loaded (via {#configure_objects}), clear it.
|
116
|
+
def self::reset
|
117
|
+
self.loaded_config = nil
|
118
|
+
end
|
119
|
+
|
120
|
+
|
110
121
|
### Reset the global logger object to the default
|
111
122
|
### @return [void]
|
112
123
|
def self::reset_logger
|
@@ -116,6 +127,25 @@ module Configurability
|
|
116
127
|
end
|
117
128
|
|
118
129
|
|
130
|
+
### Install the appropriate section of the +config+ into the given +object+.
|
131
|
+
def self::install_config( config, object )
|
132
|
+
section = object.config_key.to_sym
|
133
|
+
self.log.debug "Configuring %p with the %p section of the config." %
|
134
|
+
[ object, section ]
|
135
|
+
|
136
|
+
if config.respond_to?( section )
|
137
|
+
self.log.debug " config has a %p method; using that" % [ section ]
|
138
|
+
object.configure( config.send(section) )
|
139
|
+
elsif config.respond_to?( :[] )
|
140
|
+
self.log.debug " config has a an index operator method; using that"
|
141
|
+
object.configure( config[section] || config[section.to_s] )
|
142
|
+
else
|
143
|
+
self.log.warn " don't know how to get the %p section of the config from %p" %
|
144
|
+
[ section, config ]
|
145
|
+
object.configure( nil )
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
119
149
|
|
120
150
|
#############################################################
|
121
151
|
### A P P E N D E D M E T H O D S
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby -wKU
|
2
|
+
|
3
|
+
require 'configurability'
|
4
|
+
|
5
|
+
|
6
|
+
### Mixin that can be applied to classes to cause them to configure themselves
|
7
|
+
### as soon as they are able to.
|
8
|
+
module Configurability::DeferredConfig
|
9
|
+
|
10
|
+
### Extension hook: log when the mixin is used.
|
11
|
+
def self::extended( mod )
|
12
|
+
Configurability.log.debug "Adding deferred configuration hook to %p" % [ mod ]
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
### Singleton method definition hook: configure the instance as soon as it
|
18
|
+
### overrides the #configure method supplied by the Configurability mixin itself.
|
19
|
+
def singleton_method_added( sym )
|
20
|
+
super
|
21
|
+
|
22
|
+
if sym == :configure
|
23
|
+
config = Configurability.loaded_config
|
24
|
+
Configurability.log.debug "Propagating config to %p" % [ self ]
|
25
|
+
Configurability.install_config( config, self )
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end # module Configurability::DeferredConfig
|
data/rake/hg.rb
CHANGED
@@ -151,9 +151,10 @@ unless defined?( HG_DOTDIR )
|
|
151
151
|
task :prep_release do
|
152
152
|
tags = get_tags()
|
153
153
|
rev = get_current_rev()
|
154
|
+
pkg_version_tag = "v#{PKG_VERSION}"
|
154
155
|
|
155
156
|
# Look for a tag for the current release version, and if it exists abort
|
156
|
-
if tags.include?(
|
157
|
+
if tags.include?( pkg_version_tag )
|
157
158
|
error "Version #{PKG_VERSION} already has a tag. Did you mean " +
|
158
159
|
"to increment the version in #{VERSION_FILE}?"
|
159
160
|
fail
|
@@ -164,8 +165,8 @@ unless defined?( HG_DOTDIR )
|
|
164
165
|
run 'hg', 'sign'
|
165
166
|
|
166
167
|
# Tag the current rev
|
167
|
-
log "Tagging rev #{rev} as #{
|
168
|
-
run 'hg', 'tag',
|
168
|
+
log "Tagging rev #{rev} as #{pkg_version_tag}"
|
169
|
+
run 'hg', 'tag', pkg_version_tag
|
169
170
|
|
170
171
|
# Offer to push
|
171
172
|
Rake::Task['hg:push'].invoke
|
@@ -229,6 +230,18 @@ unless defined?( HG_DOTDIR )
|
|
229
230
|
end
|
230
231
|
|
231
232
|
|
233
|
+
desc "Update to tip"
|
234
|
+
task :update do
|
235
|
+
run 'hg', 'update'
|
236
|
+
end
|
237
|
+
|
238
|
+
|
239
|
+
desc "Clobber all changes (hg up -C)"
|
240
|
+
task :update_and_clobber do
|
241
|
+
run 'hg', 'update', '-C'
|
242
|
+
end
|
243
|
+
|
244
|
+
|
232
245
|
desc "Check the current code in if tests pass"
|
233
246
|
task :checkin => ['hg:pull', 'hg:newfiles', 'test', COMMIT_MSG_FILE] do
|
234
247
|
targets = get_target_args()
|
data/rake/packaging.rb
CHANGED
@@ -12,7 +12,7 @@ include Config
|
|
12
12
|
### Task: prerelease
|
13
13
|
desc "Append the package build number to package versions"
|
14
14
|
task :prerelease do
|
15
|
-
GEMSPEC.version.version << "
|
15
|
+
GEMSPEC.version.version << "pre#{PKG_BUILD}"
|
16
16
|
Rake::Task[:gem].clear
|
17
17
|
|
18
18
|
Gem::PackageTask.new( GEMSPEC ) do |pkg|
|
data/rake/testing.rb
CHANGED
@@ -0,0 +1,56 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
BEGIN {
|
4
|
+
require 'pathname'
|
5
|
+
basedir = Pathname.new( __FILE__ ).dirname.parent.parent
|
6
|
+
|
7
|
+
libdir = basedir + "lib"
|
8
|
+
|
9
|
+
$LOAD_PATH.unshift( basedir ) unless $LOAD_PATH.include?( basedir )
|
10
|
+
$LOAD_PATH.unshift( libdir ) unless $LOAD_PATH.include?( libdir )
|
11
|
+
}
|
12
|
+
|
13
|
+
require 'tempfile'
|
14
|
+
require 'logger'
|
15
|
+
require 'fileutils'
|
16
|
+
require 'rspec'
|
17
|
+
|
18
|
+
require 'spec/lib/helpers'
|
19
|
+
|
20
|
+
require 'configurability'
|
21
|
+
require 'configurability/deferredconfig'
|
22
|
+
|
23
|
+
|
24
|
+
#####################################################################
|
25
|
+
### C O N T E X T S
|
26
|
+
#####################################################################
|
27
|
+
describe Configurability::DeferredConfig do
|
28
|
+
|
29
|
+
before( :all ) do
|
30
|
+
setup_logging( :fatal )
|
31
|
+
end
|
32
|
+
|
33
|
+
after( :each ) do
|
34
|
+
Configurability.configurable_objects.clear
|
35
|
+
Configurability.reset
|
36
|
+
end
|
37
|
+
|
38
|
+
it "calls Configurability.install_config with itself when a 'configure' method is defined" do
|
39
|
+
config = double( "config object", :testing => :testing_config )
|
40
|
+
Configurability.configure_objects( config )
|
41
|
+
|
42
|
+
a_class = Class.new do
|
43
|
+
extend Configurability::DeferredConfig
|
44
|
+
class << self; attr_accessor :config_object; end
|
45
|
+
def self::config_key; "testing"; end
|
46
|
+
def self::configure( config )
|
47
|
+
self.config_object = config
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
a_class.config_object.should == :testing_config
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
56
|
+
# vim: set nosta noet ts=4 sw=4:
|
@@ -15,6 +15,7 @@ require 'rspec'
|
|
15
15
|
require 'spec/lib/helpers'
|
16
16
|
|
17
17
|
require 'configurability'
|
18
|
+
require 'configurability/config'
|
18
19
|
|
19
20
|
|
20
21
|
#####################################################################
|
@@ -30,6 +31,7 @@ describe Configurability do
|
|
30
31
|
|
31
32
|
after( :each ) do
|
32
33
|
Configurability.configurable_objects.clear
|
34
|
+
Configurability.reset
|
33
35
|
end
|
34
36
|
|
35
37
|
|
@@ -49,7 +51,7 @@ describe Configurability do
|
|
49
51
|
config_key :testconfig
|
50
52
|
end
|
51
53
|
|
52
|
-
config =
|
54
|
+
config = mock( "configuration object" )
|
53
55
|
config.should_receive( :respond_to? ).with( :testconfig ).and_return( true )
|
54
56
|
config.should_receive( :testconfig ).and_return( :a_config_section )
|
55
57
|
|
@@ -63,7 +65,7 @@ describe Configurability do
|
|
63
65
|
config_key :testconfig
|
64
66
|
end
|
65
67
|
|
66
|
-
config =
|
68
|
+
config = mock( "configuration object" )
|
67
69
|
config.should_receive( :respond_to? ).with( :testconfig ).and_return( true )
|
68
70
|
config.should_receive( :testconfig ).and_return( :a_config_section )
|
69
71
|
|
@@ -78,7 +80,7 @@ describe Configurability do
|
|
78
80
|
config_key :testconfig
|
79
81
|
end
|
80
82
|
|
81
|
-
config =
|
83
|
+
config = mock( "configuration object" )
|
82
84
|
config.should_receive( :respond_to? ).with( :testconfig ).and_return( false )
|
83
85
|
config.should_receive( :respond_to? ).with( :[] ).and_return( true )
|
84
86
|
config.should_receive( :[] ).with( :testconfig ).and_return( :a_config_section )
|
@@ -94,7 +96,7 @@ describe Configurability do
|
|
94
96
|
config_key :testconfig
|
95
97
|
end
|
96
98
|
|
97
|
-
config =
|
99
|
+
config = mock( "configuration object" )
|
98
100
|
config.should_receive( :respond_to? ).with( :testconfig ).and_return( false )
|
99
101
|
config.should_receive( :respond_to? ).with( :[] ).and_return( false )
|
100
102
|
|
@@ -109,7 +111,7 @@ describe Configurability do
|
|
109
111
|
config_key :testconfig
|
110
112
|
end
|
111
113
|
|
112
|
-
config =
|
114
|
+
config = mock( "configuration object" )
|
113
115
|
config.should_receive( :respond_to? ).with( :testconfig ).and_return( false )
|
114
116
|
config.should_receive( :respond_to? ).with( :[] ).and_return( true )
|
115
117
|
config.should_receive( :[] ).with( :testconfig ).and_return( nil )
|
@@ -125,7 +127,7 @@ describe Configurability do
|
|
125
127
|
object.extend( Configurability )
|
126
128
|
object.config_key = :testobjconfig
|
127
129
|
|
128
|
-
config =
|
130
|
+
config = mock( "configuration object" )
|
129
131
|
config.should_receive( :respond_to? ).with( :testobjconfig ).and_return( true )
|
130
132
|
config.should_receive( :testobjconfig ).and_return( :a_config_section )
|
131
133
|
|
@@ -140,7 +142,7 @@ describe Configurability do
|
|
140
142
|
def object.name; "testobjconfig"; end
|
141
143
|
object.extend( Configurability )
|
142
144
|
|
143
|
-
config =
|
145
|
+
config = mock( "configuration object" )
|
144
146
|
config.should_receive( :respond_to? ).with( :testobjconfig ).and_return( true )
|
145
147
|
config.should_receive( :testobjconfig ).and_return( :a_config_section )
|
146
148
|
|
@@ -154,7 +156,7 @@ describe Configurability do
|
|
154
156
|
def object.name; "Test Obj-Config"; end
|
155
157
|
object.extend( Configurability )
|
156
158
|
|
157
|
-
config =
|
159
|
+
config = mock( "configuration object" )
|
158
160
|
config.should_receive( :respond_to? ).with( :test_obj_config ).and_return( true )
|
159
161
|
config.should_receive( :test_obj_config ).and_return( :a_config_section )
|
160
162
|
|
@@ -168,7 +170,7 @@ describe Configurability do
|
|
168
170
|
object = Object.new
|
169
171
|
object.extend( Configurability )
|
170
172
|
|
171
|
-
config =
|
173
|
+
config = mock( "configuration object" )
|
172
174
|
config.should_receive( :respond_to? ).with( :object ).and_return( true )
|
173
175
|
config.should_receive( :object ).and_return( :a_config_section )
|
174
176
|
|
@@ -184,7 +186,7 @@ describe Configurability do
|
|
184
186
|
end
|
185
187
|
end
|
186
188
|
|
187
|
-
config =
|
189
|
+
config = mock( "configuration object" )
|
188
190
|
config.should_receive( :respond_to? ).with( :dbobject ).and_return( true )
|
189
191
|
config.should_receive( :dbobject ).and_return( :a_config_section )
|
190
192
|
|
@@ -199,7 +201,7 @@ describe Configurability do
|
|
199
201
|
object = objectclass.new
|
200
202
|
object.extend( Configurability )
|
201
203
|
|
202
|
-
config =
|
204
|
+
config = mock( "configuration object" )
|
203
205
|
config.should_receive( :respond_to? ).with( :anonymous ).and_return( true )
|
204
206
|
config.should_receive( :anonymous ).and_return( :a_config_section )
|
205
207
|
|
@@ -208,6 +210,51 @@ describe Configurability do
|
|
208
210
|
Configurability.configure_objects( config )
|
209
211
|
end
|
210
212
|
|
213
|
+
|
214
|
+
context "after installation of a config object" do
|
215
|
+
|
216
|
+
before( :each ) do
|
217
|
+
@config = Configurability::Config.new
|
218
|
+
@config.postconfig = :yes
|
219
|
+
Configurability.configure_objects( @config )
|
220
|
+
end
|
221
|
+
|
222
|
+
after( :each ) do
|
223
|
+
Configurability.reset
|
224
|
+
end
|
225
|
+
|
226
|
+
|
227
|
+
it "should know what the currently-installed configuration is" do
|
228
|
+
Configurability.loaded_config.should equal( @config )
|
229
|
+
end
|
230
|
+
|
231
|
+
it "propagates the installed configuration to any objects which add Configurability" do
|
232
|
+
objectclass = Class.new do
|
233
|
+
def initialize; @config = nil; end
|
234
|
+
attr_reader :config
|
235
|
+
def name; "postconfig"; end
|
236
|
+
def configure( config ); @config = config; end
|
237
|
+
end
|
238
|
+
|
239
|
+
object = objectclass.new
|
240
|
+
object.extend( Configurability )
|
241
|
+
object.config.should == :yes
|
242
|
+
end
|
243
|
+
|
244
|
+
it "defers configuration until after an object has defined a #configure method if " +
|
245
|
+
"it adds Configurability before declaring one" do
|
246
|
+
objectclass = Class.new do
|
247
|
+
extend Configurability
|
248
|
+
config_key :postconfig
|
249
|
+
def self::configure( config ); @config = config; end
|
250
|
+
class << self; attr_reader :config; end
|
251
|
+
end
|
252
|
+
|
253
|
+
objectclass.config.should == :yes
|
254
|
+
end
|
255
|
+
|
256
|
+
end
|
257
|
+
|
211
258
|
end
|
212
259
|
|
213
260
|
# vim: set nosta noet ts=4 sw=4:
|
data/spec/lib/helpers.rb
CHANGED
@@ -10,6 +10,8 @@ BEGIN {
|
|
10
10
|
$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
|
11
11
|
}
|
12
12
|
|
13
|
+
require 'rspec'
|
14
|
+
|
13
15
|
require 'logger'
|
14
16
|
require 'erb'
|
15
17
|
require 'yaml'
|
@@ -133,5 +135,10 @@ module Configurability::SpecHelpers
|
|
133
135
|
end
|
134
136
|
|
135
137
|
|
138
|
+
RSpec.configure do |config|
|
139
|
+
config.mock_with( :rspec )
|
140
|
+
config.include( Configurability::SpecHelpers )
|
141
|
+
end
|
142
|
+
|
136
143
|
# vim: set nosta noet ts=4 sw=4:
|
137
144
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: configurability
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 3
|
10
|
+
version: 1.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Granger
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
cmlhXe46pZNJgWKbxZah85jIjx95hR8vOI+NAM5iH9kOqK13DrxacTKPhqj5PjwF
|
36
36
|
-----END CERTIFICATE-----
|
37
37
|
|
38
|
-
date: 2010-
|
38
|
+
date: 2010-11-29 00:00:00 -08:00
|
39
39
|
default_executable:
|
40
40
|
dependencies: []
|
41
41
|
|
@@ -61,10 +61,12 @@ files:
|
|
61
61
|
- README.md
|
62
62
|
- LICENSE
|
63
63
|
- spec/configurability/config_spec.rb
|
64
|
+
- spec/configurability/deferredconfig_spec.rb
|
64
65
|
- spec/configurability_spec.rb
|
65
66
|
- spec/lib/helpers.rb
|
66
67
|
- lib/configurability/behavior.rb
|
67
68
|
- lib/configurability/config.rb
|
69
|
+
- lib/configurability/deferredconfig.rb
|
68
70
|
- lib/configurability/logformatter.rb
|
69
71
|
- lib/configurability.rb
|
70
72
|
- rake/191_compat.rb
|
@@ -81,8 +83,8 @@ files:
|
|
81
83
|
- rake/verifytask.rb
|
82
84
|
has_rdoc: true
|
83
85
|
homepage: http://bitbucket.org/ged/configurability
|
84
|
-
licenses:
|
85
|
-
|
86
|
+
licenses:
|
87
|
+
- BSD
|
86
88
|
post_install_message:
|
87
89
|
rdoc_options:
|
88
90
|
- --tab-width=4
|
@@ -98,10 +100,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
100
|
requirements:
|
99
101
|
- - ">="
|
100
102
|
- !ruby/object:Gem::Version
|
101
|
-
hash:
|
103
|
+
hash: 57
|
102
104
|
segments:
|
103
|
-
-
|
104
|
-
|
105
|
+
- 1
|
106
|
+
- 8
|
107
|
+
- 7
|
108
|
+
version: 1.8.7
|
105
109
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
110
|
none: false
|
107
111
|
requirements:
|
@@ -120,5 +124,6 @@ specification_version: 3
|
|
120
124
|
summary: A configurability mixin for Ruby
|
121
125
|
test_files:
|
122
126
|
- spec/configurability/config_spec.rb
|
127
|
+
- spec/configurability/deferredconfig_spec.rb
|
123
128
|
- spec/configurability_spec.rb
|
124
129
|
- spec/lib/helpers.rb
|
metadata.gz.sig
CHANGED
Binary file
|