loquacious 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +7 -0
- data/lib/loquacious.rb +22 -1
- data/lib/loquacious/configuration.rb +3 -3
- metadata +52 -7
data/History.txt
CHANGED
data/lib/loquacious.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
module Loquacious
|
3
3
|
|
4
4
|
# :stopdoc:
|
5
|
-
VERSION = '1.3.
|
5
|
+
VERSION = '1.3.1'
|
6
6
|
LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
|
7
7
|
PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
|
8
8
|
# :startdoc:
|
@@ -67,6 +67,27 @@ module Loquacious
|
|
67
67
|
Dir.glob(search_me).sort.each {|rb| require rb}
|
68
68
|
end
|
69
69
|
|
70
|
+
# This is merely a convenience method to remove methods from the
|
71
|
+
# Loquacious::Configuration class. Some ruby gems add lots of crap to the
|
72
|
+
# Kernel module, and this interferes with the configuration system. The
|
73
|
+
# remove method should be used to anihilate unwanted methods from the
|
74
|
+
# configuration class as needed.
|
75
|
+
#
|
76
|
+
# Loquacious.remove :gem # courtesy of rubygems
|
77
|
+
# Loquacious.remove :test, :file # courtesy of rake
|
78
|
+
#
|
79
|
+
def remove( *args )
|
80
|
+
args.each { |name|
|
81
|
+
name = name.to_s.delete('=')
|
82
|
+
code = <<-__
|
83
|
+
undef_method :#{name} rescue nil
|
84
|
+
undef_method :#{name}= rescue nil
|
85
|
+
__
|
86
|
+
Loquacious::Configuration.module_eval code
|
87
|
+
Loquacious::Configuration::DSL.module_eval code
|
88
|
+
}
|
89
|
+
end
|
90
|
+
|
70
91
|
end # class << self
|
71
92
|
end # module Loquacious
|
72
93
|
|
@@ -80,8 +80,8 @@ module Loquacious
|
|
80
80
|
v = (1 == args.length ? args.first : args)
|
81
81
|
v = nil if args.empty?
|
82
82
|
v = DSL.evaluate(&block) if block
|
83
|
-
|
84
|
-
return @#{m} unless v
|
83
|
+
|
84
|
+
return @#{m} unless v or v == false
|
85
85
|
|
86
86
|
if @#{m}.kind_of?(Configuration)
|
87
87
|
@#{m}.merge! v
|
@@ -162,7 +162,7 @@ module Loquacious
|
|
162
162
|
|
163
163
|
instance_methods.each do |m|
|
164
164
|
undef_method m unless m[%r/^__/] or m.to_s == 'object_id'
|
165
|
-
end
|
165
|
+
end
|
166
166
|
|
167
167
|
# Create a new DSL and evaluate the given _block_ in the context of
|
168
168
|
# the DSL. Returns a newly created configuration object.
|
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.3.
|
4
|
+
version: 1.3.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-
|
12
|
+
date: 2009-10-30 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.2.
|
23
|
+
version: 1.2.8
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: bones
|
@@ -30,9 +30,52 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.5.
|
33
|
+
version: 2.5.1
|
34
34
|
version:
|
35
|
-
description:
|
35
|
+
description: |-
|
36
|
+
Descriptive configuration files for Ruby written in Ruby.
|
37
|
+
|
38
|
+
Loquacious provides a very open configuration system written in ruby and
|
39
|
+
descriptions for each configuration attribute. The attributes and descriptions
|
40
|
+
can be iterated over allowing for helpful information about those attributes to
|
41
|
+
be displayed to the user.
|
42
|
+
|
43
|
+
In the simple case we have a file something like
|
44
|
+
|
45
|
+
Loquacious.configuration_for('app') {
|
46
|
+
name 'value', :desc => "Defines the name"
|
47
|
+
foo 'bar', :desc => "FooBar"
|
48
|
+
id 42, :desc => "Ara T. Howard"
|
49
|
+
}
|
50
|
+
|
51
|
+
Which can be loaded via the standard Ruby loading mechanisms
|
52
|
+
|
53
|
+
Kernel.load 'config/app.rb'
|
54
|
+
|
55
|
+
The attributes and their descriptions can be printed by using a Help object
|
56
|
+
|
57
|
+
help = Loquacious.help_for('app')
|
58
|
+
help.show :values => true # show the values for the attributes, too
|
59
|
+
|
60
|
+
Descriptions are optional, and configurations can be nested arbitrarily deep.
|
61
|
+
|
62
|
+
Loquacious.configuration_for('nested') {
|
63
|
+
desc "The outermost level"
|
64
|
+
a {
|
65
|
+
desc "One more level in"
|
66
|
+
b {
|
67
|
+
desc "Finally, a real value"
|
68
|
+
c 'value'
|
69
|
+
}
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
config = Loquacious.configuration_for('nested')
|
74
|
+
|
75
|
+
p config.a.b.c #=> "value"
|
76
|
+
|
77
|
+
And as you can see, descriptions can either be given inline after the value or
|
78
|
+
they can appear above the attribute and value on their own line.
|
36
79
|
email: tim.pease@gmail.com
|
37
80
|
executables: []
|
38
81
|
|
@@ -76,6 +119,8 @@ files:
|
|
76
119
|
- tasks/zentest.rake
|
77
120
|
has_rdoc: true
|
78
121
|
homepage: http://codeforpeople.rubyforge.org/loquacious
|
122
|
+
licenses: []
|
123
|
+
|
79
124
|
post_install_message:
|
80
125
|
rdoc_options:
|
81
126
|
- --main
|
@@ -97,9 +142,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
97
142
|
requirements: []
|
98
143
|
|
99
144
|
rubyforge_project: codeforpeople
|
100
|
-
rubygems_version: 1.3.
|
145
|
+
rubygems_version: 1.3.5
|
101
146
|
signing_key:
|
102
|
-
specification_version:
|
147
|
+
specification_version: 3
|
103
148
|
summary: Descriptive configuration files for Ruby written in Ruby
|
104
149
|
test_files: []
|
105
150
|
|