config_logic 0.1.0 → 0.1.1
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/README.md +159 -0
- data/lib/config_logic/file_cache.rb +1 -1
- metadata +42 -52
- data/README.rdoc +0 -159
data/README.md
ADDED
@@ -0,0 +1,159 @@
|
|
1
|
+
# Config Logic
|
2
|
+
|
3
|
+
Config Logic is a configuration management tool for Ruby/Rails applications. It
|
4
|
+
wraps any set of config files in a managed access layer which supports
|
5
|
+
|
6
|
+
* caching
|
7
|
+
* multi argument, hash style, or dot style access
|
8
|
+
* ordered overlays
|
9
|
+
* dynamic or static multiplexing
|
10
|
+
|
11
|
+
|
12
|
+
## Requirements
|
13
|
+
|
14
|
+
The following gems will be installed along with config_logic
|
15
|
+
|
16
|
+
* activesupport (2.2.2+)
|
17
|
+
* buffered_logger (0.1.2+)
|
18
|
+
|
19
|
+
|
20
|
+
## Installation
|
21
|
+
|
22
|
+
gem install config_logic
|
23
|
+
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
Imagine that your application has a config directory with the following layout,
|
28
|
+
|
29
|
+
config/config_prod.yml -->
|
30
|
+
|
31
|
+
:key1: 1
|
32
|
+
:key2: 2
|
33
|
+
:key3: 3
|
34
|
+
|
35
|
+
config/config_dev.yml -->
|
36
|
+
|
37
|
+
:key1: 11
|
38
|
+
:key2: 12
|
39
|
+
:key3: 13
|
40
|
+
|
41
|
+
config/dir1/config_prod.yml -->
|
42
|
+
|
43
|
+
:key1: 11
|
44
|
+
:key2: 12
|
45
|
+
:key3: 13
|
46
|
+
|
47
|
+
config/dir1/config_dev.yml -->
|
48
|
+
|
49
|
+
:key4: 1
|
50
|
+
:key5: 2
|
51
|
+
:key6: 3
|
52
|
+
|
53
|
+
|
54
|
+
### Initialization
|
55
|
+
|
56
|
+
c = ConfigLogic.new('path/to/config/dir')
|
57
|
+
c = ConfigLogic.new(['path1', 'path2'])
|
58
|
+
|
59
|
+
|
60
|
+
### Data Access
|
61
|
+
|
62
|
+
c.config.key1 => 1
|
63
|
+
c[:config][:key1] => 1
|
64
|
+
c['config']['key1'] => 1
|
65
|
+
c(:config, :key1) => 1
|
66
|
+
c('config', 'key1') => 1
|
67
|
+
c.unknown => nil
|
68
|
+
c.config.unknown => nil
|
69
|
+
|
70
|
+
|
71
|
+
### Rebuilding the Config Cache
|
72
|
+
|
73
|
+
c.reload!
|
74
|
+
|
75
|
+
|
76
|
+
### Applying Overlays
|
77
|
+
|
78
|
+
An Overlay allows multiple config values to be merged in a specified order. The
|
79
|
+
merge order is determined by the order of the key names in the :inputs parameter.
|
80
|
+
|
81
|
+
#### Global
|
82
|
+
|
83
|
+
c = ConfigLogic.new('path/to/config/dir', :overlays => [ { :name => 'config',
|
84
|
+
:inputs => [:config_prod, :config_dev] } ] )
|
85
|
+
c.config.key1 => 11
|
86
|
+
c.config.key2 => 12
|
87
|
+
c.config.key3 => 13
|
88
|
+
c.config.dir1.key1 => 11
|
89
|
+
c.config.dir1.key2 => 12
|
90
|
+
c.config.dir1.key3 => 13
|
91
|
+
c.config.dir1.key4 => 1
|
92
|
+
c.config.dir1.key5 => 2
|
93
|
+
c.config.dir1.key6 => 3
|
94
|
+
|
95
|
+
#### Local
|
96
|
+
|
97
|
+
c.config.insert_overlay( { :name => 'config',
|
98
|
+
:inputs => [:config_prod, :config_dev] } )
|
99
|
+
c.config.key1 => 11
|
100
|
+
c.config.key2 => 12
|
101
|
+
c.config.key3 => 13
|
102
|
+
c.config.dir1.key1 => 1
|
103
|
+
c.config.dir1.key2 => 2
|
104
|
+
c.config.dir1.key3 => 3
|
105
|
+
c.config.dir1.key4 => nil
|
106
|
+
|
107
|
+
|
108
|
+
### Applying Multiplexers
|
109
|
+
|
110
|
+
A multiplexer groups multiple config values and uses the result of a supplied code
|
111
|
+
block to choose the appropriate one. Multiplexers can be static or dynamic. A
|
112
|
+
static multiplexer is evaluated when it is created and its result replaces the
|
113
|
+
key group specified. A dynamic multiplexer is evaluated every time it's called.
|
114
|
+
Multiplexers are static by default.
|
115
|
+
|
116
|
+
|
117
|
+
#### Global
|
118
|
+
|
119
|
+
c = ConfigLogic.new('path/to/config/dir', :multiplexers => [ { :name => 'key',
|
120
|
+
:selector => Proc.new {1 + 1 },
|
121
|
+
:inputs => {1 => :key1, 2 => :key2, 3 => :key3} } ] )
|
122
|
+
c.config.key => 2
|
123
|
+
c.config.key1 => nil
|
124
|
+
c.config.key2 => nil
|
125
|
+
c.config.key3 => nil
|
126
|
+
c.config.dir1.key => 2
|
127
|
+
c.config.dir1.key1 => nil
|
128
|
+
c.config.dir1.key2 => nil
|
129
|
+
c.config.dir1.key3 => nil
|
130
|
+
|
131
|
+
#### Local
|
132
|
+
|
133
|
+
c.config.insert_multiplexer({ :name => 'key',
|
134
|
+
:selector => Proc.new {1 + 1 },
|
135
|
+
:inputs => {1 => :key1, 2 => :key2, 3 => :key3} })
|
136
|
+
c.config.key => 2
|
137
|
+
c.config.key1 => nil
|
138
|
+
c.config.key2 => nil
|
139
|
+
c.config.key3 => nil
|
140
|
+
c.config.dir1.key => nil
|
141
|
+
c.config.dir1.key1 => 1
|
142
|
+
c.config.dir1.key2 => 2
|
143
|
+
c.config.dir1.key3 => 3
|
144
|
+
|
145
|
+
#### Static vs Dynamic
|
146
|
+
|
147
|
+
A dynamic multiplexer will re-evaluate the selecor proc every time it's called
|
148
|
+
|
149
|
+
c.config.insert_multiplexer({ :name => 'key',
|
150
|
+
:static => false,
|
151
|
+
:selector => Proc.new { rand(3) + 1 },
|
152
|
+
:inputs => {1 => :key1, 2 => :key2, 3 => :key3} })
|
153
|
+
c.config.key => 2 = time = 0
|
154
|
+
c.config.key => 1 = time = 0 + n
|
155
|
+
|
156
|
+
|
157
|
+
## Credits
|
158
|
+
|
159
|
+
Inspired by RConfig (Rahmal Conda) / activeconfig (Enova Financial)
|
metadata
CHANGED
@@ -1,97 +1,87 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: config_logic
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
4
5
|
prerelease:
|
5
|
-
version: 0.1.0
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Alex Skryl
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-07-31 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
17
15
|
name: activesupport
|
18
|
-
|
19
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70304940575640 !ruby/object:Gem::Requirement
|
20
17
|
none: false
|
21
|
-
requirements:
|
22
|
-
- -
|
23
|
-
- !ruby/object:Gem::Version
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
24
21
|
version: 2.2.2
|
25
22
|
type: :runtime
|
26
|
-
version_requirements: *id001
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: buffered_logger
|
29
23
|
prerelease: false
|
30
|
-
|
24
|
+
version_requirements: *70304940575640
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: buffered_logger
|
27
|
+
requirement: &70304940574720 !ruby/object:Gem::Requirement
|
31
28
|
none: false
|
32
|
-
requirements:
|
33
|
-
- -
|
34
|
-
- !ruby/object:Gem::Version
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
35
32
|
version: 0.1.2
|
36
33
|
type: :runtime
|
37
|
-
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70304940574720
|
38
36
|
description: An intuitive configuration access layer
|
39
37
|
email: rut216@gmail.com
|
40
38
|
executables: []
|
41
|
-
|
42
39
|
extensions: []
|
43
|
-
|
44
40
|
extra_rdoc_files: []
|
45
|
-
|
46
|
-
files:
|
47
|
-
- lib/config_logic.rb
|
48
|
-
- lib/config_logic/logger.rb
|
49
|
-
- lib/config_logic/config_logic.rb
|
50
|
-
- lib/config_logic/logic_element.rb
|
41
|
+
files:
|
51
42
|
- lib/config_logic/cache.rb
|
52
|
-
- lib/config_logic/
|
53
|
-
- lib/config_logic/file_cache.rb
|
54
|
-
- lib/config_logic/multiplexer.rb
|
43
|
+
- lib/config_logic/config_logic.rb
|
55
44
|
- lib/config_logic/core_ext/array.rb
|
56
45
|
- lib/config_logic/core_ext/class.rb
|
46
|
+
- lib/config_logic/file_cache.rb
|
47
|
+
- lib/config_logic/logger.rb
|
48
|
+
- lib/config_logic/logic_element.rb
|
49
|
+
- lib/config_logic/multiplexer.rb
|
57
50
|
- lib/config_logic/overlay.rb
|
51
|
+
- lib/config_logic/tree_cache.rb
|
52
|
+
- lib/config_logic.rb
|
58
53
|
- spec/cache_spec.rb
|
54
|
+
- spec/config_logic_spec.rb
|
59
55
|
- spec/file_cache_spec.rb
|
60
56
|
- spec/logic_element_spec.rb
|
61
57
|
- spec/multiplexer_spec.rb
|
62
58
|
- spec/overlay_spec.rb
|
63
|
-
- spec/config_logic_spec.rb
|
64
59
|
- spec/spec_helper.rb
|
65
60
|
- spec/tree_cache_spec.rb
|
66
|
-
- README.
|
61
|
+
- README.md
|
67
62
|
- TODO
|
68
|
-
has_rdoc: true
|
69
63
|
homepage: http://github.com/skryl
|
70
64
|
licenses: []
|
71
|
-
|
72
65
|
post_install_message:
|
73
66
|
rdoc_options: []
|
74
|
-
|
75
|
-
require_paths:
|
67
|
+
require_paths:
|
76
68
|
- lib
|
77
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
78
70
|
none: false
|
79
|
-
requirements:
|
80
|
-
- -
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version:
|
83
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
76
|
none: false
|
85
|
-
requirements:
|
86
|
-
- -
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version:
|
77
|
+
requirements:
|
78
|
+
- - ! '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
89
81
|
requirements: []
|
90
|
-
|
91
82
|
rubyforge_project:
|
92
|
-
rubygems_version: 1.
|
83
|
+
rubygems_version: 1.8.15
|
93
84
|
signing_key:
|
94
85
|
specification_version: 3
|
95
86
|
summary: A configuration access layer for Ruby/Rails applications
|
96
87
|
test_files: []
|
97
|
-
|
data/README.rdoc
DELETED
@@ -1,159 +0,0 @@
|
|
1
|
-
= Config Logic
|
2
|
-
|
3
|
-
Config Logic is a configuration management tool for Ruby/Rails applications. It
|
4
|
-
wraps any set of config files in a managed access layer which supports
|
5
|
-
|
6
|
-
* caching
|
7
|
-
* multi argument, hash style, or dot style access
|
8
|
-
* ordered overlays
|
9
|
-
* dynamic or static multiplexing
|
10
|
-
|
11
|
-
|
12
|
-
== Requirements
|
13
|
-
|
14
|
-
The following gems will be installed along with config_logic
|
15
|
-
|
16
|
-
* activesupport (2.2.2+)
|
17
|
-
* buffered_logger (0.1.2+)
|
18
|
-
|
19
|
-
|
20
|
-
== Installation
|
21
|
-
|
22
|
-
gem install config_logic
|
23
|
-
|
24
|
-
|
25
|
-
== Usage
|
26
|
-
|
27
|
-
Imagine that your application has a config directory with the following layout,
|
28
|
-
|
29
|
-
config/config_prod.yml -->
|
30
|
-
|
31
|
-
:key1: 1
|
32
|
-
:key2: 2
|
33
|
-
:key3: 3
|
34
|
-
|
35
|
-
config/config_dev.yml -->
|
36
|
-
|
37
|
-
:key1: 11
|
38
|
-
:key2: 12
|
39
|
-
:key3: 13
|
40
|
-
|
41
|
-
config/dir1/config_prod.yml -->
|
42
|
-
|
43
|
-
:key1: 11
|
44
|
-
:key2: 12
|
45
|
-
:key3: 13
|
46
|
-
|
47
|
-
config/dir2/config_dev.yml -->
|
48
|
-
|
49
|
-
:key4: 1
|
50
|
-
:key5: 2
|
51
|
-
:key6: 3
|
52
|
-
|
53
|
-
|
54
|
-
=== Initialization
|
55
|
-
|
56
|
-
c = ConfigLogic.new('path/to/config/dir')
|
57
|
-
c = ConfigLogic.new(['path1', 'path2'])
|
58
|
-
|
59
|
-
|
60
|
-
=== Data Access
|
61
|
-
|
62
|
-
c.config.key1 => 1
|
63
|
-
c[:config][:key1] => 1
|
64
|
-
c['config']['key1'] => 1
|
65
|
-
c(:config, :key1) => 1
|
66
|
-
c('config', 'key1') => 1
|
67
|
-
c.unknown => nil
|
68
|
-
c.config.unknown => nil
|
69
|
-
|
70
|
-
|
71
|
-
=== Rebuilding the Config Cache
|
72
|
-
|
73
|
-
c.reload!
|
74
|
-
|
75
|
-
|
76
|
-
=== Applying Overlays
|
77
|
-
|
78
|
-
An Overlay allows multiple config values to be merged in a specified order. The
|
79
|
-
merge order is determined by the order of the key names in the :inputs parameter.
|
80
|
-
|
81
|
-
==== Global
|
82
|
-
|
83
|
-
c = ConfigLogic.new('path/to/config/dir', :overlays => [ { :name => 'config',
|
84
|
-
:inputs => [:config_prod, :config_dev] } ] )
|
85
|
-
c.config.key1 => 11
|
86
|
-
c.config.key2 => 12
|
87
|
-
c.config.key3 => 13
|
88
|
-
c.config.dir1.key1 => 11
|
89
|
-
c.config.dir1.key2 => 12
|
90
|
-
c.config.dir1.key3 => 13
|
91
|
-
c.config.dir1.key4 => 1
|
92
|
-
c.config.dir1.key5 => 2
|
93
|
-
c.config.dir1.key6 => 3
|
94
|
-
|
95
|
-
==== Local
|
96
|
-
|
97
|
-
c.config.insert_overlay( { :name => 'config',
|
98
|
-
:inputs => [:config_prod, :config_dev] } )
|
99
|
-
c.config.key1 => 11
|
100
|
-
c.config.key2 => 12
|
101
|
-
c.config.key3 => 13
|
102
|
-
c.config.dir1.key1 => 1
|
103
|
-
c.config.dir1.key2 => 2
|
104
|
-
c.config.dir1.key3 => 3
|
105
|
-
c.config.dir1.key4 => nil
|
106
|
-
|
107
|
-
|
108
|
-
=== Applying Multiplexers
|
109
|
-
|
110
|
-
A multiplexer groups multiple config values and uses the result of a supplied code
|
111
|
-
block to choose the appropriate one. Multiplexers can be static or dynamic. A
|
112
|
-
static multiplexer is evaluated when it is created and its result replaces the
|
113
|
-
key group specified. A dynamic multiplexer is evaluated every time it's called.
|
114
|
-
Multiplexers are static by default.
|
115
|
-
|
116
|
-
|
117
|
-
==== Global
|
118
|
-
|
119
|
-
c = ConfigLogic.new('path/to/config/dir', :multiplexers => [ { :name => 'key',
|
120
|
-
:selector => Proc.new {1 + 1 },
|
121
|
-
:inputs => {1 => :key1, 2 => :key2, 3 => :key3} } ] )
|
122
|
-
c.config.key => 2
|
123
|
-
c.config.key1 => nil
|
124
|
-
c.config.key2 => nil
|
125
|
-
c.config.key3 => nil
|
126
|
-
c.config.dir1.key => 2
|
127
|
-
c.config.dir1.key1 => nil
|
128
|
-
c.config.dir1.key2 => nil
|
129
|
-
c.config.dir1.key3 => nil
|
130
|
-
|
131
|
-
==== Local
|
132
|
-
|
133
|
-
c.config.insert_multiplexer({ :name => 'key',
|
134
|
-
:selector => Proc.new {1 + 1 },
|
135
|
-
:inputs => {1 => :key1, 2 => :key2, 3 => :key3} })
|
136
|
-
c.config.key => 2
|
137
|
-
c.config.key1 => nil
|
138
|
-
c.config.key2 => nil
|
139
|
-
c.config.key3 => nil
|
140
|
-
c.config.dir1.key => nil
|
141
|
-
c.config.dir1.key1 => 1
|
142
|
-
c.config.dir1.key2 => 2
|
143
|
-
c.config.dir1.key3 => 3
|
144
|
-
|
145
|
-
==== Static vs Dynamic
|
146
|
-
|
147
|
-
A dynamic multiplexer will re-evaluate the selecor proc every time it's called
|
148
|
-
|
149
|
-
c.config.insert_multiplexer({ :name => 'key',
|
150
|
-
:static => false,
|
151
|
-
:selector => Proc.new { rand(3) + 1 },
|
152
|
-
:inputs => {1 => :key1, 2 => :key2, 3 => :key3} })
|
153
|
-
c.config.key => 2 # time = 0
|
154
|
-
c.config.key => 1 # time = 0 + n
|
155
|
-
|
156
|
-
|
157
|
-
== Credits
|
158
|
-
|
159
|
-
Inspired by RConfig (Rahmal Conda) / activeconfig (Enova Financial)
|