nxt_config 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +1 -1
- data/README.md +5 -2
- data/lib/nxt_config.rb +7 -2
- data/lib/nxt_config/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0eeb33c443f139f43cbf12e64594e24a7623329461dc767d5fa5d98a34cc1606
|
4
|
+
data.tar.gz: d707cd6e76a1ca3cd283420ebe2d54bd2ade462d069fb84ecac31484c63f7c08
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6552d0798f6c99f14fa4dc5f453091d5bba323759d20fbbac9a05b34a1cadce2eb65b10fcf53ef9b1a3e8ad095d8c198417794d02e7ebd832ad7ff1fdb4d2c50
|
7
|
+
data.tar.gz: 621f00981928f7d1a7e912274af295d7d5cf6c4613987068ef6b8fa850418719e651f0055c4c7e0b09c9bff4314918fc6b5156cae574484e8d537ca9cb57319e
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -27,7 +27,8 @@ Or install it yourself as:
|
|
27
27
|
|
28
28
|
## Usage
|
29
29
|
|
30
|
-
You can
|
30
|
+
You can create a configuration object using `NxtConfig.load` from YAML files or directly from a hash.
|
31
|
+
If you are in a rails application, you can do this in an initializer (e.g. `config/initializers/nxt_config.rb`).
|
31
32
|
|
32
33
|
```ruby
|
33
34
|
module MyRailsApp
|
@@ -35,7 +36,9 @@ module MyRailsApp
|
|
35
36
|
end
|
36
37
|
```
|
37
38
|
|
38
|
-
Of course you can also load configuration structs everywhere else in the application.
|
39
|
+
Of course you can also load configuration structs everywhere else in the application.
|
40
|
+
Depending on where you assign it to a constant, you can have many configuration structs available via constants namespaced all over your application,
|
41
|
+
scoped to the context where you need them.
|
39
42
|
|
40
43
|
```ruby
|
41
44
|
# Use struct like method chaining to access nested data
|
data/lib/nxt_config.rb
CHANGED
@@ -5,8 +5,13 @@ require "nxt_config/struct"
|
|
5
5
|
require "nxt_config/version"
|
6
6
|
|
7
7
|
module NxtConfig
|
8
|
-
def load(
|
9
|
-
|
8
|
+
def load(filename_or_hash)
|
9
|
+
if filename_or_hash.respond_to?(:to_h)
|
10
|
+
source_hash = filename_or_hash
|
11
|
+
else
|
12
|
+
source_hash = YAML.safe_load(ERB.new(File.read(filename_or_hash)).result)
|
13
|
+
end
|
14
|
+
|
10
15
|
Struct.new(source_hash)
|
11
16
|
end
|
12
17
|
|
data/lib/nxt_config/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nxt_config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nils Sommer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Create namespaced, immutable objects serving configuration properties
|
14
14
|
to your ruby application.
|