iqeo-conf 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -2
- data/.yardoc/checksums +2 -0
- data/.yardoc/object_types +0 -0
- data/.yardoc/objects/root.dat +0 -0
- data/.yardoc/proxy_types +2 -0
- data/Gemfile.lock +8 -2
- data/README.md +88 -60
- data/Rakefile +15 -7
- data/doc/Iqeo/Configuration.html +974 -0
- data/doc/Iqeo.html +128 -0
- data/doc/_index.html +125 -0
- data/doc/class_list.html +53 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +328 -0
- data/doc/file.README.html +206 -0
- data/doc/file_list.html +55 -0
- data/doc/frames.html +28 -0
- data/doc/index.html +206 -0
- data/doc/js/app.js +208 -0
- data/doc/js/full_list.js +173 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +140 -0
- data/doc/top-level-namespace.html +112 -0
- data/iqeo-conf.gemspec +6 -3
- data/lib/iqeo/configuration/version.rb +2 -1
- data/lib/iqeo/configuration.rb +28 -8
- data/spec/configuration_spec.rb +9 -9
- metadata +62 -20
- data/.rspec +0 -2
- data/.rvmrc +0 -1
- data/pkg/iqeo-conf-0.0.1.gem +0 -0
- data/pkg/iqeo-conf-0.0.2.gem +0 -0
- data/pkg/iqeo-conf-0.0.3.gem +0 -0
- data/pkg/iqeo-conf-0.0.4.gem +0 -0
- data/pkg/iqeo-conf-0.0.5.gem +0 -0
- data/pkg/iqeo-conf-0.0.6.gem +0 -0
- data/pkg/iqeo-conf-0.0.7.gem +0 -0
- data/pkg/iqeo-conf-0.0.8.gem +0 -0
- data/pkg/iqeo-conf-0.0.9.gem +0 -0
data/.gitignore
CHANGED
data/.yardoc/checksums
ADDED
Binary file
|
Binary file
|
data/.yardoc/proxy_types
ADDED
data/Gemfile.lock
CHANGED
@@ -2,14 +2,16 @@ PATH
|
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
4
|
iqeo-conf (0.0.11)
|
5
|
-
blankslate (~> 2.1.2.4)
|
6
5
|
|
7
6
|
GEM
|
8
7
|
remote: https://rubygems.org/
|
9
8
|
specs:
|
10
|
-
blankslate (2.1.2.4)
|
11
9
|
diff-lcs (1.1.3)
|
10
|
+
json (1.7.1)
|
12
11
|
rake (0.9.2.2)
|
12
|
+
rdoc (3.12)
|
13
|
+
json (~> 1.4)
|
14
|
+
redcarpet (2.1.1)
|
13
15
|
rspec (2.9.0)
|
14
16
|
rspec-core (~> 2.9.0)
|
15
17
|
rspec-expectations (~> 2.9.0)
|
@@ -18,6 +20,7 @@ GEM
|
|
18
20
|
rspec-expectations (2.9.1)
|
19
21
|
diff-lcs (~> 1.1.3)
|
20
22
|
rspec-mocks (2.9.0)
|
23
|
+
yard (0.8.1)
|
21
24
|
|
22
25
|
PLATFORMS
|
23
26
|
ruby
|
@@ -25,4 +28,7 @@ PLATFORMS
|
|
25
28
|
DEPENDENCIES
|
26
29
|
iqeo-conf!
|
27
30
|
rake (~> 0.9.2)
|
31
|
+
rdoc (~> 3.12.0)
|
32
|
+
redcarpet (~> 2.1.1)
|
28
33
|
rspec (~> 2.9.0)
|
34
|
+
yard (~> 0.8.1)
|
data/README.md
CHANGED
@@ -1,108 +1,136 @@
|
|
1
1
|
# Iqeo::Configuration
|
2
2
|
|
3
|
-
A DSL
|
3
|
+
A DSL representing configuration files.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
It
|
7
|
+
It`s a gem...
|
8
8
|
|
9
|
-
|
10
|
-
$ gem install iqeo-conf
|
11
|
-
```
|
9
|
+
$ gem install iqeo-conf
|
12
10
|
|
13
11
|
## Usage
|
14
12
|
|
15
|
-
Require
|
13
|
+
Require 'iqeo/configuration' and optionally include Iqeo namespace:
|
16
14
|
|
17
15
|
```ruby
|
18
16
|
require 'iqeo/configuration'
|
17
|
+
include Iqeo
|
19
18
|
```
|
20
19
|
|
21
|
-
### Create
|
20
|
+
### Create configuration
|
22
21
|
|
23
|
-
|
22
|
+
There are three ways to create configurations; explicit, block DSL, eval DSL.
|
24
23
|
|
25
|
-
####
|
24
|
+
#### Explicit
|
26
25
|
|
27
|
-
|
28
|
-
|
26
|
+
Call Configuration#new without a block.
|
27
|
+
Explicitly call methods on instance to configure instance.
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
conf.alpha
|
33
|
-
conf.bravo
|
34
|
-
conf.charlie
|
35
|
-
conf.delta
|
29
|
+
```ruby
|
30
|
+
conf = Configuration.new
|
31
|
+
conf.alpha 1
|
32
|
+
conf.bravo 2.0
|
33
|
+
conf.charlie :three
|
34
|
+
conf.delta "four"
|
36
35
|
```
|
37
36
|
|
38
|
-
####
|
37
|
+
#### Block DSL
|
38
|
+
|
39
|
+
Call Configuration#new with a block that expects a variable, a new instance will be yielded.
|
40
|
+
Within block, call methods on yielded instance to configure.
|
39
41
|
|
40
42
|
```ruby
|
41
|
-
conf =
|
43
|
+
conf = Configuration.new do |c|
|
44
|
+
c.alpha 1
|
45
|
+
c.bravo 2.0
|
46
|
+
c.charlie :three
|
47
|
+
c.delta "four"
|
48
|
+
end
|
49
|
+
```
|
42
50
|
|
43
|
-
|
44
|
-
c.bravo "foobar"
|
45
|
-
c.charlie { :a => 1, :b => 2, :c => 3 }
|
46
|
-
c.delta [ 1, 2, 3 ]
|
51
|
+
#### Eval DSL
|
47
52
|
|
53
|
+
Call Configuration#new with a block that does not expect a variable, contents of the block are eval`d in the context of the new instance.
|
54
|
+
Call methods with implied self to configure instance.
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
conf = Configuration.new do
|
58
|
+
alpha 1
|
59
|
+
bravo 2.0
|
60
|
+
charlie :three
|
61
|
+
delta "four"
|
48
62
|
end
|
49
63
|
```
|
50
64
|
|
51
|
-
|
65
|
+
### Read configuration
|
52
66
|
|
53
|
-
|
54
|
-
|
67
|
+
All examples above result in the same configuration.
|
68
|
+
Configuration settings can be retrieved directly or indirectly.
|
55
69
|
|
56
|
-
|
57
|
-
bravo "foobar"
|
58
|
-
charlie { :a => 1, :b => 2, :c => 3 }
|
59
|
-
delta [ 1, 2, 3 ]
|
70
|
+
#### Directly
|
60
71
|
|
61
|
-
|
72
|
+
##### Named method
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
conf.alpha # => 1
|
76
|
+
conf.bravo # => 2.0
|
77
|
+
conf.charlie # => :three
|
78
|
+
conf.delta # => "four"
|
62
79
|
```
|
63
80
|
|
64
|
-
|
81
|
+
##### [ 'string' ]
|
65
82
|
|
66
|
-
|
83
|
+
```ruby
|
84
|
+
conf['alpha'] # => 1
|
85
|
+
conf['bravo'] # => 2.0
|
86
|
+
conf['charlie'] # => :three
|
87
|
+
conf['delta'] # => "four"
|
88
|
+
```
|
89
|
+
|
90
|
+
##### [ :symbol ]
|
67
91
|
|
68
92
|
```ruby
|
69
|
-
conf
|
70
|
-
conf
|
71
|
-
conf
|
72
|
-
conf
|
93
|
+
conf[:alpha] # => 1
|
94
|
+
conf[:bravo] # => 2.0
|
95
|
+
conf[:charlie] # => :three
|
96
|
+
conf[:delta] # => "four"
|
73
97
|
```
|
74
98
|
|
75
|
-
|
99
|
+
#### Indirectly
|
76
100
|
|
77
|
-
|
101
|
+
The underlying storage is an indifferent hash, so the usual Hash and Enumerable methods work.
|
78
102
|
|
79
|
-
|
103
|
+
##### Hash & Enumerable methods
|
80
104
|
|
81
|
-
|
105
|
+
```ruby
|
106
|
+
conf.size # => 4
|
107
|
+
conf.keys # => [ 'alpha', 'bravo', 'charlie', 'delta' ]
|
108
|
+
conf.collect { |key,value| value } # => [ 1, 2.0, :three, 'four' ]
|
109
|
+
```
|
82
110
|
|
83
|
-
|
84
|
-
* Nested configurations
|
85
|
-
* Nested configurations inherit settings
|
86
|
-
* Nested configurations override inherited settings
|
87
|
-
* Load configurations from a string or file at creation
|
88
|
-
* Iterate over items hash - by delegation to hash
|
89
|
-
* Indifferent hash access - using ActiveSupport/HashWithIndifferentAccess
|
90
|
-
* Clean DSL syntax for creating a nested configuration - just a block ?
|
91
|
-
* Load configurations from a string or file after creation / in DSL block
|
111
|
+
## Features
|
92
112
|
|
93
|
-
|
113
|
+
* settings by named methods
|
114
|
+
* settings by '[]' & '[]='
|
115
|
+
* settings & locals with '='
|
116
|
+
* referencing existing settings
|
117
|
+
* nested configurations
|
118
|
+
* inheritance & override
|
119
|
+
* read from string, at creation, or after - merged & nested
|
120
|
+
* load from filename, at creation, or after - merged & nested
|
121
|
+
* todo: merge configurations
|
122
|
+
* todo: defaults
|
123
|
+
* todo: blank slate
|
94
124
|
|
95
|
-
|
125
|
+
## Fancy usage
|
96
126
|
|
97
|
-
*
|
98
|
-
*
|
99
|
-
*
|
100
|
-
* Option to get hash directly to prevent polluting namespace with delegated hash methods
|
101
|
-
* Consider issues around deferred interpolation / procs / lambdas etc...
|
102
|
-
* Load other formats into configuration - YAML, CSV, ...anything Enumerable should be easy enough.
|
127
|
+
* Dynamic settings by '[]' & '[]=' & 'self'
|
128
|
+
* Multiple configuration files
|
129
|
+
* Hierarchial configuration files
|
103
130
|
|
104
131
|
## License
|
105
132
|
|
106
|
-
|
107
|
-
See LICENSE file
|
133
|
+
Copyright Gerard Fowley (gerard.fowley@iqeo.net).
|
108
134
|
|
135
|
+
Licensed under GPL Version 3 license.
|
136
|
+
See LICENSE file.
|
data/Rakefile
CHANGED
@@ -1,14 +1,22 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
2
|
require "bundler/gem_tasks"
|
3
|
-
require "rake/testtask"
|
4
|
-
|
5
|
-
Rake::TestTask.new do |t|
|
6
|
-
t.libs << "test"
|
7
|
-
t.test_files = FileList['test/test*.rb']
|
8
|
-
t.verbose = true
|
9
|
-
end
|
10
3
|
|
11
4
|
require 'rspec/core/rake_task'
|
12
5
|
RSpec::Core::RakeTask.new('spec')
|
13
6
|
|
7
|
+
require 'rdoc/task'
|
8
|
+
RDoc::Task.new do |rdoc|
|
9
|
+
rdoc.main = "README.rdoc"
|
10
|
+
rdoc.rdoc_files.include "README.rdoc", "lib/**/*.rb"
|
11
|
+
rdoc.rdoc_files.exclude "lib/**/hash_with_indifferent_access.rb"
|
12
|
+
rdoc.options << "--all" << "--verbose"
|
13
|
+
end
|
14
|
+
|
15
|
+
require 'yard'
|
16
|
+
#require 'yard/rake/yardoc_task'
|
17
|
+
YARD::Rake::YardocTask.new do |yard|
|
18
|
+
yard.files = %w( lib/**/*.rb )
|
19
|
+
yard.options = %w( --main README.md --exclude hash_with_indifferent_access.rb )
|
20
|
+
end
|
21
|
+
|
14
22
|
task :default => :spec
|