configurability 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +1 -2
- data/.gemtest +0 -0
- data/History.md +40 -0
- data/LICENSE +1 -1
- data/README.md +23 -8
- data/Rakefile +57 -331
- data/examples/basicconfig.rb +59 -0
- data/examples/config.yml +25 -0
- data/lib/configurability.rb +2 -2
- data/lib/configurability/config.rb +5 -3
- data/spec/configurability/config_spec.rb +17 -0
- metadata +97 -50
- metadata.gz.sig +3 -2
- data/ChangeLog +0 -87
- data/rake/191_compat.rb +0 -26
- data/rake/dependencies.rb +0 -76
- data/rake/documentation.rb +0 -123
- data/rake/helpers.rb +0 -502
- data/rake/hg.rb +0 -318
- data/rake/manual.rb +0 -787
- data/rake/packaging.rb +0 -129
- data/rake/publishing.rb +0 -341
- data/rake/style.rb +0 -62
- data/rake/svn.rb +0 -668
- data/rake/testing.rb +0 -152
- data/rake/verifytask.rb +0 -64
@@ -0,0 +1,59 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
BEGIN {
|
4
|
+
require 'pathname'
|
5
|
+
basedir = Pathname( __FILE__ ).dirname.parent
|
6
|
+
libdir = basedir + 'lib'
|
7
|
+
|
8
|
+
$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
|
9
|
+
}
|
10
|
+
|
11
|
+
require 'configurability'
|
12
|
+
require 'sequel'
|
13
|
+
require 'treequel'
|
14
|
+
|
15
|
+
|
16
|
+
class DatabaseAdapter
|
17
|
+
extend Configurability
|
18
|
+
|
19
|
+
config_key :db
|
20
|
+
|
21
|
+
### Configure the database
|
22
|
+
def self::configure( dbconfig )
|
23
|
+
$stderr.puts "Configuring database adapter: %p" % [ dbconfig ]
|
24
|
+
@database = Sequel.connect( dbconfig )
|
25
|
+
end
|
26
|
+
|
27
|
+
end # class DatabaseAdapter
|
28
|
+
|
29
|
+
class LdapAdapter
|
30
|
+
extend Configurability
|
31
|
+
|
32
|
+
config_key :ldap
|
33
|
+
|
34
|
+
def self::configure( ldapconfig )
|
35
|
+
$stderr.puts "Configuring LDAP adapter: %p" % [ ldapconfig ]
|
36
|
+
@ldap = Treequel.directory( ldapconfig )
|
37
|
+
end
|
38
|
+
|
39
|
+
end # class LdapAdapter
|
40
|
+
|
41
|
+
|
42
|
+
config = YAML.load( DATA )
|
43
|
+
Configurability.configure_objects( config )
|
44
|
+
|
45
|
+
|
46
|
+
__END__
|
47
|
+
|
48
|
+
:db:
|
49
|
+
:adapter: postgres
|
50
|
+
:host: localhost
|
51
|
+
:database: test
|
52
|
+
:user: test
|
53
|
+
|
54
|
+
:ldap:
|
55
|
+
:host: localhost
|
56
|
+
:port: 389
|
57
|
+
:connect_type: tls
|
58
|
+
:base_dn: dc=acme,dc=com
|
59
|
+
|
data/examples/config.yml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
---
|
2
|
+
database:
|
3
|
+
development:
|
4
|
+
adapter: sqlite3
|
5
|
+
database: db/dev.db
|
6
|
+
pool: 5
|
7
|
+
timeout: 5000
|
8
|
+
testing:
|
9
|
+
adapter: sqlite3
|
10
|
+
database: db/testing.db
|
11
|
+
pool: 2
|
12
|
+
timeout: 5000
|
13
|
+
production:
|
14
|
+
adapter: postgres
|
15
|
+
database: fixedassets
|
16
|
+
pool: 25
|
17
|
+
timeout: 50
|
18
|
+
ldap:
|
19
|
+
uri: ldap://ldap.acme.com/dc=acme,dc=com
|
20
|
+
bind_dn: cn=web,dc=acme,dc=com
|
21
|
+
bind_pass: Mut@ge.Mix@ge
|
22
|
+
branding:
|
23
|
+
header: "#333"
|
24
|
+
title: "#dedede"
|
25
|
+
anchor: "#9fc8d4"
|
data/lib/configurability.rb
CHANGED
@@ -9,10 +9,10 @@ require 'yaml'
|
|
9
9
|
module Configurability
|
10
10
|
|
11
11
|
# Library version constant
|
12
|
-
VERSION = '1.0.
|
12
|
+
VERSION = '1.0.5'
|
13
13
|
|
14
14
|
# Version-control revision constant
|
15
|
-
REVISION = %q$Revision:
|
15
|
+
REVISION = %q$Revision: 12fda25efd84 $
|
16
16
|
|
17
17
|
require 'configurability/logformatter'
|
18
18
|
require 'configurability/deferredconfig'
|
@@ -303,10 +303,12 @@ class Configurability::Config
|
|
303
303
|
def symbolify_keys( hash )
|
304
304
|
newhash = {}
|
305
305
|
hash.each do |key,val|
|
306
|
+
key = key.to_sym if key.respond_to?( :to_sym )
|
307
|
+
|
306
308
|
if val.is_a?( Hash )
|
307
|
-
newhash[ key
|
309
|
+
newhash[ key ] = symbolify_keys( val )
|
308
310
|
else
|
309
|
-
newhash[ key
|
311
|
+
newhash[ key ] = val
|
310
312
|
end
|
311
313
|
end
|
312
314
|
|
@@ -377,7 +379,7 @@ class Configurability::Config
|
|
377
379
|
### Configurability::Config::ConfigStruct if +key+
|
378
380
|
### is a section name.
|
379
381
|
def []( key )
|
380
|
-
key = key.untaint.to_sym
|
382
|
+
key = key.untaint.to_sym if key.respond_to?( :to_sym )
|
381
383
|
|
382
384
|
# Create the config struct on the fly for subsections
|
383
385
|
if !@hash.key?( key )
|
@@ -94,6 +94,23 @@ describe Configurability::Config do
|
|
94
94
|
end
|
95
95
|
|
96
96
|
|
97
|
+
NIL_KEY_CONFIG = %{
|
98
|
+
---
|
99
|
+
trap_on:
|
100
|
+
"low disk space alert":
|
101
|
+
~:
|
102
|
+
notepad:
|
103
|
+
patterns:
|
104
|
+
- pattern1
|
105
|
+
- pattern2
|
106
|
+
}.gsub(/^\t/, '')
|
107
|
+
|
108
|
+
it "handles nil as a key in the configuration (issue #1)" do
|
109
|
+
config = Configurability::Config.new( NIL_KEY_CONFIG )
|
110
|
+
config[:trap_on]['low disk space alert'][nil][:notepad][:patterns].should == [ 'pattern1', 'pattern2' ]
|
111
|
+
end
|
112
|
+
|
113
|
+
|
97
114
|
describe "created with in-memory YAML source" do
|
98
115
|
|
99
116
|
before(:each) do
|
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:
|
5
|
-
prerelease:
|
4
|
+
hash: 29
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 5
|
10
|
+
version: 1.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Granger
|
@@ -35,16 +35,77 @@ cert_chain:
|
|
35
35
|
cmlhXe46pZNJgWKbxZah85jIjx95hR8vOI+NAM5iH9kOqK13DrxacTKPhqj5PjwF
|
36
36
|
-----END CERTIFICATE-----
|
37
37
|
|
38
|
-
date:
|
38
|
+
date: 2011-02-08 00:00:00 -08:00
|
39
39
|
default_executable:
|
40
|
-
dependencies:
|
41
|
-
|
40
|
+
dependencies:
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: hoe-mercurial
|
43
|
+
prerelease: false
|
44
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ~>
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
hash: 29
|
50
|
+
segments:
|
51
|
+
- 1
|
52
|
+
- 2
|
53
|
+
- 1
|
54
|
+
version: 1.2.1
|
55
|
+
type: :development
|
56
|
+
version_requirements: *id001
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: hoe-yard
|
59
|
+
prerelease: false
|
60
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
hash: 31
|
66
|
+
segments:
|
67
|
+
- 0
|
68
|
+
- 1
|
69
|
+
- 2
|
70
|
+
version: 0.1.2
|
71
|
+
type: :development
|
72
|
+
version_requirements: *id002
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: rspec
|
75
|
+
prerelease: false
|
76
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ~>
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
hash: 11
|
82
|
+
segments:
|
83
|
+
- 2
|
84
|
+
- 4
|
85
|
+
version: "2.4"
|
86
|
+
type: :development
|
87
|
+
version_requirements: *id003
|
88
|
+
- !ruby/object:Gem::Dependency
|
89
|
+
name: hoe
|
90
|
+
prerelease: false
|
91
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
hash: 43
|
97
|
+
segments:
|
98
|
+
- 2
|
99
|
+
- 9
|
100
|
+
- 0
|
101
|
+
version: 2.9.0
|
102
|
+
type: :development
|
103
|
+
version_requirements: *id004
|
42
104
|
description: |-
|
43
|
-
Configurability is a mixin that allows you to add
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
section it requested.
|
105
|
+
Configurability is a mixin that allows you to add configurability to one or
|
106
|
+
more objects or classes. You can assign them each a subsection of the
|
107
|
+
configuration, and then later, when the configuration is loaded, the
|
108
|
+
configuration is split up and sent to the objects that will use it.
|
48
109
|
email:
|
49
110
|
- ged@FaerieMUD.org
|
50
111
|
executables: []
|
@@ -52,47 +113,36 @@ executables: []
|
|
52
113
|
extensions: []
|
53
114
|
|
54
115
|
extra_rdoc_files:
|
55
|
-
-
|
56
|
-
- README.md
|
57
|
-
- LICENSE
|
116
|
+
- History.md
|
58
117
|
files:
|
59
|
-
-
|
60
|
-
- ChangeLog
|
61
|
-
- README.md
|
118
|
+
- History.md
|
62
119
|
- LICENSE
|
63
|
-
-
|
64
|
-
-
|
65
|
-
-
|
66
|
-
-
|
120
|
+
- README.md
|
121
|
+
- Rakefile
|
122
|
+
- examples/basicconfig.rb
|
123
|
+
- examples/config.yml
|
124
|
+
- lib/configurability.rb
|
67
125
|
- lib/configurability/behavior.rb
|
68
126
|
- lib/configurability/config.rb
|
69
127
|
- lib/configurability/deferredconfig.rb
|
70
128
|
- lib/configurability/logformatter.rb
|
71
|
-
-
|
72
|
-
-
|
73
|
-
-
|
74
|
-
-
|
75
|
-
-
|
76
|
-
- rake/hg.rb
|
77
|
-
- rake/manual.rb
|
78
|
-
- rake/packaging.rb
|
79
|
-
- rake/publishing.rb
|
80
|
-
- rake/style.rb
|
81
|
-
- rake/svn.rb
|
82
|
-
- rake/testing.rb
|
83
|
-
- rake/verifytask.rb
|
129
|
+
- spec/configurability/config_spec.rb
|
130
|
+
- spec/configurability/deferredconfig_spec.rb
|
131
|
+
- spec/configurability_spec.rb
|
132
|
+
- spec/lib/helpers.rb
|
133
|
+
- .gemtest
|
84
134
|
has_rdoc: true
|
85
135
|
homepage: http://bitbucket.org/ged/configurability
|
86
136
|
licenses:
|
87
137
|
- BSD
|
88
|
-
post_install_message:
|
138
|
+
post_install_message: "\n\n\
|
139
|
+
New!\n\n\
|
140
|
+
\t"
|
89
141
|
rdoc_options:
|
90
|
-
- --
|
91
|
-
- --
|
92
|
-
- --
|
93
|
-
-
|
94
|
-
- --main=README.md
|
95
|
-
- --title=configurability
|
142
|
+
- --protected
|
143
|
+
- --verbose
|
144
|
+
- --title
|
145
|
+
- Configurability Documentation
|
96
146
|
require_paths:
|
97
147
|
- lib
|
98
148
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -117,13 +167,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
167
|
version: "0"
|
118
168
|
requirements: []
|
119
169
|
|
120
|
-
rubyforge_project:
|
121
|
-
rubygems_version: 1.
|
170
|
+
rubyforge_project: configurability
|
171
|
+
rubygems_version: 1.5.0
|
122
172
|
signing_key:
|
123
173
|
specification_version: 3
|
124
|
-
summary:
|
125
|
-
test_files:
|
126
|
-
|
127
|
-
- spec/configurability/deferredconfig_spec.rb
|
128
|
-
- spec/configurability_spec.rb
|
129
|
-
- spec/lib/helpers.rb
|
174
|
+
summary: Configurability is a mixin that allows you to add configurability to one or more objects or classes
|
175
|
+
test_files: []
|
176
|
+
|
metadata.gz.sig
CHANGED
@@ -1,2 +1,3 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
}���N)W�&MG�i9���Y�T�������m�u�i
|
2
|
+
Py=���4+ҔO6����j���P��TarI��.��A���>�pY�qy��$X�r�X藲���Ie]�<rHX�h_�k��ƍ�h��OÒ���k�o�zM�e�%d��x�կ���s�lp���k`�9��^¥��c�CP�a)��6l0�E��k̚uttW��<��p��)���˭RФ�V���\��lز�1����T�] <�Z^J(�3�{�
|
3
|
+
|
data/ChangeLog
DELETED
@@ -1,87 +0,0 @@
|
|
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
|
29
|
-
Fixed require for RSpec 2 in the shared behavior.
|
30
|
-
|
31
|
-
18:15 5d18e28e387b 2010-10-25 10:48 -0700 ged
|
32
|
-
Converted tests to RSpec 2.
|
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
|
-
|
40
|
-
15 41bc1de0bf36 2010-08-04 18:51 -0700 ged
|
41
|
-
More Configurability::Config work
|
42
|
-
|
43
|
-
14 44db952eb824 2010-08-04 18:23 -0700 ged
|
44
|
-
More work on Configurability::Config
|
45
|
-
|
46
|
-
13 2323bf260e7c 2010-08-04 16:28 -0700 ged
|
47
|
-
Finishing up Configurability::Config.
|
48
|
-
|
49
|
-
12 9e0bab83afd5 2010-08-04 10:18 -0700 ged
|
50
|
-
Build system updates.
|
51
|
-
|
52
|
-
11 cba63cef2f7f 2010-08-04 10:17 -0700 ged
|
53
|
-
Add an rspec shared behavior for testing classes with Configurability
|
54
|
-
|
55
|
-
10 4ffdde3f7a2f 2010-07-16 16:55 -0700 ged
|
56
|
-
Adding a Configurability::Config class for YAML config loading.
|
57
|
-
|
58
|
-
9 d225cef4269e 2010-07-16 16:54 -0700 ged
|
59
|
-
Updating README, project metadata, adding .irbrc
|
60
|
-
|
61
|
-
8 9da882b82786 2010-07-16 16:53 -0700 ged
|
62
|
-
Version bump; debugging log
|
63
|
-
|
64
|
-
7 ecf5d4565338 2010-07-12 15:52 -0700 ged
|
65
|
-
Added tag 1.0.0 for changeset 74b5dd9a89c9
|
66
|
-
|
67
|
-
6[1.0.0] 74b5dd9a89c9 2010-07-12 15:52 -0700 ged
|
68
|
-
Added signature for changeset e0fef8dabba4
|
69
|
-
|
70
|
-
5 e0fef8dabba4 2010-07-12 15:51 -0700 ged
|
71
|
-
README formatting, YARD tag fix.
|
72
|
-
|
73
|
-
4 4d7044641f87 2010-07-12 13:38 -0700 ged
|
74
|
-
Documentation, added a test for classname normalization.
|
75
|
-
|
76
|
-
3 0b395dbf657f 2010-07-12 08:13 -0700 ged
|
77
|
-
Added some stuff to the README, made String config keys work.
|
78
|
-
|
79
|
-
2 9531380cc3f2 2010-07-12 07:52 -0700 ged
|
80
|
-
Adding an example.
|
81
|
-
|
82
|
-
1 982ba9fe2e6e 2010-07-11 11:26 -0700 ged
|
83
|
-
Initial version.
|
84
|
-
|
85
|
-
0 ac34a9d6c913 2010-07-10 17:18 -0700 ged
|
86
|
-
Adding rake subrepo
|
87
|
-
|
data/rake/191_compat.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
# 1.9.1 fixes
|
2
|
-
|
3
|
-
|
4
|
-
# Make Pathname compatible with 1.8.7 Pathname.
|
5
|
-
unless Pathname.instance_methods.include?( :=~ )
|
6
|
-
class Pathname
|
7
|
-
def self::glob( *args ) # :yield: p
|
8
|
-
args = args.collect {|p| p.to_s }
|
9
|
-
if block_given?
|
10
|
-
Dir.glob(*args) {|f| yield self.new(f) }
|
11
|
-
else
|
12
|
-
Dir.glob(*args).map {|f| self.new(f) }
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def =~( other )
|
17
|
-
self.to_s =~ other
|
18
|
-
end
|
19
|
-
|
20
|
-
def to_str
|
21
|
-
self.to_s
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
|