configuration-blocks 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/.rspec +1 -0
- data/.yardopts +12 -0
- data/ChangeLog +35 -0
- data/LGPL-LICENSE +169 -0
- data/Manifest.txt +18 -0
- data/README.md +193 -0
- data/Rakefile +85 -0
- data/configuration-blocks.gemspec +58 -0
- data/docs/COPYING +57 -0
- data/docs/HISTORY +6 -0
- data/docs/LEGAL +11 -0
- data/docs/LGPL-LICENSE +166 -0
- data/docs/TODO +0 -0
- data/docs/rdoc.css +21 -0
- data/docs/yard-tpl/default/fulldoc/html/css/common.css +5 -0
- data/lib/configuration-blocks.rb +6 -0
- data/lib/configuration-blocks/core.rb +145 -0
- data/lib/configuration-blocks/version.rb +24 -0
- metadata +241 -0
- metadata.gz.sig +0 -0
data.tar.gz.sig
ADDED
Binary file
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--format nested --color
|
data/.yardopts
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
--title 'Easy way of adding configuration blocks to classes, modules and applications'
|
2
|
+
--protected
|
3
|
+
--readme README.md
|
4
|
+
--no-private
|
5
|
+
--hide-void-return
|
6
|
+
-p docs/yard-tpl
|
7
|
+
-t default
|
8
|
+
-
|
9
|
+
docs/HISTORY
|
10
|
+
ChangeLog
|
11
|
+
docs/COPYING
|
12
|
+
docs/LGPL-LICENSE
|
data/ChangeLog
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
commit 1b04f5f3e97639b455a473c5f9c2200cf9f18c26
|
2
|
+
Author: Paweł Wilk <siefca@gnu.org>
|
3
|
+
Date: Sun Dec 2 03:01:35 2012 +0100
|
4
|
+
|
5
|
+
Deps updated
|
6
|
+
|
7
|
+
commit 648ddc5fa83e50e72ffbd4ed287d0387ebe9b789
|
8
|
+
Author: Paweł Wilk <siefca@gnu.org>
|
9
|
+
Date: Sun Dec 2 03:00:06 2012 +0100
|
10
|
+
|
11
|
+
Release 1.0.0
|
12
|
+
|
13
|
+
commit 379849ff5570306b892db0b94923cc0d385658df
|
14
|
+
Author: Paweł Wilk <siefca@gnu.org>
|
15
|
+
Date: Sun Dec 2 02:48:40 2012 +0100
|
16
|
+
|
17
|
+
Anonymous modules caching fixed, added singleton support
|
18
|
+
|
19
|
+
commit 38c4f9ac29bb12696c22af23690484fff38c885f
|
20
|
+
Author: Paweł Wilk <siefca@gnu.org>
|
21
|
+
Date: Sun Dec 2 02:47:48 2012 +0100
|
22
|
+
|
23
|
+
README updated
|
24
|
+
|
25
|
+
commit 2abc6a4c17b753dbe0cb515cc83cf6dd4b25b82f
|
26
|
+
Author: Paweł Wilk <siefca@gnu.org>
|
27
|
+
Date: Sat Dec 1 21:52:28 2012 +0100
|
28
|
+
|
29
|
+
ChangeLog and Manifest.txt updated
|
30
|
+
|
31
|
+
commit c10e977775a83b8cd1ef4e7a8b1a128b71661beb
|
32
|
+
Author: Paweł Wilk <siefca@gnu.org>
|
33
|
+
Date: Sat Dec 1 21:51:34 2012 +0100
|
34
|
+
|
35
|
+
Initial commit
|
data/LGPL-LICENSE
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
<tt>
|
2
|
+
|
3
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
4
|
+
Version 3, 29 June 2007
|
5
|
+
|
6
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
7
|
+
Everyone is permitted to copy and distribute verbatim copies
|
8
|
+
of this license document, but changing it is not allowed.
|
9
|
+
|
10
|
+
|
11
|
+
This version of the GNU Lesser General Public License incorporates
|
12
|
+
the terms and conditions of version 3 of the GNU General Public
|
13
|
+
License, supplemented by the additional permissions listed below.
|
14
|
+
|
15
|
+
0. Additional Definitions.
|
16
|
+
|
17
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
18
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
19
|
+
General Public License.
|
20
|
+
|
21
|
+
"The Library" refers to a covered work governed by this License,
|
22
|
+
other than an Application or a Combined Work as defined below.
|
23
|
+
|
24
|
+
An "Application" is any work that makes use of an interface provided
|
25
|
+
by the Library, but which is not otherwise based on the Library.
|
26
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
27
|
+
of using an interface provided by the Library.
|
28
|
+
|
29
|
+
A "Combined Work" is a work produced by combining or linking an
|
30
|
+
Application with the Library. The particular version of the Library
|
31
|
+
with which the Combined Work was made is also called the "Linked
|
32
|
+
Version".
|
33
|
+
|
34
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
35
|
+
Corresponding Source for the Combined Work, excluding any source code
|
36
|
+
for portions of the Combined Work that, considered in isolation, are
|
37
|
+
based on the Application, and not on the Linked Version.
|
38
|
+
|
39
|
+
The "Corresponding Application Code" for a Combined Work means the
|
40
|
+
object code and/or source code for the Application, including any data
|
41
|
+
and utility programs needed for reproducing the Combined Work from the
|
42
|
+
Application, but excluding the System Libraries of the Combined Work.
|
43
|
+
|
44
|
+
1. Exception to Section 3 of the GNU GPL.
|
45
|
+
|
46
|
+
You may convey a covered work under sections 3 and 4 of this License
|
47
|
+
without being bound by section 3 of the GNU GPL.
|
48
|
+
|
49
|
+
2. Conveying Modified Versions.
|
50
|
+
|
51
|
+
If you modify a copy of the Library, and, in your modifications, a
|
52
|
+
facility refers to a function or data to be supplied by an Application
|
53
|
+
that uses the facility (other than as an argument passed when the
|
54
|
+
facility is invoked), then you may convey a copy of the modified
|
55
|
+
version:
|
56
|
+
|
57
|
+
a) under this License, provided that you make a good faith effort to
|
58
|
+
ensure that, in the event an Application does not supply the
|
59
|
+
function or data, the facility still operates, and performs
|
60
|
+
whatever part of its purpose remains meaningful, or
|
61
|
+
|
62
|
+
b) under the GNU GPL, with none of the additional permissions of
|
63
|
+
this License applicable to that copy.
|
64
|
+
|
65
|
+
3. Object Code Incorporating Material from Library Header Files.
|
66
|
+
|
67
|
+
The object code form of an Application may incorporate material from
|
68
|
+
a header file that is part of the Library. You may convey such object
|
69
|
+
code under terms of your choice, provided that, if the incorporated
|
70
|
+
material is not limited to numerical parameters, data structure
|
71
|
+
layouts and accessors, or small macros, inline functions and templates
|
72
|
+
(ten or fewer lines in length), you do both of the following:
|
73
|
+
|
74
|
+
a) Give prominent notice with each copy of the object code that the
|
75
|
+
Library is used in it and that the Library and its use are
|
76
|
+
covered by this License.
|
77
|
+
|
78
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
79
|
+
document.
|
80
|
+
|
81
|
+
4. Combined Works.
|
82
|
+
|
83
|
+
You may convey a Combined Work under terms of your choice that,
|
84
|
+
taken together, effectively do not restrict modification of the
|
85
|
+
portions of the Library contained in the Combined Work and reverse
|
86
|
+
engineering for debugging such modifications, if you also do each of
|
87
|
+
the following:
|
88
|
+
|
89
|
+
a) Give prominent notice with each copy of the Combined Work that
|
90
|
+
the Library is used in it and that the Library and its use are
|
91
|
+
covered by this License.
|
92
|
+
|
93
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
94
|
+
document.
|
95
|
+
|
96
|
+
c) For a Combined Work that displays copyright notices during
|
97
|
+
execution, include the copyright notice for the Library among
|
98
|
+
these notices, as well as a reference directing the user to the
|
99
|
+
copies of the GNU GPL and this license document.
|
100
|
+
|
101
|
+
d) Do one of the following:
|
102
|
+
|
103
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
104
|
+
License, and the Corresponding Application Code in a form
|
105
|
+
suitable for, and under terms that permit, the user to
|
106
|
+
recombine or relink the Application with a modified version of
|
107
|
+
the Linked Version to produce a modified Combined Work, in the
|
108
|
+
manner specified by section 6 of the GNU GPL for conveying
|
109
|
+
Corresponding Source.
|
110
|
+
|
111
|
+
1) Use a suitable shared library mechanism for linking with the
|
112
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
113
|
+
a copy of the Library already present on the user's computer
|
114
|
+
system, and (b) will operate properly with a modified version
|
115
|
+
of the Library that is interface-compatible with the Linked
|
116
|
+
Version.
|
117
|
+
|
118
|
+
e) Provide Installation Information, but only if you would otherwise
|
119
|
+
be required to provide such information under section 6 of the
|
120
|
+
GNU GPL, and only to the extent that such information is
|
121
|
+
necessary to install and execute a modified version of the
|
122
|
+
Combined Work produced by recombining or relinking the
|
123
|
+
Application with a modified version of the Linked Version. (If
|
124
|
+
you use option 4d0, the Installation Information must accompany
|
125
|
+
the Minimal Corresponding Source and Corresponding Application
|
126
|
+
Code. If you use option 4d1, you must provide the Installation
|
127
|
+
Information in the manner specified by section 6 of the GNU GPL
|
128
|
+
for conveying Corresponding Source.)
|
129
|
+
|
130
|
+
5. Combined Libraries.
|
131
|
+
|
132
|
+
You may place library facilities that are a work based on the
|
133
|
+
Library side by side in a single library together with other library
|
134
|
+
facilities that are not Applications and are not covered by this
|
135
|
+
License, and convey such a combined library under terms of your
|
136
|
+
choice, if you do both of the following:
|
137
|
+
|
138
|
+
a) Accompany the combined library with a copy of the same work based
|
139
|
+
on the Library, uncombined with any other library facilities,
|
140
|
+
conveyed under the terms of this License.
|
141
|
+
|
142
|
+
b) Give prominent notice with the combined library that part of it
|
143
|
+
is a work based on the Library, and explaining where to find the
|
144
|
+
accompanying uncombined form of the same work.
|
145
|
+
|
146
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
147
|
+
|
148
|
+
The Free Software Foundation may publish revised and/or new versions
|
149
|
+
of the GNU Lesser General Public License from time to time. Such new
|
150
|
+
versions will be similar in spirit to the present version, but may
|
151
|
+
differ in detail to address new problems or concerns.
|
152
|
+
|
153
|
+
Each version is given a distinguishing version number. If the
|
154
|
+
Library as you received it specifies that a certain numbered version
|
155
|
+
of the GNU Lesser General Public License "or any later version"
|
156
|
+
applies to it, you have the option of following the terms and
|
157
|
+
conditions either of that published version or of any later version
|
158
|
+
published by the Free Software Foundation. If the Library as you
|
159
|
+
received it does not specify a version number of the GNU Lesser
|
160
|
+
General Public License, you may choose any version of the GNU Lesser
|
161
|
+
General Public License ever published by the Free Software Foundation.
|
162
|
+
|
163
|
+
If the Library as you received it specifies that a proxy can decide
|
164
|
+
whether future versions of the GNU Lesser General Public License shall
|
165
|
+
apply, that proxy's public statement of acceptance of any version is
|
166
|
+
permanent authorization for you to choose that version for the
|
167
|
+
Library.
|
168
|
+
|
169
|
+
</tt>
|
data/Manifest.txt
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
.rspec
|
2
|
+
.yardopts
|
3
|
+
ChangeLog
|
4
|
+
LGPL-LICENSE
|
5
|
+
Manifest.txt
|
6
|
+
README.md
|
7
|
+
Rakefile
|
8
|
+
configuration-blocks.gemspec
|
9
|
+
docs/COPYING
|
10
|
+
docs/HISTORY
|
11
|
+
docs/LEGAL
|
12
|
+
docs/LGPL-LICENSE
|
13
|
+
docs/TODO
|
14
|
+
docs/rdoc.css
|
15
|
+
docs/yard-tpl/default/fulldoc/html/css/common.css
|
16
|
+
lib/configuration-blocks.rb
|
17
|
+
lib/configuration-blocks/core.rb
|
18
|
+
lib/configuration-blocks/version.rb
|
data/README.md
ADDED
@@ -0,0 +1,193 @@
|
|
1
|
+
Configuration blocks for classes, modules and applications
|
2
|
+
==========================================================
|
3
|
+
|
4
|
+
**configuration-blocks version `1.0`** (`True`)
|
5
|
+
|
6
|
+
* https://rubygems.org/gems/configuration-blocks
|
7
|
+
* https://github.com/siefca/configuration-blocks/tree
|
8
|
+
* pw@gnu.org
|
9
|
+
|
10
|
+
|
11
|
+
Summary
|
12
|
+
-------
|
13
|
+
|
14
|
+
This is simple module that helps in creating configuration blocks in objects.
|
15
|
+
|
16
|
+
It separates configuration blocks from a class containing configuration methods
|
17
|
+
by creating anonymous modules containing delegators. Those delegators are used
|
18
|
+
to set or get some configuration data through delegates (methods that exist in your
|
19
|
+
class or module).
|
20
|
+
|
21
|
+
Example
|
22
|
+
-------
|
23
|
+
|
24
|
+
Instance-level:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
class SomeClass
|
28
|
+
include ConfigurationBlocks
|
29
|
+
|
30
|
+
def some_setting(arg)
|
31
|
+
p "setting to #{arg}"
|
32
|
+
end
|
33
|
+
configuration_method :some_setting
|
34
|
+
end
|
35
|
+
|
36
|
+
obj = SomeClass.new
|
37
|
+
|
38
|
+
obj.configuration_block do
|
39
|
+
some_setting :some_value
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
43
|
+
Class-level:
|
44
|
+
|
45
|
+
```ruby
|
46
|
+
class SomeClass
|
47
|
+
include ConfigurationBlocks
|
48
|
+
|
49
|
+
class <<self
|
50
|
+
def some_setting(arg)
|
51
|
+
p "setting to #{arg}"
|
52
|
+
end
|
53
|
+
configuration_method :some_setting
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
SomeClass.configuration_block do
|
58
|
+
some_setting :some_value
|
59
|
+
end
|
60
|
+
```
|
61
|
+
|
62
|
+
Imported from modules:
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
module MyModule
|
66
|
+
include ConfigurationBlocks
|
67
|
+
|
68
|
+
def some_setting(arg)
|
69
|
+
p "setting to #{arg}"
|
70
|
+
end
|
71
|
+
configuration_method :some_setting
|
72
|
+
end
|
73
|
+
|
74
|
+
module SecondModule
|
75
|
+
include ConfigurationBlocks
|
76
|
+
include MyModule
|
77
|
+
|
78
|
+
def other(v)
|
79
|
+
p "setting other to #{v}"
|
80
|
+
end
|
81
|
+
configuration_method :other
|
82
|
+
end
|
83
|
+
|
84
|
+
class SomeClass
|
85
|
+
include ConfigurationBlocks
|
86
|
+
include SecondModule
|
87
|
+
end
|
88
|
+
|
89
|
+
SomeClass.new.configuration_block do
|
90
|
+
some_setting :some_value
|
91
|
+
other :other
|
92
|
+
end
|
93
|
+
```
|
94
|
+
|
95
|
+
Please note that configuration blocks called **without arguments** are evaluated in the context of a module
|
96
|
+
and that module persists between calls. You can store and retrieve instance variables, create
|
97
|
+
module-level methods and so on:
|
98
|
+
|
99
|
+
```ruby
|
100
|
+
class SomeClass
|
101
|
+
include ConfigurationBlocks
|
102
|
+
end
|
103
|
+
|
104
|
+
obj = SomeClass.new
|
105
|
+
|
106
|
+
obj.configuration_block do
|
107
|
+
@some_var = 8
|
108
|
+
end
|
109
|
+
|
110
|
+
obj.configuration_block do
|
111
|
+
p @some_var
|
112
|
+
end
|
113
|
+
```
|
114
|
+
|
115
|
+
If you pass **at least one argument** to a configuration block, then the module will be passed as a first argument
|
116
|
+
of the block and the context will remain as it is (current). Imagine using +tap+.
|
117
|
+
|
118
|
+
See also
|
119
|
+
--------
|
120
|
+
|
121
|
+
* See [whole documentation](http://rubydoc.info/gems/configuration-blocks/) to browse all documents.
|
122
|
+
|
123
|
+
Requirements
|
124
|
+
------------
|
125
|
+
|
126
|
+
* [rubygems](http://docs.rubygems.org/)
|
127
|
+
* [bundler](http://gembundler.com/)
|
128
|
+
|
129
|
+
Download
|
130
|
+
--------
|
131
|
+
|
132
|
+
### Source code ###
|
133
|
+
|
134
|
+
* https://github.com/siefca/configuration-blocks/tree
|
135
|
+
* `git clone git://github.com/siefca/configuration-blocks.git`
|
136
|
+
|
137
|
+
### Gem ###
|
138
|
+
|
139
|
+
* https://rubygems.org/gems/configuration-blocks
|
140
|
+
|
141
|
+
Installation
|
142
|
+
------------
|
143
|
+
|
144
|
+
```ruby
|
145
|
+
gem install configuration-blocks
|
146
|
+
```
|
147
|
+
|
148
|
+
Specs
|
149
|
+
-----
|
150
|
+
|
151
|
+
You can run RSpec examples both with
|
152
|
+
|
153
|
+
* `bundle exec rake spec` or just `bundle exec rake`
|
154
|
+
* run a test file directly, e.g. `ruby -S rspec spec/configuration-blocks_spec.rb -Ispec:lib`
|
155
|
+
|
156
|
+
Common rake tasks
|
157
|
+
-----------------
|
158
|
+
|
159
|
+
* `bundle exec rake bundler:gemfile` – regenerate the `Gemfile`
|
160
|
+
* `bundle exec rake docs` – render the documentation (output in the subdirectory directory `doc`)
|
161
|
+
* `bundle exec rake gem:spec` – builds static gemspec file (`configuration-blocks.gemspec`)
|
162
|
+
* `bundle exec rake gem` – builds package (output in the subdirectory `pkg`)
|
163
|
+
* `bundle exec rake spec` – performs spec. tests
|
164
|
+
* `bundle exec rake Manifest.txt` – regenerates the `Manifest.txt` file
|
165
|
+
* `bundle exec rake ChangeLog` – regenerates the `ChangeLog` file
|
166
|
+
|
167
|
+
Like my work?
|
168
|
+
-------------
|
169
|
+
|
170
|
+
You can send me some bitcoins if you would like to support me:
|
171
|
+
|
172
|
+
* `13wZbBjs6yQQuAb3zjfHubQSyer2cLAYzH`
|
173
|
+
|
174
|
+
Or you can endorse my skills on LinkedIn or Coderwall:
|
175
|
+
|
176
|
+
* [pl.linkedin.com/in/pwilk](http://www.linkedin.com/profile/view?id=4251568#profile-skills)
|
177
|
+
|
178
|
+
* [![endorse](http://api.coderwall.com/siefca/endorsecount.png)](http://coderwall.com/siefca)
|
179
|
+
|
180
|
+
License
|
181
|
+
-------
|
182
|
+
|
183
|
+
Copyright (c) 2012 by Paweł Wilk.
|
184
|
+
|
185
|
+
configuration-blocks is copyrighted software owned by Paweł Wilk (pw@gnu.org).
|
186
|
+
You may redistribute and/or modify this software as long as you
|
187
|
+
comply with either the terms of the LGPL (see [LGPL-LICENSE](http://rubydoc.info/gems/configuration-blocks/file/docs/LGPL-LICENSE)),
|
188
|
+
or Ruby's license (see [COPYING](http://rubydoc.info/gems/configuration-blocks/file/docs/COPYING)).
|
189
|
+
|
190
|
+
THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS
|
191
|
+
OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION,
|
192
|
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
193
|
+
FOR A PARTICULAR PURPOSE.
|
data/Rakefile
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# -*- ruby -*-
|
3
|
+
|
4
|
+
$:.unshift File.join(File.dirname(__FILE__), "lib")
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require 'bundler/setup'
|
8
|
+
|
9
|
+
require "rake"
|
10
|
+
require "rake/clean"
|
11
|
+
|
12
|
+
require "fileutils"
|
13
|
+
|
14
|
+
require 'configuration-blocks/version'
|
15
|
+
require 'hoe'
|
16
|
+
|
17
|
+
task :default => [:spec]
|
18
|
+
|
19
|
+
desc "install by setup.rb"
|
20
|
+
task :install do
|
21
|
+
sh "sudo ruby setup.rb install"
|
22
|
+
end
|
23
|
+
|
24
|
+
### Gem
|
25
|
+
|
26
|
+
Hoe.plugin :bundler
|
27
|
+
Hoe.plugin :yard
|
28
|
+
Hoe.plugin :gemspec
|
29
|
+
|
30
|
+
Hoe.spec 'configuration-blocks' do
|
31
|
+
developer ConfigurationBlocks::DEVELOPER, ConfigurationBlocks::EMAIL
|
32
|
+
|
33
|
+
self.version = ConfigurationBlocks::VERSION
|
34
|
+
self.rubyforge_name = ConfigurationBlocks::NAME
|
35
|
+
self.summary = ConfigurationBlocks::SUMMARY
|
36
|
+
self.description = ConfigurationBlocks::DESCRIPTION
|
37
|
+
self.url = ConfigurationBlocks::URL
|
38
|
+
|
39
|
+
self.remote_rdoc_dir = ''
|
40
|
+
self.rsync_args << '--chmod=a+rX'
|
41
|
+
self.readme_file = 'README.md'
|
42
|
+
self.history_file = 'docs/HISTORY'
|
43
|
+
|
44
|
+
extra_dev_deps << ['rspec', '>= 2.6.0'] <<
|
45
|
+
['yard', '>= 0.8.2'] <<
|
46
|
+
['rdoc', '>= 3.8.0'] <<
|
47
|
+
['redcarpet', '>= 2.1.0'] <<
|
48
|
+
['bundler', '>= 1.0.10'] <<
|
49
|
+
['hoe-bundler', '>= 1.1.0'] <<
|
50
|
+
['hoe-gemspec', '>= 1.0.0']
|
51
|
+
|
52
|
+
unless extra_dev_deps.flatten.include?('hoe-yard')
|
53
|
+
extra_dev_deps << ['hoe-yard', '>= 0.1.2']
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
task 'Manifest.txt' do
|
58
|
+
puts 'generating Manifest.txt from git'
|
59
|
+
sh %{git ls-files | grep -v gitignore | grep -v Gemfile > Manifest.txt}
|
60
|
+
sh %{git add Manifest.txt}
|
61
|
+
end
|
62
|
+
|
63
|
+
task 'ChangeLog' do
|
64
|
+
sh %{git log > ChangeLog}
|
65
|
+
end
|
66
|
+
|
67
|
+
desc "Fix documentation's file permissions"
|
68
|
+
task :docperm do
|
69
|
+
sh %{chmod -R a+rX doc}
|
70
|
+
end
|
71
|
+
|
72
|
+
### Sign & Publish
|
73
|
+
|
74
|
+
desc "Create signed tag in Git"
|
75
|
+
task :tag do
|
76
|
+
sh %{git tag -s v#{ConfigurationBlocks::VERSION} -m 'version #{ConfigurationBlocks::VERSION}'}
|
77
|
+
end
|
78
|
+
|
79
|
+
desc "Create external GnuPG signature for Gem"
|
80
|
+
task :gemsign do
|
81
|
+
sh %{gpg -u #{ConfigurationBlocks::EMAIL} \
|
82
|
+
-ab pkg/#{ConfigurationBlocks::NAME}-#{ConfigurationBlocks::VERSION}.gem \
|
83
|
+
-o pkg/#{ConfigurationBlocks::NAME}-#{ConfigurationBlocks::VERSION}.gem.sig}
|
84
|
+
end
|
85
|
+
|
@@ -0,0 +1,58 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = "configuration-blocks"
|
5
|
+
s.version = "1.0.0.20121202030054"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Pawe\u{142} Wilk"]
|
9
|
+
s.cert_chain = ["/Users/siefca/.gem/gem-public_cert.pem"]
|
10
|
+
s.date = "2012-12-02"
|
11
|
+
s.description = "Easy way of adding configuration blocks to classes, modules and applications."
|
12
|
+
s.email = ["pw@gnu.org"]
|
13
|
+
s.extra_rdoc_files = ["Manifest.txt"]
|
14
|
+
s.files = [".rspec", ".yardopts", "ChangeLog", "LGPL-LICENSE", "Manifest.txt", "README.md", "Rakefile", "configuration-blocks.gemspec", "docs/COPYING", "docs/HISTORY", "docs/LEGAL", "docs/LGPL-LICENSE", "docs/TODO", "docs/rdoc.css", "docs/yard-tpl/default/fulldoc/html/css/common.css", "lib/configuration-blocks.rb", "lib/configuration-blocks/core.rb", "lib/configuration-blocks/version.rb"]
|
15
|
+
s.homepage = "https://rubygems.org/gems/configuration-blocks/"
|
16
|
+
s.rdoc_options = ["--title", "Configuration::Blocks Documentation", "--quiet"]
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
s.rubyforge_project = "configuration-blocks"
|
19
|
+
s.rubygems_version = "1.8.23"
|
20
|
+
s.signing_key = "/Users/siefca/.gem/gem-private_key.pem"
|
21
|
+
s.summary = "Easy way of adding configuration blocks to classes, modules and applications"
|
22
|
+
|
23
|
+
if s.respond_to? :specification_version then
|
24
|
+
s.specification_version = 3
|
25
|
+
|
26
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
27
|
+
s.add_development_dependency(%q<hoe-yard>, [">= 0.1.2"])
|
28
|
+
s.add_development_dependency(%q<rspec>, [">= 2.6.0"])
|
29
|
+
s.add_development_dependency(%q<yard>, [">= 0.8.2"])
|
30
|
+
s.add_development_dependency(%q<rdoc>, [">= 3.8.0"])
|
31
|
+
s.add_development_dependency(%q<redcarpet>, [">= 2.1.0"])
|
32
|
+
s.add_development_dependency(%q<bundler>, [">= 1.0.10"])
|
33
|
+
s.add_development_dependency(%q<hoe-bundler>, [">= 1.1.0"])
|
34
|
+
s.add_development_dependency(%q<hoe-gemspec>, [">= 1.0.0"])
|
35
|
+
s.add_development_dependency(%q<hoe>, ["~> 2.16"])
|
36
|
+
else
|
37
|
+
s.add_dependency(%q<hoe-yard>, [">= 0.1.2"])
|
38
|
+
s.add_dependency(%q<rspec>, [">= 2.6.0"])
|
39
|
+
s.add_dependency(%q<yard>, [">= 0.8.2"])
|
40
|
+
s.add_dependency(%q<rdoc>, [">= 3.8.0"])
|
41
|
+
s.add_dependency(%q<redcarpet>, [">= 2.1.0"])
|
42
|
+
s.add_dependency(%q<bundler>, [">= 1.0.10"])
|
43
|
+
s.add_dependency(%q<hoe-bundler>, [">= 1.1.0"])
|
44
|
+
s.add_dependency(%q<hoe-gemspec>, [">= 1.0.0"])
|
45
|
+
s.add_dependency(%q<hoe>, ["~> 2.16"])
|
46
|
+
end
|
47
|
+
else
|
48
|
+
s.add_dependency(%q<hoe-yard>, [">= 0.1.2"])
|
49
|
+
s.add_dependency(%q<rspec>, [">= 2.6.0"])
|
50
|
+
s.add_dependency(%q<yard>, [">= 0.8.2"])
|
51
|
+
s.add_dependency(%q<rdoc>, [">= 3.8.0"])
|
52
|
+
s.add_dependency(%q<redcarpet>, [">= 2.1.0"])
|
53
|
+
s.add_dependency(%q<bundler>, [">= 1.0.10"])
|
54
|
+
s.add_dependency(%q<hoe-bundler>, [">= 1.1.0"])
|
55
|
+
s.add_dependency(%q<hoe-gemspec>, [">= 1.0.0"])
|
56
|
+
s.add_dependency(%q<hoe>, ["~> 2.16"])
|
57
|
+
end
|
58
|
+
end
|
data/docs/COPYING
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
configuration-blocks is copyrighted free software owned by Paweł Wilk (pw@gnu.org). The Owner of this software permits you to redistribute and/or modify the software under either the terms of the LGPL version 3 (see the file {file:LGPL-LICENSE LGPL-LICENSE}), or the conditions below ("Ruby License").
|
2
|
+
|
3
|
+
== 1.
|
4
|
+
|
5
|
+
You may make and give away verbatim copies of the source form of this software without restriction, provided that you retain ALL of the
|
6
|
+
original copyright notices and associated disclaimers.
|
7
|
+
|
8
|
+
== 2.
|
9
|
+
|
10
|
+
You may modify your copy of the software in any way, provided that you do at least ONE of the following:
|
11
|
+
|
12
|
+
a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said
|
13
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
14
|
+
the author to include your modifications in the software.
|
15
|
+
|
16
|
+
b) use the modified software only within your corporation or
|
17
|
+
organization.
|
18
|
+
|
19
|
+
c) give non-standard binaries non-standard names, with
|
20
|
+
instructions on where to get the original software distribution.
|
21
|
+
|
22
|
+
d) make other distribution arrangements with the Owner.
|
23
|
+
|
24
|
+
== 3.
|
25
|
+
|
26
|
+
You may distribute the software in object code or binary form, provided that you do at least ONE of the following:
|
27
|
+
|
28
|
+
a) distribute the binaries and library files of the software,
|
29
|
+
together with instructions (in a manual page or equivalent)
|
30
|
+
on where to get the original distribution.
|
31
|
+
|
32
|
+
b) accompany the distribution with the machine-readable source of
|
33
|
+
the software.
|
34
|
+
|
35
|
+
c) give non-standard binaries non-standard names, with
|
36
|
+
instructions on where to get the original software distribution.
|
37
|
+
|
38
|
+
d) make other distribution arrangements with the Owner.
|
39
|
+
|
40
|
+
== 4.
|
41
|
+
|
42
|
+
You may modify and include parts of the software into any other software (possibly commercial), provided you comply with the terms in
|
43
|
+
Sections 1, 2, and 3 above. But some files in the distribution are not written by the Owner, so they may be made available to you
|
44
|
+
under different terms.
|
45
|
+
|
46
|
+
For the list of those files and their copying conditions, see the
|
47
|
+
file LEGAL.
|
48
|
+
|
49
|
+
== 5.
|
50
|
+
|
51
|
+
The scripts and library files supplied as input to or produced as output from the software do not automatically fall under the
|
52
|
+
copyright of the software, but belong to whoever generated them, and may be sold commercially, and may be aggregated with this software.
|
53
|
+
|
54
|
+
== 6.
|
55
|
+
|
56
|
+
THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
57
|
+
|
data/docs/HISTORY
ADDED
data/docs/LEGAL
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
LEGAL NOTICE INFORMATION
|
2
|
+
------------------------
|
3
|
+
|
4
|
+
configuration-blocks is Copyright (C) 2012 by Paweł Wilk.
|
5
|
+
|
6
|
+
configuration-blocks is copyrighted software owned by Paweł Wilk
|
7
|
+
(pw@gnu.org). You may redistribute and/or modify this
|
8
|
+
software as long as you comply with either the terms of the LGPL
|
9
|
+
(see the file {file:LGPL-LICENSE}),
|
10
|
+
or Ruby's license (see the file {file:COPYING}).
|
11
|
+
|
data/docs/LGPL-LICENSE
ADDED
@@ -0,0 +1,166 @@
|
|
1
|
+
|
2
|
+
= GNU LESSER GENERAL PUBLIC LICENSE
|
3
|
+
Version 3, 29 June 2007
|
4
|
+
|
5
|
+
Copyright (C) 2007 Free Software Foundation, Inc. < http://fsf.org/ >
|
6
|
+
Everyone is permitted to copy and distribute verbatim copies
|
7
|
+
of this license document, but changing it is not allowed.
|
8
|
+
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
11
|
+
License, supplemented by the additional permissions listed below.
|
12
|
+
|
13
|
+
=== 0. Additional Definitions.
|
14
|
+
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
17
|
+
General Public License.
|
18
|
+
|
19
|
+
The Library" refers to a covered work governed by this License,
|
20
|
+
other than an Application or a Combined Work as defined below.
|
21
|
+
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
25
|
+
of using an interface provided by the Library.
|
26
|
+
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
28
|
+
Application with the Library. The particular version of the Library
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
30
|
+
Version".
|
31
|
+
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
35
|
+
based on the Application, and not on the Linked Version.
|
36
|
+
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
38
|
+
object code and/or source code for the Application, including any data
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
41
|
+
|
42
|
+
=== 1. Exception to Section 3 of the GNU GPL.
|
43
|
+
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
46
|
+
|
47
|
+
=== 2. Conveying Modified Versions.
|
48
|
+
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
51
|
+
that uses the facility (other than as an argument passed when the
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
53
|
+
version:
|
54
|
+
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
56
|
+
ensure that, in the event an Application does not supply the
|
57
|
+
function or data, the facility still operates, and performs
|
58
|
+
whatever part of its purpose remains meaningful, or
|
59
|
+
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
61
|
+
this License applicable to that copy.
|
62
|
+
|
63
|
+
=== 3. Object Code Incorporating Material from Library Header Files.
|
64
|
+
|
65
|
+
The object code form of an Application may incorporate material from
|
66
|
+
a header file that is part of the Library. You may convey such object
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
68
|
+
material is not limited to numerical parameters, data structure
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
71
|
+
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
73
|
+
Library is used in it and that the Library and its use are
|
74
|
+
covered by this License.
|
75
|
+
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
77
|
+
document.
|
78
|
+
|
79
|
+
=== 4. Combined Works.
|
80
|
+
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
82
|
+
taken together, effectively do not restrict modification of the
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
85
|
+
the following:
|
86
|
+
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
88
|
+
the Library is used in it and that the Library and its use are
|
89
|
+
covered by this License.
|
90
|
+
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
92
|
+
document.
|
93
|
+
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
95
|
+
execution, include the copyright notice for the Library among
|
96
|
+
these notices, as well as a reference directing the user to the
|
97
|
+
copies of the GNU GPL and this license document.
|
98
|
+
|
99
|
+
d) Do one of the following:
|
100
|
+
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
102
|
+
License, and the Corresponding Application Code in a form
|
103
|
+
suitable for, and under terms that permit, the user to
|
104
|
+
recombine or relink the Application with a modified version of
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
107
|
+
Corresponding Source.
|
108
|
+
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
111
|
+
a copy of the Library already present on the user's computer
|
112
|
+
system, and (b) will operate properly with a modified version
|
113
|
+
of the Library that is interface-compatible with the Linked
|
114
|
+
Version.
|
115
|
+
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
117
|
+
be required to provide such information under section 6 of the
|
118
|
+
GNU GPL, and only to the extent that such information is
|
119
|
+
necessary to install and execute a modified version of the
|
120
|
+
Combined Work produced by recombining or relinking the
|
121
|
+
Application with a modified version of the Linked Version. (If
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
126
|
+
for conveying Corresponding Source.)
|
127
|
+
|
128
|
+
=== 5. Combined Libraries.
|
129
|
+
|
130
|
+
You may place library facilities that are a work based on the
|
131
|
+
Library side by side in a single library together with other library
|
132
|
+
facilities that are not Applications and are not covered by this
|
133
|
+
License, and convey such a combined library under terms of your
|
134
|
+
choice, if you do both of the following:
|
135
|
+
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
137
|
+
on the Library, uncombined with any other library facilities,
|
138
|
+
conveyed under the terms of this License.
|
139
|
+
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
141
|
+
is a work based on the Library, and explaining where to find the
|
142
|
+
accompanying uncombined form of the same work.
|
143
|
+
|
144
|
+
=== 6. Revised Versions of the GNU Lesser General Public License.
|
145
|
+
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
148
|
+
versions will be similar in spirit to the present version, but may
|
149
|
+
differ in detail to address new problems or concerns.
|
150
|
+
|
151
|
+
Each version is given a distinguishing version number. If the
|
152
|
+
Library as you received it specifies that a certain numbered version
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
154
|
+
applies to it, you have the option of following the terms and
|
155
|
+
conditions either of that published version or of any later version
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
160
|
+
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
164
|
+
permanent authorization for you to choose that version for the
|
165
|
+
Library.
|
166
|
+
|
data/docs/TODO
ADDED
File without changes
|
data/docs/rdoc.css
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
@import "rdoc_base.css";
|
2
|
+
|
3
|
+
#documentation > ul:first-of-type {
|
4
|
+
padding-bottom: 2em;
|
5
|
+
padding-top: 1.5em;
|
6
|
+
background-position: 20em 0%;
|
7
|
+
background-repeat: no-repeat;
|
8
|
+
}
|
9
|
+
|
10
|
+
#documentation .method-description > p:first-of-type + p {
|
11
|
+
margin-top: 0.5em;
|
12
|
+
}
|
13
|
+
|
14
|
+
#documentation .method-description > ul {
|
15
|
+
margin-left: 1.2em;
|
16
|
+
}
|
17
|
+
|
18
|
+
#documentation .method-description > p + ul {
|
19
|
+
margin-left: 1.8em;
|
20
|
+
}
|
21
|
+
|
@@ -0,0 +1,6 @@
|
|
1
|
+
# Author:: Paweł Wilk (mailto:pw@gnu.org)
|
2
|
+
# Copyright:: (c) 2012 by Paweł Wilk
|
3
|
+
# License:: This program is licensed under the terms of {file:LGPL-LICENSE GNU Lesser General Public License} or {file:COPYING Ruby License}.
|
4
|
+
|
5
|
+
require 'configuration-blocks/version'
|
6
|
+
require 'configuration-blocks/core'
|
@@ -0,0 +1,145 @@
|
|
1
|
+
# Author:: Paweł Wilk (mailto:pw@gnu.org)
|
2
|
+
# Copyright:: (c) 2012 by Paweł Wilk
|
3
|
+
# License:: This program is licensed under the terms of {file:LGPL-LICENSE GNU Lesser General Public License} or {file:COPYING Ruby License}.
|
4
|
+
#
|
5
|
+
# This file contains ConfigurationBlocks module.
|
6
|
+
|
7
|
+
require 'set'
|
8
|
+
|
9
|
+
# This module adds support for configuration blocks.
|
10
|
+
module ConfigurationBlocks
|
11
|
+
|
12
|
+
# @private
|
13
|
+
def self.included(base)
|
14
|
+
base.extend(ClassMethods)
|
15
|
+
base.singleton_class.extend(ClassMethods)
|
16
|
+
super if defined?(super)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Returns configuration block.
|
20
|
+
#
|
21
|
+
# @param base [Object,Symbol] base object which delegators will point to (defaults to object on which
|
22
|
+
# this method has been called). If symbol is given, then it should contain the name of a method that
|
23
|
+
# will be called on current object.
|
24
|
+
# @return [Object] result of evaluating the given block within context of configuration module
|
25
|
+
def configuration_block(base = self, &block)
|
26
|
+
self.class.configuration_block(base, &block)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Returns configuration module that delegates methods pointing to the given +base+ object
|
30
|
+
# and optionally evaluates the given block in the context of this module or in the current context.
|
31
|
+
#
|
32
|
+
# If a block is given then it is evaluated in the context of the configuration module.
|
33
|
+
# If a block with at least one argument is given then the context remains as it was
|
34
|
+
# but the first argument is the module.
|
35
|
+
#
|
36
|
+
# @example
|
37
|
+
# # using external access to configuration module:
|
38
|
+
# x.configuration_block do |c|
|
39
|
+
# c.some_setting :a
|
40
|
+
# c.other_setting :b
|
41
|
+
# end
|
42
|
+
#
|
43
|
+
# # using internal access to configuration module:
|
44
|
+
# x.configuration_block do
|
45
|
+
# some_setting :a
|
46
|
+
# other_setting :b
|
47
|
+
# end
|
48
|
+
#
|
49
|
+
# @param base [Object,Symbol] base object which delegators will point to (defaults to object on which
|
50
|
+
# this method has been called). If symbol is given, then it should contain the name of a method that
|
51
|
+
# will be called on current object.
|
52
|
+
# @return [Module,Object] configuration module if not block is given or a block takes no arguments. In case
|
53
|
+
# of one or more arguments in a block it also returns a module unless +break+ statement is used; in such case
|
54
|
+
# the value passed to +break+ is returned.
|
55
|
+
def configuration_block(base = self, &block)
|
56
|
+
@cb_conf_module ||= self.class.configuration_module(base)
|
57
|
+
self.class.send(:configuration_block_core, @cb_conf_module, &block)
|
58
|
+
end
|
59
|
+
|
60
|
+
# This module contains methods that will extend the class.
|
61
|
+
module ClassMethods
|
62
|
+
|
63
|
+
# Returns configuration block.
|
64
|
+
#
|
65
|
+
# @param base [Object,Symbol] base object which delegators will point to (defaults to object on which
|
66
|
+
# this method has been called). If symbol is given, then it should contain the name of a method that
|
67
|
+
# will be called on current object.
|
68
|
+
#
|
69
|
+
# @return [Object] result of evaluating the given block within context of configuration module
|
70
|
+
def configuration_block(base = self, &block)
|
71
|
+
@cb_conf_module ||= configuration_module(base)
|
72
|
+
configuration_block_core(@cb_conf_module, &block)
|
73
|
+
end
|
74
|
+
|
75
|
+
# Creates and returns anonymous module containing
|
76
|
+
# delegators that point to methods from a class this module is included in
|
77
|
+
# or the given +base+.
|
78
|
+
#
|
79
|
+
# @param base [Object,Symbol] base object which delegators will point to (defaults to object on which
|
80
|
+
# this method has been called). If symbol is given, then it should contain the name of a method that
|
81
|
+
# will be called on current object.
|
82
|
+
#
|
83
|
+
# @return [Module] anonymous module with proxy module methods delegating actions to +base+ object
|
84
|
+
def configuration_module(base = self)
|
85
|
+
Module.new.tap do |cm|
|
86
|
+
delegators = get_configuration_methods
|
87
|
+
base = send(base) if base.is_a?(Symbol)
|
88
|
+
cm.extend Module.new {
|
89
|
+
delegators.each do |method|
|
90
|
+
module_eval do
|
91
|
+
define_method(method) do |*args|
|
92
|
+
base.send(method, *args)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
96
|
+
}
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# Gets all method names known to configuration engine.
|
101
|
+
#
|
102
|
+
# @param local_only [Boolean] optional flag that if set, causes only methods added
|
103
|
+
# by current class or module to be listed.
|
104
|
+
#
|
105
|
+
# @return [Array<Symbol>] delegated method names
|
106
|
+
def get_configuration_methods(local_only = false)
|
107
|
+
all_delegators = singleton_class.send(:cf_block_delegators) + cf_block_delegators
|
108
|
+
return all_delegators if local_only
|
109
|
+
ancestors.each_with_object(all_delegators) do |ancestor, all|
|
110
|
+
all.merge(ancestor.send(__method__, true)) if ancestor.respond_to?(__method__)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
# This DSL method is intended to be used in a class or module to indicate which methods
|
115
|
+
# should be delegated.
|
116
|
+
#
|
117
|
+
# @param methods [Array<Symbol,String>] list of method names
|
118
|
+
# @return [nil]
|
119
|
+
def configuration_block_delegate(*methods)
|
120
|
+
methods.flatten.each { |m| cf_block_delegators.add(m.to_sym) }
|
121
|
+
@cb_conf_module = nil if @cb_conf_module
|
122
|
+
nil
|
123
|
+
end
|
124
|
+
alias_method :configuration_method, :configuration_block_delegate
|
125
|
+
alias_method :configuration_methods, :configuration_block_delegate
|
126
|
+
alias_method :settings_method, :configuration_block_delegate
|
127
|
+
|
128
|
+
private
|
129
|
+
|
130
|
+
# Getter for +@cf_block_delegators+ internal variable.
|
131
|
+
def cf_block_delegators
|
132
|
+
@cf_block_delegators ||= Set.new
|
133
|
+
end
|
134
|
+
|
135
|
+
# Evaluates configuration block within a context of the given module.
|
136
|
+
def configuration_block_core(conf_module, &block)
|
137
|
+
return conf_module unless block_given?
|
138
|
+
return conf_module.tap(&block) unless block.arity == 0
|
139
|
+
conf_module.module_eval(&block)
|
140
|
+
conf_module
|
141
|
+
end
|
142
|
+
|
143
|
+
end # module ClassMethods
|
144
|
+
|
145
|
+
end # module ConfigurationBlocks
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
#
|
3
|
+
# Author:: Paweł Wilk (mailto:pw@gnu.org)
|
4
|
+
# Copyright:: (c) 2012 by Paweł Wilk
|
5
|
+
# License:: This program is licensed under the terms of {file:LGPL-LICENSE GNU Lesser General Public License} or {file:COPYING Ruby License}.
|
6
|
+
#
|
7
|
+
# This file contains version information.
|
8
|
+
|
9
|
+
module ConfigurationBlocks
|
10
|
+
# @private
|
11
|
+
DEVELOPER = 'Paweł Wilk'
|
12
|
+
# @private
|
13
|
+
EMAIL = 'pw@gnu.org'
|
14
|
+
# @private
|
15
|
+
VERSION = '1.0.0'
|
16
|
+
# @private
|
17
|
+
NAME = 'configuration-blocks'
|
18
|
+
# @private
|
19
|
+
SUMMARY = 'Easy way of adding configuration blocks to classes, modules and applications'
|
20
|
+
# @private
|
21
|
+
URL = 'https://rubygems.org/gems/configuration-blocks/'
|
22
|
+
# @private
|
23
|
+
DESCRIPTION = 'Easy way of adding configuration blocks to classes, modules and applications.'
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,241 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: configuration-blocks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Paweł Wilk
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain:
|
12
|
+
- !binary |-
|
13
|
+
LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURLakNDQWhLZ0F3SUJB
|
14
|
+
Z0lCQURBTkJna3Foa2lHOXcwQkFRVUZBREE3TVE4d0RRWURWUVFEREFaemFX
|
15
|
+
Vm0KWTJFeEV6QVJCZ29Ka2lhSmsvSXNaQUVaRmdObmJuVXhFekFSQmdvSmtp
|
16
|
+
YUprL0lzWkFFWkZnTnZjbWN3SGhjTgpNRGt3TmpBMk1Ea3dPREE1V2hjTk1U
|
17
|
+
QXdOakEyTURrd09EQTVXakE3TVE4d0RRWURWUVFEREFaemFXVm1ZMkV4CkV6
|
18
|
+
QVJCZ29Ka2lhSmsvSXNaQUVaRmdObmJuVXhFekFSQmdvSmtpYUprL0lzWkFF
|
19
|
+
WkZnTnZjbWN3Z2dFaU1BMEcKQ1NxR1NJYjNEUUVCQVFVQUE0SUJEd0F3Z2dF
|
20
|
+
S0FvSUJBUUNkazQrOWllU3gySTJPUHNsUGNqL0xqYWp3dHNySAptZXY2RnMz
|
21
|
+
eEs5aGRESWJiTHVRTTlBeXBCUzdOZUtQLzJZVG9FT0d4c3Z6Y3BGekwyQWg3
|
22
|
+
MWNQNllmbitaMllvCnp2cXBBeDUvbmw3OVBySkt2amxrZHpWTk9GQnAvRU9r
|
23
|
+
TEs2N1FLNFB2OTdBQm5HMlBrRjRGb2txT2p1TkhMTTcKNDdPa0pQdkZ5Zkh5
|
24
|
+
TUJEWk43RUZsakJCTm0zSXVRUlRpTzQ4ZTVKY3AzTDc2MVBXT3ZDcG5WOHdp
|
25
|
+
Z2EwV3d0Mwo5OEdteTdjMW5XemZiUWMxd0h3S0xQSUNZL2FpZEtVMjBLeW1T
|
26
|
+
SEc2M0JTVzVwTzJjWFplY0llWWp3NVlOakdBCk0xUlpNaXdUN1FKOVc4NlZW
|
27
|
+
UCs4RXFiSktKT1M5NXhsbVFUSGpQSzU2eVh2OEdpdXlMUUhwUGg1QWdNQkFB
|
28
|
+
R2oKT1RBM01Ba0dBMVVkRXdRQ01BQXdIUVlEVlIwT0JCWUVGS09Lc3BaT05x
|
29
|
+
NGJ0NUQyREVleEIrdnNNQjJHTUFzRwpBMVVkRHdRRUF3SUVzREFOQmdrcWhr
|
30
|
+
aUc5dzBCQVFVRkFBT0NBUUVBVWgwTG5CNG81WEtwSDN5T3hhdkV5cDlYCk5l
|
31
|
+
bjJlODU0d3NTakFyMHdhU1Z6RXQzWHhZMXZveUlFNldDR3haSlUvLzQwQ1Iw
|
32
|
+
QmU3ajVDY3NKc0RVMkNaeVoKOFNYTjEvbVpqTXFXdll5RU1TZlFQNFh6a0ZT
|
33
|
+
T3V5RGNvREFmNDNPR2hPaGR2NUpjcy9FdC9GSDZEZ1dZd1J4cQpSdEFUUldP
|
34
|
+
TjVSOTl1Z1BlUmI3aTFuSXBuekdFQkE5VjMycjZyOTU5QnAzWGprVkVYeWxi
|
35
|
+
SXRZTXFTQVJhWmxZCnF6S1NzSVVqaDd2RHlUTnF0YTBEalNnQ2syNmRobk93
|
36
|
+
YzBobXpodlZadEJ3ZlpyaXRTVmhmQ0xwNXVGd3FDcVkKTkszVElaYVBDaDFT
|
37
|
+
Mi9FUzZ3WE52alErNUVuRUVMOWovcFNFb3A5RFlFQlBhTTJXRFZSNWkwakpU
|
38
|
+
QWFSV3c9PQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
|
39
|
+
date: 2012-12-02 00:00:00.000000000 Z
|
40
|
+
dependencies:
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: hoe-yard
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
none: false
|
45
|
+
requirements:
|
46
|
+
- - ! '>='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 0.1.2
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 0.1.2
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: rspec
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: 2.6.0
|
65
|
+
type: :development
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 2.6.0
|
73
|
+
- !ruby/object:Gem::Dependency
|
74
|
+
name: yard
|
75
|
+
requirement: !ruby/object:Gem::Requirement
|
76
|
+
none: false
|
77
|
+
requirements:
|
78
|
+
- - ! '>='
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: 0.8.2
|
81
|
+
type: :development
|
82
|
+
prerelease: false
|
83
|
+
version_requirements: !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ! '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 0.8.2
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: rdoc
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
none: false
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 3.8.0
|
97
|
+
type: :development
|
98
|
+
prerelease: false
|
99
|
+
version_requirements: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
102
|
+
- - ! '>='
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: 3.8.0
|
105
|
+
- !ruby/object:Gem::Dependency
|
106
|
+
name: redcarpet
|
107
|
+
requirement: !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
109
|
+
requirements:
|
110
|
+
- - ! '>='
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 2.1.0
|
113
|
+
type: :development
|
114
|
+
prerelease: false
|
115
|
+
version_requirements: !ruby/object:Gem::Requirement
|
116
|
+
none: false
|
117
|
+
requirements:
|
118
|
+
- - ! '>='
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: 2.1.0
|
121
|
+
- !ruby/object:Gem::Dependency
|
122
|
+
name: bundler
|
123
|
+
requirement: !ruby/object:Gem::Requirement
|
124
|
+
none: false
|
125
|
+
requirements:
|
126
|
+
- - ! '>='
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: 1.0.10
|
129
|
+
type: :development
|
130
|
+
prerelease: false
|
131
|
+
version_requirements: !ruby/object:Gem::Requirement
|
132
|
+
none: false
|
133
|
+
requirements:
|
134
|
+
- - ! '>='
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: 1.0.10
|
137
|
+
- !ruby/object:Gem::Dependency
|
138
|
+
name: hoe-bundler
|
139
|
+
requirement: !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
141
|
+
requirements:
|
142
|
+
- - ! '>='
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: 1.1.0
|
145
|
+
type: :development
|
146
|
+
prerelease: false
|
147
|
+
version_requirements: !ruby/object:Gem::Requirement
|
148
|
+
none: false
|
149
|
+
requirements:
|
150
|
+
- - ! '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 1.1.0
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: hoe-gemspec
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
none: false
|
157
|
+
requirements:
|
158
|
+
- - ! '>='
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: 1.0.0
|
161
|
+
type: :development
|
162
|
+
prerelease: false
|
163
|
+
version_requirements: !ruby/object:Gem::Requirement
|
164
|
+
none: false
|
165
|
+
requirements:
|
166
|
+
- - ! '>='
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: 1.0.0
|
169
|
+
- !ruby/object:Gem::Dependency
|
170
|
+
name: hoe
|
171
|
+
requirement: !ruby/object:Gem::Requirement
|
172
|
+
none: false
|
173
|
+
requirements:
|
174
|
+
- - ~>
|
175
|
+
- !ruby/object:Gem::Version
|
176
|
+
version: '2.16'
|
177
|
+
type: :development
|
178
|
+
prerelease: false
|
179
|
+
version_requirements: !ruby/object:Gem::Requirement
|
180
|
+
none: false
|
181
|
+
requirements:
|
182
|
+
- - ~>
|
183
|
+
- !ruby/object:Gem::Version
|
184
|
+
version: '2.16'
|
185
|
+
description: Easy way of adding configuration blocks to classes, modules and applications.
|
186
|
+
email:
|
187
|
+
- pw@gnu.org
|
188
|
+
executables: []
|
189
|
+
extensions: []
|
190
|
+
extra_rdoc_files:
|
191
|
+
- Manifest.txt
|
192
|
+
files:
|
193
|
+
- .rspec
|
194
|
+
- .yardopts
|
195
|
+
- ChangeLog
|
196
|
+
- LGPL-LICENSE
|
197
|
+
- Manifest.txt
|
198
|
+
- README.md
|
199
|
+
- Rakefile
|
200
|
+
- configuration-blocks.gemspec
|
201
|
+
- docs/COPYING
|
202
|
+
- docs/HISTORY
|
203
|
+
- docs/LEGAL
|
204
|
+
- docs/LGPL-LICENSE
|
205
|
+
- docs/TODO
|
206
|
+
- docs/rdoc.css
|
207
|
+
- docs/yard-tpl/default/fulldoc/html/css/common.css
|
208
|
+
- lib/configuration-blocks.rb
|
209
|
+
- lib/configuration-blocks/core.rb
|
210
|
+
- lib/configuration-blocks/version.rb
|
211
|
+
homepage: https://rubygems.org/gems/configuration-blocks/
|
212
|
+
licenses: []
|
213
|
+
post_install_message:
|
214
|
+
rdoc_options:
|
215
|
+
- --title
|
216
|
+
- Configuration::Blocks Documentation
|
217
|
+
- --quiet
|
218
|
+
require_paths:
|
219
|
+
- lib
|
220
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
221
|
+
none: false
|
222
|
+
requirements:
|
223
|
+
- - ! '>='
|
224
|
+
- !ruby/object:Gem::Version
|
225
|
+
version: '0'
|
226
|
+
segments:
|
227
|
+
- 0
|
228
|
+
hash: -2840952254768116890
|
229
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
230
|
+
none: false
|
231
|
+
requirements:
|
232
|
+
- - ! '>='
|
233
|
+
- !ruby/object:Gem::Version
|
234
|
+
version: '0'
|
235
|
+
requirements: []
|
236
|
+
rubyforge_project: configuration-blocks
|
237
|
+
rubygems_version: 1.8.23
|
238
|
+
signing_key:
|
239
|
+
specification_version: 3
|
240
|
+
summary: Easy way of adding configuration blocks to classes, modules and applications
|
241
|
+
test_files: []
|
metadata.gz.sig
ADDED
Binary file
|