loquacious 1.4.0 → 1.4.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/History.txt +6 -0
- data/Rakefile +2 -1
- data/lib/loquacious.rb +1 -1
- data/lib/loquacious/configuration.rb +26 -8
- data/spec/configuration_spec.rb +19 -0
- metadata +7 -7
data/History.txt
CHANGED
data/Rakefile
CHANGED
@@ -19,8 +19,9 @@ Bones {
|
|
19
19
|
version Loquacious::VERSION
|
20
20
|
readme_file 'README.rdoc'
|
21
21
|
ignore_file '.gitignore'
|
22
|
-
ruby_opts %w[-W0]
|
22
|
+
# ruby_opts %w[-W0]
|
23
23
|
spec.opts << '--color'
|
24
|
+
rubyforge.name 'codeforpeople'
|
24
25
|
|
25
26
|
depend_on 'rspec', :development => true
|
26
27
|
depend_on 'bones-git', :development => true
|
data/lib/loquacious.rb
CHANGED
@@ -49,9 +49,18 @@ module Loquacious
|
|
49
49
|
alias :help :help_for
|
50
50
|
end
|
51
51
|
|
52
|
-
|
52
|
+
Keepers = %r/^__|^object_id$|^instance_of\?$|^kind_of\?$|^equal\?$/
|
53
53
|
instance_methods.each do |m|
|
54
|
-
|
54
|
+
next if m[Keepers]
|
55
|
+
undef_method m
|
56
|
+
end
|
57
|
+
Kernel.methods.each do |m|
|
58
|
+
next if m[Keepers]
|
59
|
+
module_eval <<-CODE
|
60
|
+
def #{m}( *args, &block )
|
61
|
+
self.method_missing('#{m}', *args, &block)
|
62
|
+
end
|
63
|
+
CODE
|
55
64
|
end
|
56
65
|
|
57
66
|
# Accessor for the description hash.
|
@@ -104,7 +113,7 @@ module Loquacious
|
|
104
113
|
ec = class << self; self; end
|
105
114
|
ec.module_eval code
|
106
115
|
rescue StandardError
|
107
|
-
raise Error, "cannot evalutate this code:\n#{code}\n"
|
116
|
+
Kernel.raise Error, "cannot evalutate this code:\n#{code}\n"
|
108
117
|
end
|
109
118
|
|
110
119
|
# Merge the contents of the _other_ configuration into this one. Values
|
@@ -116,7 +125,7 @@ module Loquacious
|
|
116
125
|
#
|
117
126
|
def merge!( other )
|
118
127
|
return self if other.equal? self
|
119
|
-
raise Error, "can only merge another Configuration" unless other.kind_of?(Configuration)
|
128
|
+
Kernel.raise Error, "can only merge another Configuration" unless other.kind_of?(Configuration)
|
120
129
|
|
121
130
|
other.__desc.each do |key,desc|
|
122
131
|
value = other.__send__(key)
|
@@ -158,10 +167,18 @@ module Loquacious
|
|
158
167
|
# configuration object.
|
159
168
|
#
|
160
169
|
class DSL
|
161
|
-
|
162
|
-
|
170
|
+
Keepers = %r/^__|^object_id$/
|
163
171
|
instance_methods.each do |m|
|
164
|
-
|
172
|
+
next if m[Keepers]
|
173
|
+
undef_method m
|
174
|
+
end
|
175
|
+
Kernel.methods.each do |m|
|
176
|
+
next if m[Keepers]
|
177
|
+
module_eval <<-CODE
|
178
|
+
def #{m}( *args, &block )
|
179
|
+
self.method_missing('#{m}', *args, &block)
|
180
|
+
end
|
181
|
+
CODE
|
165
182
|
end
|
166
183
|
|
167
184
|
# Create a new DSL and evaluate the given _block_ in the context of
|
@@ -181,7 +198,8 @@ module Loquacious
|
|
181
198
|
def initialize( &block )
|
182
199
|
@description = nil
|
183
200
|
@__config = Configuration.new
|
184
|
-
|
201
|
+
Object.instance_method(:instance_eval).bind(self).
|
202
|
+
call(&block) if block
|
185
203
|
end
|
186
204
|
|
187
205
|
# Dynamically adds the given _method_ to the configuration as an
|
data/spec/configuration_spec.rb
CHANGED
@@ -71,6 +71,25 @@ describe Loquacious::Configuration do
|
|
71
71
|
cfg[:five].should == 5
|
72
72
|
end
|
73
73
|
|
74
|
+
it 'should allow Kernel methods to be treated as configuration attributes' do
|
75
|
+
cfg = Loquacious::Configuration.new {
|
76
|
+
fork 'spoon knife spork'
|
77
|
+
split 'join'
|
78
|
+
raise 'double down'
|
79
|
+
puts 'not what you think'
|
80
|
+
}
|
81
|
+
|
82
|
+
cfg['fork'].should == 'spoon knife spork'
|
83
|
+
cfg['split'].should == 'join'
|
84
|
+
cfg['raise'].should == 'double down'
|
85
|
+
cfg['puts'].should == 'not what you think'
|
86
|
+
|
87
|
+
cfg[:fork].should == 'spoon knife spork'
|
88
|
+
cfg[:split].should == 'join'
|
89
|
+
cfg[:raise].should == 'double down'
|
90
|
+
cfg[:puts].should == 'not what you think'
|
91
|
+
end
|
92
|
+
|
74
93
|
# -----------------------------------------------------------------------
|
75
94
|
describe 'when merging' do
|
76
95
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: loquacious
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Pease
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-29 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 1.2.
|
23
|
+
version: 1.2.9
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bones-git
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.
|
33
|
+
version: 1.1.1
|
34
34
|
version:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: bones-extras
|
@@ -40,7 +40,7 @@ dependencies:
|
|
40
40
|
requirements:
|
41
41
|
- - ">="
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 1.0
|
43
|
+
version: 1.2.0
|
44
44
|
version:
|
45
45
|
- !ruby/object:Gem::Dependency
|
46
46
|
name: bones
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 3.
|
53
|
+
version: 3.1.0
|
54
54
|
version:
|
55
55
|
description: |-
|
56
56
|
Descriptive configuration files for Ruby written in Ruby.
|
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
147
|
version:
|
148
148
|
requirements: []
|
149
149
|
|
150
|
-
rubyforge_project:
|
150
|
+
rubyforge_project: codeforpeople
|
151
151
|
rubygems_version: 1.3.5
|
152
152
|
signing_key:
|
153
153
|
specification_version: 3
|