configfiles 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/Changelog +5 -0
  2. data/README.rdoc +2 -2
  3. data/lib/configfiles.rb +15 -3
  4. metadata +4 -3
data/Changelog ADDED
@@ -0,0 +1,5 @@
1
+ 0.2.0
2
+ * add 'virtual' parameter
3
+
4
+ 0.1.0
5
+ * first non-alpha release
data/README.rdoc CHANGED
@@ -3,12 +3,12 @@
3
3
  A simple library to specify the format of configuration files and the
4
4
  way to turn their data into Ruby objects.
5
5
 
6
- Ruby1.9 centric. "Lazy" to some extent and as needed.
6
+ Ruby1.9 centric. Uses some lazy evaluation.
7
7
 
8
8
  No write support: it's strongly sugested to use ERB or other
9
9
  templating systems for that.
10
10
 
11
- A good example usage is found at http:/github.com/gderosa/dansguardian.rb .
11
+ A good example usage is found at http://github.com/gderosa/dansguardian.rb .
12
12
 
13
13
  ==Author
14
14
 
data/lib/configfiles.rb CHANGED
@@ -7,7 +7,7 @@ require 'configfiles/extensions/enumerable'
7
7
 
8
8
  module ConfigFiles
9
9
 
10
- VERSION = '0.1.0'
10
+ VERSION = '0.2.0'
11
11
 
12
12
  # You should write a read(io) method,
13
13
  # taking an IO object and returnig a key-value hash, where keys
@@ -26,9 +26,8 @@ module ConfigFiles
26
26
  class ValidationFailed < ::RuntimeError; end
27
27
  class AlreadyDefinedParameter < ::Exception; end
28
28
  class DefaultAlreadySet < ::Exception; end
29
+ class VirtualParameterFound < ::RuntimeError; end
29
30
 
30
- AlreadyDefinedDefault = DefaultAlreadySet
31
-
32
31
  @@parameters ||= {}
33
32
  @@behavior ||= {
34
33
  :unknown_parameter => :ignore,
@@ -130,6 +129,19 @@ module ConfigFiles
130
129
  @@parameters[name][:default] = value
131
130
  end
132
131
 
132
+ # Define a parameter as a function of other parameters.
133
+ # Example:
134
+ # virtual :delta do |confdata|
135
+ # confdata[:this] - confdata[:that]
136
+ # end
137
+ def virtual(name, &block)
138
+ parameter name do |str|
139
+ raise VirtualParameterFound,
140
+ "'#{name}' is a virtual parameter, it shouldn't appear directly!"
141
+ end
142
+ default name, block
143
+ end
144
+
133
145
  # A special kind of parameter, with a special kind of converter,
134
146
  # which in turn
135
147
  # converts an Enumerable yielding Strings into an Enumerator of
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 1
7
+ - 2
8
8
  - 0
9
- version: 0.1.0
9
+ version: 0.2.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Guido De Rosa
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-09-14 00:00:00 +02:00
17
+ date: 2010-09-15 00:00:00 +02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -40,6 +40,7 @@ extra_rdoc_files:
40
40
  - README.rdoc
41
41
  files:
42
42
  - README.rdoc
43
+ - Changelog
43
44
  - lib/configfiles.rb
44
45
  - lib/configfiles/extensions/enumerable.rb
45
46
  has_rdoc: true