adhearsion-loquacious 1.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +23 -0
- data/Guardfile +5 -0
- data/History.txt +127 -0
- data/README.rdoc +229 -0
- data/Rakefile +30 -0
- data/adhearsion-loquacious.gemspec +32 -0
- data/examples/gutters.rb +29 -0
- data/examples/nested.rb +43 -0
- data/examples/simple.rb +20 -0
- data/lib/loquacious.rb +165 -0
- data/lib/loquacious/configuration.rb +406 -0
- data/lib/loquacious/configuration/help.rb +249 -0
- data/lib/loquacious/configuration/iterator.rb +158 -0
- data/lib/loquacious/core_ext/string.rb +75 -0
- data/lib/loquacious/undefined.rb +92 -0
- data/lib/loquacious/utility.rb +14 -0
- data/loquacious.gemspec +32 -0
- data/spec/configuration_spec.rb +513 -0
- data/spec/help_spec.rb +369 -0
- data/spec/iterator_spec.rb +70 -0
- data/spec/loquacious_spec.rb +76 -0
- data/spec/spec_helper.rb +70 -0
- data/spec/string_spec.rb +53 -0
- data/spec/utility_spec.rb +28 -0
- data/version.txt +1 -0
- metadata +102 -0
data/.gitignore
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# Gem related stuff
|
2
|
+
*.gem
|
3
|
+
pkg
|
4
|
+
.bundle
|
5
|
+
Gemfile.lock
|
6
|
+
vendor
|
7
|
+
|
8
|
+
# Testing stuff
|
9
|
+
coverage
|
10
|
+
spec/reports
|
11
|
+
example.log
|
12
|
+
|
13
|
+
# RBX stuff
|
14
|
+
*~
|
15
|
+
.*.sw?
|
16
|
+
nbproject
|
17
|
+
/.rbx/
|
18
|
+
|
19
|
+
# General
|
20
|
+
.DS_Store
|
21
|
+
.rvmrc
|
22
|
+
.yardoc
|
23
|
+
doc
|
data/Guardfile
ADDED
data/History.txt
ADDED
@@ -0,0 +1,127 @@
|
|
1
|
+
== 1.9.1 / 2011-12-15
|
2
|
+
|
3
|
+
Bug Fixes
|
4
|
+
- Properly generate accessor method when merging
|
5
|
+
|
6
|
+
== 1.9.0 / 2011-09-13
|
7
|
+
|
8
|
+
Enhancements
|
9
|
+
- Iterator now skips Undefined values
|
10
|
+
- Method to convert Configuration objects to a hash [mcmire]
|
11
|
+
|
12
|
+
== 1.8.1 / 2011-06-09
|
13
|
+
|
14
|
+
Bug Fixes
|
15
|
+
- Assignment methods now mirror one another in their return values
|
16
|
+
|
17
|
+
== 1.8.0 / 2011-06-03
|
18
|
+
|
19
|
+
Enhancements
|
20
|
+
- Support for defalut values on configuration properties
|
21
|
+
|
22
|
+
== 1.7.1 / 2011-02-11
|
23
|
+
|
24
|
+
Bug Fixes
|
25
|
+
- Fixing the "alias instance_eval" warning on JRuby
|
26
|
+
|
27
|
+
== 1.7.0 / 2010-08-16
|
28
|
+
|
29
|
+
Enhancements
|
30
|
+
- Adding a "copy" function for configuration objects
|
31
|
+
Bug Fixes
|
32
|
+
- Fixing warnings
|
33
|
+
|
34
|
+
== 1.6.4 / 2010-06-08
|
35
|
+
|
36
|
+
Bug Fixes
|
37
|
+
- Extending a configuration was not working properly
|
38
|
+
- Descriptions were being overwritten when extending a configuration
|
39
|
+
|
40
|
+
== 1.6.3 / 2010-06-07
|
41
|
+
|
42
|
+
Bug Fixes
|
43
|
+
- Assign a nil description when none is given [Nathan Witmer]
|
44
|
+
|
45
|
+
== 1.6.2 / 2010-06-01
|
46
|
+
|
47
|
+
Bug Fixes
|
48
|
+
- Compatibility with Ruby 1.9.2
|
49
|
+
|
50
|
+
== 1.6.1 / 2010-04-19
|
51
|
+
|
52
|
+
Bug Fixes
|
53
|
+
- Allow interrogative methods on configuration objects (nil?)
|
54
|
+
|
55
|
+
== 1.6.0 / 2010-04-18
|
56
|
+
|
57
|
+
Enhancements
|
58
|
+
- Added a default "undefined" value
|
59
|
+
|
60
|
+
== 1.5.2 / 2010-04-06
|
61
|
+
|
62
|
+
Bug Fixes
|
63
|
+
- Accidentally undefining the initialize method for the DSL
|
64
|
+
|
65
|
+
== 1.5.1 / 2010-04-06
|
66
|
+
|
67
|
+
Bug Fixes
|
68
|
+
- Private methods were accessible in the configuration objects
|
69
|
+
|
70
|
+
== 1.5.0 / 2010-03-11
|
71
|
+
|
72
|
+
Enhancements
|
73
|
+
- Adding support for evaluation of Proc objects
|
74
|
+
- Upgrading to the latest Mr Bones
|
75
|
+
|
76
|
+
|
77
|
+
== 1.4.2 / 2010-02-01
|
78
|
+
|
79
|
+
Bug Fixes
|
80
|
+
- Resolving some circular dependencies
|
81
|
+
|
82
|
+
== 1.4.1 / 2009-11-29
|
83
|
+
|
84
|
+
Bug Fixes
|
85
|
+
- Fixing warning message from jRuby
|
86
|
+
- Kernel methods can now be used as configuration attributes
|
87
|
+
|
88
|
+
== 1.4.0 / 2009-11-07
|
89
|
+
|
90
|
+
Enhancements
|
91
|
+
- Added a help option to hide nesting configuration atrributes
|
92
|
+
- Update to Mr Bones 3.0.0
|
93
|
+
|
94
|
+
== 1.3.1 / 2009-10-30
|
95
|
+
|
96
|
+
Enhancements
|
97
|
+
- Added a remove method to clobber unwanted methods in the configuration
|
98
|
+
Bug Fixes
|
99
|
+
- Could not assign false as a default value
|
100
|
+
|
101
|
+
== 1.3.0 / 2009-04-05
|
102
|
+
|
103
|
+
Enhancements
|
104
|
+
- Adding colorization options to the Help object
|
105
|
+
|
106
|
+
== 1.2.0 / 2009-04-05
|
107
|
+
|
108
|
+
Enhancements
|
109
|
+
- Help#show now matches using a regular expression
|
110
|
+
|
111
|
+
== 1.1.1 / 2009-04-05
|
112
|
+
|
113
|
+
Bug Fixes
|
114
|
+
- You can no longer use object_id as a configuration value
|
115
|
+
(Ruby 1.9 is very cranky if object_id gets undefined)
|
116
|
+
|
117
|
+
== 1.1.0 / 2009-04-05
|
118
|
+
|
119
|
+
Enhancements
|
120
|
+
- Added hash accessor methods for configuration attributes
|
121
|
+
Bug Fixes
|
122
|
+
- Hash values were not being handeld properly by the DSL
|
123
|
+
|
124
|
+
== 1.0.0 / 2009-04-04
|
125
|
+
|
126
|
+
Enhancements
|
127
|
+
- Birthday!
|
data/README.rdoc
ADDED
@@ -0,0 +1,229 @@
|
|
1
|
+
= Loquacious
|
2
|
+
by Tim Pease
|
3
|
+
http://rubygems.org/gems/loquacious
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Descriptive configuration files for Ruby written in Ruby.
|
8
|
+
|
9
|
+
Loquacious provides a very open configuration system written in ruby and
|
10
|
+
descriptions for each configuration attribute. The attributes and descriptions
|
11
|
+
can be iterated over allowing for helpful information about those attributes to
|
12
|
+
be displayed to the user.
|
13
|
+
|
14
|
+
In the simple case we have a file something like
|
15
|
+
|
16
|
+
Loquacious.configuration_for('app') {
|
17
|
+
name 'value', :desc => "Defines the name"
|
18
|
+
foo 'bar', :desc => "FooBar"
|
19
|
+
id 42, :desc => "Ara T. Howard"
|
20
|
+
}
|
21
|
+
|
22
|
+
Which can be loaded via the standard Ruby loading mechanisms
|
23
|
+
|
24
|
+
Kernel.load 'config/app.rb'
|
25
|
+
|
26
|
+
The attributes and their descriptions can be printed by using a Help object
|
27
|
+
|
28
|
+
help = Loquacious.help_for('app')
|
29
|
+
help.show :values => true # show the values for the attributes, too
|
30
|
+
|
31
|
+
Descriptions are optional, and configurations can be nested arbitrarily deep.
|
32
|
+
|
33
|
+
Loquacious.configuration_for('nested') {
|
34
|
+
desc "The outermost level"
|
35
|
+
a {
|
36
|
+
desc "One more level in"
|
37
|
+
b {
|
38
|
+
desc "Finally, a real value"
|
39
|
+
c 'value'
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
config = Loquacious.configuration_for('nested')
|
45
|
+
|
46
|
+
p config.a.b.c #=> "value"
|
47
|
+
|
48
|
+
And as you can see, descriptions can either be given inline after the value or
|
49
|
+
they can appear above the attribute and value on their own line.
|
50
|
+
|
51
|
+
== INSTALL:
|
52
|
+
|
53
|
+
* sudo gem install loquacious
|
54
|
+
|
55
|
+
== EXAMPLES:
|
56
|
+
|
57
|
+
==== example/simple.rb
|
58
|
+
# A simple example that configures three options (a b c) along with
|
59
|
+
# descriptions for each option. The descriptions along with the
|
60
|
+
# values for the configuration options are printed to the terminal.
|
61
|
+
|
62
|
+
require 'loquacious'
|
63
|
+
include Loquacious
|
64
|
+
|
65
|
+
Configuration.for(:simple) {
|
66
|
+
desc 'Your first configuration option'
|
67
|
+
a "value for 'a'"
|
68
|
+
|
69
|
+
desc 'To be or not to be'
|
70
|
+
b "William Shakespeare"
|
71
|
+
|
72
|
+
desc 'The underpinings of Ruby'
|
73
|
+
c 42
|
74
|
+
}
|
75
|
+
|
76
|
+
help = Configuration.help_for :simple
|
77
|
+
help.show :values => true
|
78
|
+
|
79
|
+
====== output ======
|
80
|
+
Your first configuration option
|
81
|
+
- a => "value for 'a'"
|
82
|
+
|
83
|
+
To be or not to be
|
84
|
+
- b => "William Shakespeare"
|
85
|
+
|
86
|
+
The underpinings of Ruby
|
87
|
+
- c => 42
|
88
|
+
|
89
|
+
==== examples/nested.rb
|
90
|
+
# Here we show how to used nested configuration options by taking a subset
|
91
|
+
# of some common Rails configuration options. Also, descriptions can be give
|
92
|
+
# before the option or they can be given inline using Ruby hash notation. If
|
93
|
+
# both are present, then the inline description takes precedence.
|
94
|
+
#
|
95
|
+
# Multiline descriptions are provided using Ruby heredocs. Leading
|
96
|
+
# whitespace is stripped and line breaks are preserved when descriptions
|
97
|
+
# are printed using the help object.
|
98
|
+
|
99
|
+
require 'loquacious'
|
100
|
+
include Loquacious
|
101
|
+
|
102
|
+
Configuration.for(:nested) {
|
103
|
+
root_path '.', :desc => "The application's base directory."
|
104
|
+
|
105
|
+
desc "Configuration options for ActiveRecord::Base."
|
106
|
+
active_record {
|
107
|
+
colorize_logging true, :desc => <<-__
|
108
|
+
Determines whether to use ANSI codes to colorize the logging statements committed
|
109
|
+
by the connection adapter. These colors make it much easier to overview things
|
110
|
+
during debugging (when used through a reader like +tail+ and on a black background),
|
111
|
+
but may complicate matters if you use software like syslog. This is true, by default.
|
112
|
+
__
|
113
|
+
|
114
|
+
default_timezone :local, :desc => <<-__
|
115
|
+
Determines whether to use Time.local (using :local) or Time.utc (using :utc)
|
116
|
+
when pulling dates and times from the database. This is set to :local by default.
|
117
|
+
__
|
118
|
+
}
|
119
|
+
|
120
|
+
log_level :info, :desc => <<-__
|
121
|
+
The log level to use for the default Rails logger. In production mode,
|
122
|
+
this defaults to :info. In development mode, it defaults to :debug.
|
123
|
+
__
|
124
|
+
|
125
|
+
log_path 'log/development.log', :desc => <<-__
|
126
|
+
The path to the log file to use. Defaults to log/\#{environment}.log
|
127
|
+
(e.g. log/development.log or log/production.log).
|
128
|
+
__
|
129
|
+
}
|
130
|
+
|
131
|
+
help = Configuration.help_for :nested
|
132
|
+
help.show :values => true
|
133
|
+
|
134
|
+
====== output ======
|
135
|
+
Configuration options for ActiveRecord::Base.
|
136
|
+
- active_record
|
137
|
+
|
138
|
+
Determines whether to use ANSI codes to colorize the logging statements committed
|
139
|
+
by the connection adapter. These colors make it much easier to overview things
|
140
|
+
during debugging (when used through a reader like +tail+ and on a black background),
|
141
|
+
but may complicate matters if you use software like syslog. This is true, by default.
|
142
|
+
- active_record.colorize_logging => true
|
143
|
+
|
144
|
+
Determines whether to use Time.local (using :local) or Time.utc (using :utc)
|
145
|
+
when pulling dates and times from the database. This is set to :local by default.
|
146
|
+
- active_record.default_timezone => :local
|
147
|
+
|
148
|
+
The log level to use for the default Rails logger. In production mode,
|
149
|
+
this defaults to :info. In development mode, it defaults to :debug.
|
150
|
+
- log_level => :info
|
151
|
+
|
152
|
+
The path to the log file to use. Defaults to log/#{environment}.log
|
153
|
+
(e.g. log/development.log or log/production.log).
|
154
|
+
- log_path => "log/development.log"
|
155
|
+
|
156
|
+
The application's base directory.
|
157
|
+
- root_path => "."
|
158
|
+
|
159
|
+
==== examples/gutters.rb
|
160
|
+
# Using Ruby heredocs for descriptions, the Loquacious configuration will
|
161
|
+
# strip out leading whitespace but preserve line breaks. Gutter lines can be
|
162
|
+
# used to mark where leading whitespace should be preserved. This is useful
|
163
|
+
# is you need to provide example code in your descriptions.
|
164
|
+
|
165
|
+
require 'loquacious'
|
166
|
+
include Loquacious
|
167
|
+
|
168
|
+
Configuration.for(:gutters) {
|
169
|
+
log_path "log/development.log", :desc => <<-__
|
170
|
+
The path to the log file to use. Defaults to log/\#{environment}.log
|
171
|
+
(e.g. log/development.log or log/production.log).
|
172
|
+
|
|
173
|
+
| config.log_path = File.join(ROOT, "log", "\#{environment}.log
|
174
|
+
|
|
175
|
+
__
|
176
|
+
|
177
|
+
log_level :warn, :desc => <<-__
|
178
|
+
|The log level to use for the default Rails logger. In production mode,
|
179
|
+
|this defaults to :info. In development mode, it defaults to :debug.
|
180
|
+
|
|
181
|
+
| config.log_level = 'debug'
|
182
|
+
| config.log_level = :warn
|
183
|
+
|
|
184
|
+
__
|
185
|
+
}
|
186
|
+
|
187
|
+
help = Configuration.help_for :gutters
|
188
|
+
help.show :values => true
|
189
|
+
|
190
|
+
====== output ======
|
191
|
+
The log level to use for the default Rails logger. In production mode,
|
192
|
+
this defaults to :info. In development mode, it defaults to :debug.
|
193
|
+
|
194
|
+
config.log_level = 'debug'
|
195
|
+
config.log_level = :warn
|
196
|
+
|
197
|
+
- log_level => :warn
|
198
|
+
|
199
|
+
The path to the log file to use. Defaults to log/#{environment}.log
|
200
|
+
(e.g. log/development.log or log/production.log).
|
201
|
+
|
202
|
+
config.log_path = File.join(ROOT, "log", "#{environment}.log
|
203
|
+
|
204
|
+
- log_path => "log/development.log"
|
205
|
+
|
206
|
+
== LICENSE:
|
207
|
+
|
208
|
+
(The MIT License)
|
209
|
+
|
210
|
+
Copyright (c) 2009-2011
|
211
|
+
|
212
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
213
|
+
a copy of this software and associated documentation files (the
|
214
|
+
'Software'), to deal in the Software without restriction, including
|
215
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
216
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
217
|
+
permit persons to whom the Software is furnished to do so, subject to
|
218
|
+
the following conditions:
|
219
|
+
|
220
|
+
The above copyright notice and this permission notice shall be
|
221
|
+
included in all copies or substantial portions of the Software.
|
222
|
+
|
223
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
224
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
225
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
226
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
227
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
228
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
229
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
begin
|
3
|
+
require 'bones'
|
4
|
+
rescue LoadError
|
5
|
+
abort '### please install the "bones" gem ###'
|
6
|
+
end
|
7
|
+
|
8
|
+
task :default => 'spec:run'
|
9
|
+
task 'gem:release' => 'spec:run'
|
10
|
+
|
11
|
+
Bones {
|
12
|
+
name 'adhearsion-loquacious'
|
13
|
+
authors 'Tim Pease', 'Adhearsion Team'
|
14
|
+
email 'tim.pease@gmail.com', 'all@adhearsion.com'
|
15
|
+
url 'http://rubygems.org/gems/adhearsion-loquacious'
|
16
|
+
readme_file 'README.rdoc'
|
17
|
+
spec.opts << '--color'
|
18
|
+
use_gmail
|
19
|
+
|
20
|
+
depend_on 'rspec', '~> 2.6', :development => true
|
21
|
+
}
|
22
|
+
|
23
|
+
task 'ann:prereqs' do
|
24
|
+
Bones.config.name = 'Adhearsion-Loquacious'
|
25
|
+
end
|
26
|
+
|
27
|
+
# depending on bones (even as a development dependency) creates a circular
|
28
|
+
# reference that prevents the auto install of loquacious when instsalling
|
29
|
+
# bones
|
30
|
+
::Bones.config.gem._spec.dependencies.delete_if {|d| d.name == 'bones'}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "adhearsion-loquacious"
|
5
|
+
s.version = "1.9.2"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Tim Pease", "Adhearsion Team"]
|
9
|
+
s.date = "2012-01-18"
|
10
|
+
s.description = "Descriptive configuration files for Ruby written in Ruby.\n\nLoquacious provides a very open configuration system written in ruby and\ndescriptions for each configuration attribute. The attributes and descriptions\ncan be iterated over allowing for helpful information about those attributes to\nbe displayed to the user.\n\nIn the simple case we have a file something like\n\n Loquacious.configuration_for('app') {\n name 'value', :desc => \"Defines the name\"\n foo 'bar', :desc => \"FooBar\"\n id 42, :desc => \"Ara T. Howard\"\n }\n\nWhich can be loaded via the standard Ruby loading mechanisms\n\n Kernel.load 'config/app.rb'\n\nThe attributes and their descriptions can be printed by using a Help object\n\n help = Loquacious.help_for('app')\n help.show :values => true # show the values for the attributes, too\n\nDescriptions are optional, and configurations can be nested arbitrarily deep.\n\n Loquacious.configuration_for('nested') {\n desc \"The outermost level\"\n a {\n desc \"One more level in\"\n b {\n desc \"Finally, a real value\"\n c 'value'\n }\n }\n }\n\n config = Loquacious.configuration_for('nested')\n\n p config.a.b.c #=> \"value\"\n\nAnd as you can see, descriptions can either be given inline after the value or\nthey can appear above the attribute and value on their own line."
|
11
|
+
s.email = ["tim.pease@gmail.com", "all@adhearsion.com"]
|
12
|
+
s.extra_rdoc_files = ["History.txt", "README.rdoc"]
|
13
|
+
s.files = [".gitignore", "Guardfile", "History.txt", "README.rdoc", "Rakefile", "examples/gutters.rb", "examples/nested.rb", "examples/simple.rb", "lib/loquacious.rb", "lib/loquacious/configuration.rb", "lib/loquacious/configuration/help.rb", "lib/loquacious/configuration/iterator.rb", "lib/loquacious/core_ext/string.rb", "lib/loquacious/undefined.rb", "lib/loquacious/utility.rb", "loquacious.gemspec", "spec/configuration_spec.rb", "spec/help_spec.rb", "spec/iterator_spec.rb", "spec/loquacious_spec.rb", "spec/spec_helper.rb", "spec/string_spec.rb", "spec/utility_spec.rb", "version.txt"]
|
14
|
+
s.homepage = "http://rubygems.org/gems/adhearsion-loquacious"
|
15
|
+
s.rdoc_options = ["--main", "README.rdoc"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubyforge_project = "adhearsion-loquacious"
|
18
|
+
s.rubygems_version = "1.8.10"
|
19
|
+
s.summary = "Descriptive configuration files for Ruby written in Ruby."
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
s.specification_version = 3
|
23
|
+
|
24
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
25
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.6"])
|
26
|
+
else
|
27
|
+
s.add_dependency(%q<rspec>, ["~> 2.6"])
|
28
|
+
end
|
29
|
+
else
|
30
|
+
s.add_dependency(%q<rspec>, ["~> 2.6"])
|
31
|
+
end
|
32
|
+
end
|