configurations 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +3 -3
- data/Gemfile +2 -0
- data/README.md +7 -1
- data/lib/configurations.rb +1 -1
- data/lib/configurations/configuration.rb +27 -14
- data/test/test_helper.rb +3 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e15768b4735b836614316e5add917727b13f06a
|
4
|
+
data.tar.gz: e211a39356c76a333f2b855bc831341de38c876b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d0140d31188351ae3af656201eedebe5c1f68e4f98f4ad44c27557c366f761cf9a84079199ea1cc800dddaf753a09ce02645e75c9497a295bb0af17f44ac929
|
7
|
+
data.tar.gz: 6cb2bb2c5e950d40e49bcd1342017eb7723916799883770d7f98d9fb2d2a1a6873c69a8b59a3ac404c372999266a07df98e639c261c7ad1a22715e83d17d90ad
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
# Configurations
|
2
|
+
[![Build Status](https://travis-ci.org/beatrichartz/configurations.svg?branch=master)](https://travis-ci.org/beatrichartz/configurations) [![Test Coverage](https://codeclimate.com/github/beatrichartz/configurations/badges/coverage.svg)](https://codeclimate.com/github/beatrichartz/configurations) [![Code Climate](https://codeclimate.com/github/beatrichartz/configurations/badges/gpa.svg)](https://codeclimate.com/github/beatrichartz/configurations) [![Inline docs](http://inch-ci.org/github/beatrichartz/configurations.png?branch=master)](http://inch-ci.org/github/beatrichartz/configurations) [![Dependency Status](https://gemnasium.com/beatrichartz/configurations.svg)](https://gemnasium.com/beatrichartz/configurations)
|
3
|
+
|
2
4
|
|
3
5
|
Configurations provides a unified approach to do configurations using the `MyGem.configure do ... end` idiom with the flexibility to do everything from arbitrary configurations to type asserted configurations for your gem or any other ruby code.
|
4
6
|
|
@@ -12,6 +14,10 @@ or with Bundler
|
|
12
14
|
|
13
15
|
Configurations uses [Semver 2.0](http://semver.org/)
|
14
16
|
|
17
|
+
## Compatibility
|
18
|
+
|
19
|
+
Compatible with MRI 1.9.2 - 2.1, Rubinius, jRuby
|
20
|
+
|
15
21
|
## Why?
|
16
22
|
|
17
23
|
There are various ways to do configurations, yet there seems to be a broad consensus on the `MyGem.configure do ... end` idiom.
|
@@ -133,7 +139,7 @@ MyGem.configuration.to_h #=> a Hash
|
|
133
139
|
|
134
140
|
### Some caveats
|
135
141
|
|
136
|
-
The `to_h` from above is along with `method_missing` and `initialize` the only purposely defined method which you can not overwrite with a configuration value.
|
142
|
+
The `to_h` from above is along with `method_missing`, `object_id` and `initialize` the only purposely defined method which you can not overwrite with a configuration value.
|
137
143
|
Apart from these methods, you should be able to set pretty much any property name you like. `Configuration` inherits from `BasicObject`, so even standard Ruby method names are available.
|
138
144
|
|
139
145
|
## Contributing
|
data/lib/configurations.rb
CHANGED
@@ -3,23 +3,36 @@ module Configurations
|
|
3
3
|
#
|
4
4
|
class Configuration < BasicObject
|
5
5
|
|
6
|
-
#
|
7
|
-
#
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
6
|
+
# 1.9 does not allow for method rebinding in another scope
|
7
|
+
#
|
8
|
+
if ::RUBY_VERSION < '2.0.0'
|
9
|
+
include ::Kernel
|
10
|
+
undef :nil?, :===, :=~, :!~, :eql?, :hash, :<=>, :class, :singleton_class, :clone, :dup, :initialize_dup,
|
11
|
+
:initialize_clone, :taint, :tainted?, :untaint, :untrust, :untrusted?, :trust, :freeze, :frozen?,
|
12
|
+
:to_s, :inspect, :methods, :singleton_methods, :protected_methods, :private_methods, :public_methods,
|
13
|
+
:instance_variables, :instance_variable_get, :instance_variable_set, :instance_variable_defined?,
|
14
|
+
:instance_of?, :kind_of?, :tap, :send, :public_send, :respond_to?, :respond_to_missing?, :extend,
|
15
|
+
:display, :method, :public_method, :define_singleton_method, :to_enum, :enum_for
|
16
|
+
else
|
17
|
+
# @!macro [attach] install_kernel_method
|
18
|
+
# @method $1
|
19
|
+
#
|
20
|
+
def self.install_kernel_method(method)
|
21
|
+
kernel_method = ::Kernel.instance_method(method)
|
22
|
+
|
23
|
+
define_method method do |*args, &block|
|
24
|
+
kernel_method.bind(self).call(*args, &block)
|
25
|
+
end
|
13
26
|
end
|
14
|
-
end
|
15
27
|
|
16
|
-
|
17
|
-
|
18
|
-
|
28
|
+
# Installs the type asserting is_a? method from Kernel
|
29
|
+
#
|
30
|
+
install_kernel_method(:is_a?)
|
19
31
|
|
20
|
-
|
21
|
-
|
22
|
-
|
32
|
+
# Installs the inspect method from Kernel
|
33
|
+
#
|
34
|
+
install_kernel_method(:inspect)
|
35
|
+
end
|
23
36
|
|
24
37
|
# Initialize a new configuration
|
25
38
|
# @param [Proc] configuration_defaults A proc yielding to a default configuration
|
data/test/test_helper.rb
CHANGED