loquacious 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +8 -1
- data/Rakefile +1 -0
- data/lib/loquacious.rb +1 -1
- data/lib/loquacious/configuration.rb +26 -2
- data/loquacious.gemspec +8 -8
- data/spec/configuration_spec.rb +27 -0
- data/tasks/setup.rb +1 -1
- data/tasks/zentest.rake +36 -0
- metadata +5 -4
data/History.txt
CHANGED
@@ -1,4 +1,11 @@
|
|
1
|
+
== 1.1.0 / 2009-04-05
|
2
|
+
|
3
|
+
* 1 minor enhancement
|
4
|
+
- Added hash accessor methods for configuration attributes
|
5
|
+
* 1 bug fix
|
6
|
+
- Hash values were not being handeld properly by the DSL
|
7
|
+
|
1
8
|
== 1.0.0 / 2009-04-04
|
2
9
|
|
3
10
|
* 1 major enhancement
|
4
|
-
|
11
|
+
- Birthday!
|
data/Rakefile
CHANGED
data/lib/loquacious.rb
CHANGED
@@ -131,6 +131,28 @@ module Loquacious
|
|
131
131
|
self
|
132
132
|
end
|
133
133
|
|
134
|
+
# Provides hash accessor notation for configuration values.
|
135
|
+
#
|
136
|
+
# config = Configuration.for('app') {
|
137
|
+
# port 1234
|
138
|
+
# }
|
139
|
+
# config[:port] #=> 1234
|
140
|
+
# config.port #=> 1234
|
141
|
+
#
|
142
|
+
def []( key )
|
143
|
+
self.__send__(key)
|
144
|
+
end
|
145
|
+
|
146
|
+
# Provides hash accessor notation for configuration values.
|
147
|
+
#
|
148
|
+
# config = Configuration.for('app')
|
149
|
+
# config[:port] = 8808
|
150
|
+
# config.port #=> 8808
|
151
|
+
#
|
152
|
+
def []=( key, value )
|
153
|
+
self.__send__(key, value)
|
154
|
+
end
|
155
|
+
|
134
156
|
# Implementation of a doman specific language for creating configuration
|
135
157
|
# objects. Blocks of code are evaluted by the DSL which returns a new
|
136
158
|
# configuration object.
|
@@ -170,8 +192,10 @@ module Loquacious
|
|
170
192
|
def method_missing( method, *args, &block )
|
171
193
|
m = method.to_s.delete('=').to_sym
|
172
194
|
|
173
|
-
|
174
|
-
|
195
|
+
if args.length > 1
|
196
|
+
opts = args.last.instance_of?(Hash) ? args.pop : {}
|
197
|
+
self.desc(opts[:desc]) if opts.has_key? :desc
|
198
|
+
end
|
175
199
|
|
176
200
|
__config.__send__(m, *args, &block)
|
177
201
|
__config.__desc[m] = @description
|
data/loquacious.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{loquacious}
|
5
|
-
s.version = "1.
|
5
|
+
s.version = "1.1.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Tim Pease"]
|
9
|
-
s.date = %q{2009-04-
|
9
|
+
s.date = %q{2009-04-05}
|
10
10
|
s.description = %q{Descriptive configuration files for Ruby written in Ruby. Loquacious provides a very open configuration system written in ruby and descriptions for each configuration attribute. The attributes and descriptions can be iterated over allowing for helpful information about those attributes to be displayed to the user. In the simple case we have a file something like Loquacious.configuration_for('app') { name 'value', :desc => "Defines the name" foo 'bar', :desc => "FooBar" id 42, :desc => "Ara T. Howard" } Which can be loaded via the standard Ruby loading mechanisms Kernel.load 'config/app.rb' The attributes and their descriptions can be printed by using a Help object help = Loquacious.help_for('app') help.show :values => true # show the values for the attributes, too Descriptions are optional, and configurations can be nested arbitrarily deep. Loquacious.configuration_for('nested') { desc "The outermost level" a { desc "One more level in" b { desc "Finally, a real value" c 'value' } } } config = Loquacious.configuration_for('nested') p config.a.b.c #=> "value" And as you can see, descriptions can either be given inline after the value or they can appear above the attribute and value on their own line.}
|
11
11
|
s.email = %q{tim.pease@gmail.com}
|
12
12
|
s.extra_rdoc_files = ["History.txt", "README.rdoc"]
|
@@ -24,14 +24,14 @@ Gem::Specification.new do |s|
|
|
24
24
|
s.specification_version = 2
|
25
25
|
|
26
26
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
27
|
-
s.add_runtime_dependency(%q<rspec>, [">= 1.
|
28
|
-
s.add_development_dependency(%q<bones>, [">= 2.
|
27
|
+
s.add_runtime_dependency(%q<rspec>, [">= 1.2.2"])
|
28
|
+
s.add_development_dependency(%q<bones>, [">= 2.5.0"])
|
29
29
|
else
|
30
|
-
s.add_dependency(%q<rspec>, [">= 1.
|
31
|
-
s.add_dependency(%q<bones>, [">= 2.
|
30
|
+
s.add_dependency(%q<rspec>, [">= 1.2.2"])
|
31
|
+
s.add_dependency(%q<bones>, [">= 2.5.0"])
|
32
32
|
end
|
33
33
|
else
|
34
|
-
s.add_dependency(%q<rspec>, [">= 1.
|
35
|
-
s.add_dependency(%q<bones>, [">= 2.
|
34
|
+
s.add_dependency(%q<rspec>, [">= 1.2.2"])
|
35
|
+
s.add_dependency(%q<bones>, [">= 2.5.0"])
|
36
36
|
end
|
37
37
|
end
|
data/spec/configuration_spec.rb
CHANGED
@@ -44,6 +44,33 @@ describe Loquacious::Configuration do
|
|
44
44
|
@obj.__desc.should equal(h)
|
45
45
|
end
|
46
46
|
|
47
|
+
it 'should allow attributes to be assigned hash values' do
|
48
|
+
cfg = Loquacious::Configuration.new {
|
49
|
+
hash({:one => 1})
|
50
|
+
}
|
51
|
+
cfg.hash.should == {:one => 1}
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should provide hash accessor notation for attributes' do
|
55
|
+
cfg = Loquacious::Configuration.new {
|
56
|
+
one 1
|
57
|
+
two 2
|
58
|
+
three 3
|
59
|
+
}
|
60
|
+
|
61
|
+
cfg['one'].should == 1
|
62
|
+
cfg[:two].should == 2
|
63
|
+
cfg['three'].should == 3
|
64
|
+
|
65
|
+
cfg[:four].should be_nil
|
66
|
+
cfg.four = 4
|
67
|
+
cfg[:four].should == 4
|
68
|
+
|
69
|
+
cfg[:five] = 5
|
70
|
+
cfg.five.should == 5
|
71
|
+
cfg[:five].should == 5
|
72
|
+
end
|
73
|
+
|
47
74
|
# -----------------------------------------------------------------------
|
48
75
|
describe 'when merging' do
|
49
76
|
|
data/tasks/setup.rb
CHANGED
@@ -147,7 +147,7 @@ RCOV = "#{RUBY} -S rcov"
|
|
147
147
|
RDOC = "#{RUBY} -S rdoc"
|
148
148
|
GEM = "#{RUBY} -S gem"
|
149
149
|
|
150
|
-
%w(rcov spec/rake/spectask rubyforge bones facets/ansicode).each do |lib|
|
150
|
+
%w(rcov spec/rake/spectask rubyforge bones facets/ansicode zentest).each do |lib|
|
151
151
|
begin
|
152
152
|
require lib
|
153
153
|
Object.instance_eval {const_set "HAVE_#{lib.tr('/','_').upcase}", true}
|
data/tasks/zentest.rake
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
if HAVE_ZENTEST
|
2
|
+
|
3
|
+
# --------------------------------------------------------------------------
|
4
|
+
if test(?e, PROJ.test.file) or not PROJ.test.files.to_a.empty?
|
5
|
+
require 'autotest'
|
6
|
+
|
7
|
+
namespace :test do
|
8
|
+
task :autotest do
|
9
|
+
Autotest.run
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
desc "Run the autotest loop"
|
14
|
+
task :autotest => 'test:autotest'
|
15
|
+
|
16
|
+
end # if test
|
17
|
+
|
18
|
+
# --------------------------------------------------------------------------
|
19
|
+
if HAVE_SPEC_RAKE_SPECTASK and not PROJ.spec.files.to_a.empty?
|
20
|
+
require 'autotest/rspec'
|
21
|
+
|
22
|
+
namespace :spec do
|
23
|
+
task :autotest do
|
24
|
+
load '.autotest' if test(?f, '.autotest')
|
25
|
+
Autotest::Rspec.run
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "Run the autotest loop"
|
30
|
+
task :autotest => 'spec:autotest'
|
31
|
+
|
32
|
+
end # if rspec
|
33
|
+
|
34
|
+
end # if HAVE_ZENTEST
|
35
|
+
|
36
|
+
# EOF
|
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
|
+
version: 1.1.0
|
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-04-
|
12
|
+
date: 2009-04-05 00:00:00 -06: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.
|
23
|
+
version: 1.2.2
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bones
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.
|
33
|
+
version: 2.5.0
|
34
34
|
version:
|
35
35
|
description: "Descriptive configuration files for Ruby written in Ruby. Loquacious provides a very open configuration system written in ruby and descriptions for each configuration attribute. The attributes and descriptions can be iterated over allowing for helpful information about those attributes to be displayed to the user. In the simple case we have a file something like Loquacious.configuration_for('app') { name 'value', :desc => \"Defines the name\" foo 'bar', :desc => \"FooBar\" id 42, :desc => \"Ara T. Howard\" } Which can be loaded via the standard Ruby loading mechanisms Kernel.load 'config/app.rb' The attributes and their descriptions can be printed by using a Help object help = Loquacious.help_for('app') help.show :values => true # show the values for the attributes, too Descriptions are optional, and configurations can be nested arbitrarily deep. Loquacious.configuration_for('nested') { desc \"The outermost level\" a { desc \"One more level in\" b { desc \"Finally, a real value\" c 'value' } } } config = Loquacious.configuration_for('nested') p config.a.b.c #=> \"value\" And as you can see, descriptions can either be given inline after the value or they can appear above the attribute and value on their own line."
|
36
36
|
email: tim.pease@gmail.com
|
@@ -73,6 +73,7 @@ files:
|
|
73
73
|
- tasks/spec.rake
|
74
74
|
- tasks/svn.rake
|
75
75
|
- tasks/test.rake
|
76
|
+
- tasks/zentest.rake
|
76
77
|
has_rdoc: true
|
77
78
|
homepage: http://codeforpeople.rubyforge.org/loquacious
|
78
79
|
post_install_message:
|