ahoward-configuration 1.0.0 → 1.1.0

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 CHANGED
@@ -152,9 +152,20 @@ SAMPLES
152
152
 
153
153
  ~ > ruby samples/d.rb
154
154
 
155
- 42
156
- "forty-two"
157
- 42.0
155
+ config/d.rb:2:in `object_id': wrong number of arguments (1 for 0) (ArgumentError)
156
+ from config/d.rb:2
157
+ from ./lib/configuration.rb:159:in `instance_eval'
158
+ from ./lib/configuration.rb:159:in `call'
159
+ from ./lib/configuration.rb:159:in `method_missing'
160
+ from ./lib/configuration.rb:105:in `evaluate'
161
+ from ./lib/configuration.rb:68:in `initialize'
162
+ from ./lib/configuration.rb:29:in `new'
163
+ from ./lib/configuration.rb:29:in `for'
164
+ from config/d.rb:1
165
+ from ./lib/configuration.rb:53:in `load'
166
+ from ./lib/configuration.rb:53:in `load'
167
+ from ./lib/configuration.rb:31:in `for'
168
+ from samples/d.rb:10
158
169
 
159
170
 
160
171
  <========< samples/e.rb >========>
@@ -7,7 +7,7 @@ Configuration.for('e'){
7
7
 
8
8
  respond_to = Method('bar')
9
9
 
10
- if respond_to.call('bar')
10
+ if respond_to.call()
11
11
  foobar 42.0
12
12
  end
13
13
  }
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification::new do |spec|
5
5
  spec.name = "configuration"
6
- spec.version = "1.0.0"
6
+ spec.version = "1.1.0"
7
7
  spec.platform = Gem::Platform::RUBY
8
8
  spec.summary = "configuration"
9
9
 
@@ -1,5 +1,5 @@
1
1
  class Configuration
2
- Configuration::Version = '1.0.0'
2
+ Configuration::Version = '1.1.0'
3
3
  def Configuration.version() Configuration::Version end
4
4
 
5
5
  Path = [
@@ -75,14 +75,15 @@ class Configuration
75
75
  end
76
76
  send :include, InstanceMethods
77
77
 
78
-
79
78
  class DSL
79
+ Protected = %r/^__|^object_id$/
80
+
80
81
  instance_methods.each do |m|
81
- undef_method m unless m[%r/^__/]
82
+ undef_method m unless m[Protected]
82
83
  end
83
84
 
84
85
  Kernel.methods.each do |m|
85
- next if m[%r/^__/]
86
+ next if m[Protected]
86
87
  module_eval <<-code
87
88
  def #{ m }(*a, &b)
88
89
  method_missing '#{ m }', *a, &b
@@ -100,7 +101,7 @@ class Configuration
100
101
 
101
102
  def self.evaluate configuration, options = {}, &block
102
103
  dsl = new configuration
103
- Pure[dsl].instance_eval &block if block
104
+ Pure[dsl].instance_eval(&block) if block
104
105
  options.each{|key, value| Pure[dsl].send key, value}
105
106
  Pure[dsl].instance_eval{ @__configuration }
106
107
  end
@@ -117,7 +118,8 @@ class Configuration
117
118
  @__configuration
118
119
  end
119
120
 
120
- def method_missing m, *a, &b
121
+ undef_method(:method_missing) rescue nil
122
+ def method_missing(m, *a, &b)
121
123
  if(a.empty? and b.nil?)
122
124
  return Pure[@__configuration].send(m, *a, &b)
123
125
  end
@@ -142,14 +144,35 @@ class Configuration
142
144
  define_method(m){ value }
143
145
  end
144
146
  end
147
+
148
+ verbose = $VERBOSE
149
+ begin
150
+ $VERBOSE = nil
151
+ def object_id(*args)
152
+ unless args.empty?
153
+ verbose = $VERBOSE
154
+ begin
155
+ $VERBOSE = nil
156
+ define_method(:object_id){ args.first }
157
+ ensure
158
+ $VERBOSE = verbose
159
+ end
160
+ else
161
+ return Pure[@__configuration].object_id
162
+ end
163
+ end
164
+ ensure
165
+ $VERBOSE = verbose
166
+ end
145
167
  end
146
168
 
147
- class Pure
169
+ class Pure
148
170
  Instance_Methods = Hash.new
171
+ Protected = %r/^__|^object_id$/
149
172
 
150
173
  ::Object.instance_methods.each do |m|
151
174
  Instance_Methods[m.to_s] = ::Object.instance_method m
152
- undef_method m unless m[%r/^__/]
175
+ undef_method m unless m[Protected]
153
176
  end
154
177
 
155
178
  def method_missing m, *a, &b
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ahoward-configuration
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ara T. Howard