block_configurable 0.9.0 → 0.10.0
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.
- checksums.yaml +4 -4
- data/README.md +23 -18
- data/lib/block_configurable/version.rb +1 -1
- data/lib/block_configurable.rb +2 -2
- data/test/block_configurable/block_configurable_test.rb +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c16db92cffd0aa2c695abb35add01b294050c5b4
|
4
|
+
data.tar.gz: 1f1be3a9c3a4bc569e7e0c7ae349dd21a0fb6f59
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4347a2ffd104826dd9a97cc79dbb9ff4de0826c4152c4b46183388dcfae42e236b1c110dba71c04aac8643badc07c3ec2530a8a4110b4c16079801ff880ea238
|
7
|
+
data.tar.gz: bda47a8b19f0e58136c488e11a108d58550cdad8d565b9488e9451ae73ac7c0b74272f70c7a45cbd0f5ef1b7d4ccfb5e68d0dea3a2d2de2eb8d4e7d38942a9c1
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# BlockConfigurable
|
2
2
|
|
3
|
-
[](https://travis-ci.org/artemshitov/block_configurable) [](https://codeclimate.com/github/artemshitov/block_configurable)
|
3
|
+
[](https://travis-ci.org/artemshitov/block_configurable) [](https://codeclimate.com/github/artemshitov/block_configurable) [](http://badge.fury.io/rb/block_configurable)
|
4
4
|
|
5
5
|
A little mixin to make your classes and modules configurable using either single statements or blocks.
|
6
6
|
|
@@ -12,38 +12,43 @@ Install as a standalone gem:
|
|
12
12
|
|
13
13
|
Or include into your `Gemfile`:
|
14
14
|
|
15
|
-
|
15
|
+
```ruby
|
16
|
+
gem 'block_configurable', '~> 0.10.0'
|
17
|
+
```
|
16
18
|
|
17
19
|
## Usage
|
18
|
-
|
20
|
+
|
21
|
+
Set up class (or module). Only parameters explicitly listed will be available for configuration.
|
22
|
+
|
19
23
|
```ruby
|
20
24
|
class MyClass
|
21
25
|
include BlockConfigurable
|
22
26
|
|
23
|
-
|
24
|
-
|
25
|
-
|
27
|
+
configurable :param_with_default_value, 'A default!'
|
28
|
+
configurable :param_without_default_value
|
29
|
+
configurable :another_one
|
26
30
|
end
|
31
|
+
```
|
27
32
|
|
28
|
-
|
29
|
-
#=> 'A default!'
|
30
|
-
|
31
|
-
MyClass.configuration.param_without_default_value
|
32
|
-
#=> nil
|
33
|
+
Configure it:
|
33
34
|
|
35
|
+
```ruby
|
34
36
|
MyClass.configure do |c|
|
35
|
-
c.param_with_default_value = 'My values, my rules'
|
36
37
|
c.param_without_default_value = 'A value now!'
|
38
|
+
c.another_one = 'My values, my rules'
|
37
39
|
end
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
+
# or
|
42
|
+
|
43
|
+
MyClass.configuration.another_one = 'My values, my rules'
|
44
|
+
```
|
41
45
|
|
42
|
-
|
43
|
-
#=> 'A value now!'
|
46
|
+
Read configuration:
|
44
47
|
|
45
|
-
|
48
|
+
```ruby
|
49
|
+
MyClass.configuration.param_with_default_value
|
50
|
+
#=> 'A default!'
|
46
51
|
|
47
52
|
MyClass.configuration.another_one
|
48
|
-
#=> '
|
53
|
+
#=> 'My values, my rules'
|
49
54
|
```
|
data/lib/block_configurable.rb
CHANGED
@@ -7,7 +7,7 @@ module BlockConfigurable
|
|
7
7
|
@configuration ||= Configuration.new
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
10
|
+
def configurable(param, default = nil)
|
11
11
|
configuration.add_config(param, default)
|
12
12
|
end
|
13
13
|
|
@@ -18,6 +18,6 @@ module BlockConfigurable
|
|
18
18
|
|
19
19
|
def self.included(receiver)
|
20
20
|
receiver.extend ClassMethods
|
21
|
-
receiver.send :private_class_method, :
|
21
|
+
receiver.send :private_class_method, :configurable
|
22
22
|
end
|
23
23
|
end
|
@@ -4,16 +4,16 @@ require 'block_configurable'
|
|
4
4
|
class Configurable
|
5
5
|
include BlockConfigurable
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
configurable :value_with_default, 1
|
8
|
+
configurable :value_without_default, nil
|
9
|
+
configurable :value_to_change, 'a'
|
10
|
+
configurable :value_to_test_hash, :test
|
11
11
|
end
|
12
12
|
|
13
13
|
module ConfigurableModule
|
14
14
|
include BlockConfigurable
|
15
15
|
|
16
|
-
|
16
|
+
configurable :value_with_default, 1
|
17
17
|
end
|
18
18
|
|
19
19
|
class BlockConfigurableTest < Minitest::Test
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: block_configurable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Artem Shitov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|