ettin 1.1.5 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -3
- data/lib/ettin/options.rb +29 -2
- data/lib/ettin/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9dd6d9b69ef0b573b75f582f7c6c9f2f1afb8e16b127999f144a7fd65f61a9ad
|
4
|
+
data.tar.gz: dc56de18c062471f558fc88790660f2a3c118e3313a998a41a394c374130ef19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5796dcf7cd7ff06b6ab16ee87bf4b4098348054ba39e8f1ad763d94c24df48a361ac5157d52da6200239cb9662bf9748b9f254e1ef6b2af3ccbb658d05ec94ad
|
7
|
+
data.tar.gz: 32dfd88f01e37b6033db91ceed9b94f8f9663ab9e933d8adf87a3c4eb73900a09cb25918bdc19298317068871ae9b14a3d624a24f06a8bfd6d799d16396e1ddf
|
data/README.md
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
[![Build Status](https://travis-ci.org/mlibrary/ettin.svg?branch=master)](https://travis-ci.org/mlibrary/ettin)
|
4
4
|
[![Maintainability](https://api.codeclimate.com/v1/badges/efd34b151bad7dacb994/maintainability)](https://codeclimate.com/github/mlibrary/ettin/maintainability)
|
5
5
|
[![Test Coverage](https://api.codeclimate.com/v1/badges/efd34b151bad7dacb994/test_coverage)](https://codeclimate.com/github/mlibrary/ettin/test_coverage)
|
6
|
-
[![Dependency Status](https://gemnasium.com/badges/github.com/mlibrary/ettin.svg)](https://gemnasium.com/github.com/mlibrary/ettin)
|
7
6
|
|
8
7
|
## Summary
|
9
8
|
|
@@ -23,8 +22,9 @@ ruby nor does it pollute the global namespace.
|
|
23
22
|
|
24
23
|
## Compatibility
|
25
24
|
|
26
|
-
* ruby 2.
|
25
|
+
* ruby 2.5.x
|
27
26
|
* ruby 2.4.x
|
27
|
+
* ruby 2.3.x
|
28
28
|
|
29
29
|
As Ettin does not rely on any specific runtime environment other than
|
30
30
|
the ruby core and standard library, it is compatible with every
|
@@ -71,7 +71,25 @@ module MyApp
|
|
71
71
|
end
|
72
72
|
```
|
73
73
|
|
74
|
-
|
74
|
+
Use one of the above variants in a Rails app's `application.rb`, making
|
75
|
+
settings available to your `environment.rb`, `development.rb`, and initializers:
|
76
|
+
|
77
|
+
```ruby
|
78
|
+
module MyApp
|
79
|
+
class << self
|
80
|
+
def config
|
81
|
+
@config ||= Ettin.for(Ettin.settings_files("config", Rails.env))
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
class Application < Rails::Application
|
86
|
+
# ...
|
87
|
+
end
|
88
|
+
end
|
89
|
+
```
|
90
|
+
|
91
|
+
Add a section to the Rails configuration in an initializer (noting that load
|
92
|
+
order is alphanumeric):
|
75
93
|
|
76
94
|
```ruby
|
77
95
|
Rails.application.configure do |config|
|
data/lib/ettin/options.rb
CHANGED
@@ -20,8 +20,22 @@ module Ettin
|
|
20
20
|
|
21
21
|
def method_missing(method, *args, &block)
|
22
22
|
if handles?(method)
|
23
|
-
if
|
24
|
-
|
23
|
+
if !key?(debang(method))
|
24
|
+
if bang?(method)
|
25
|
+
raise KeyError, "key #{debang(method)} not found"
|
26
|
+
else
|
27
|
+
self[debang(method)]
|
28
|
+
end
|
29
|
+
else
|
30
|
+
self[debang(method)]
|
31
|
+
end
|
32
|
+
else
|
33
|
+
super(method, *args, &block)
|
34
|
+
end
|
35
|
+
|
36
|
+
if handles?(method)
|
37
|
+
if bang?(method)
|
38
|
+
handle_bang_method(method)
|
25
39
|
else
|
26
40
|
self[debang(method)]
|
27
41
|
end
|
@@ -30,6 +44,14 @@ module Ettin
|
|
30
44
|
end
|
31
45
|
end
|
32
46
|
|
47
|
+
def handle_bang_method(method)
|
48
|
+
if key?(debang(method))
|
49
|
+
self[debang(method)]
|
50
|
+
else
|
51
|
+
raise KeyError, "key #{debang(method)} not found"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
33
55
|
# We respond to:
|
34
56
|
# * all methods our parents respond to
|
35
57
|
# * all methods that are mostly alpha-numeric: /^[a-zA-Z_0-9]*$/
|
@@ -43,6 +65,11 @@ module Ettin
|
|
43
65
|
end
|
44
66
|
alias_method :has_key?, :key?
|
45
67
|
|
68
|
+
def merge(other)
|
69
|
+
new_hash = {}.deeper_merge(hash).deeper_merge!(other.to_h, overwrite_arrays: true)
|
70
|
+
self.class.new(new_hash)
|
71
|
+
end
|
72
|
+
|
46
73
|
def merge!(other)
|
47
74
|
hash.deeper_merge!(other.to_h, overwrite_arrays: true)
|
48
75
|
end
|
data/lib/ettin/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ettin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bryan Hockey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: deep_merge
|
@@ -144,8 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: '0'
|
146
146
|
requirements: []
|
147
|
-
|
148
|
-
rubygems_version: 2.7.6
|
147
|
+
rubygems_version: 3.0.2
|
149
148
|
signing_key:
|
150
149
|
specification_version: 4
|
151
150
|
summary: The best way to add settings in any ruby project.
|