nxt_config 0.2.1 → 0.2.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d8967fb731cfbb8388f8f72b4111137b1a65f59e597982d43e86f9da0280d89
4
- data.tar.gz: b111ac2f900a61e4361c0475fb9cc2d85a55e12a78764b5fef04baf948d06821
3
+ metadata.gz: 0eeb33c443f139f43cbf12e64594e24a7623329461dc767d5fa5d98a34cc1606
4
+ data.tar.gz: d707cd6e76a1ca3cd283420ebe2d54bd2ade462d069fb84ecac31484c63f7c08
5
5
  SHA512:
6
- metadata.gz: 9cc788737cce9c3addc730d6f6999b536b1d9cd2fe0d53a3c75f6ced49e3195fc622300486ee70c6942385c6b16971e08615858c8ab6c8abaa0312a7c410321a
7
- data.tar.gz: 2e44b14680acb33d9bb9585dc563d8536ddf131842b66963e8e3a6fe6c4227a9c8a48a1206f68fd857ca6ca9a7d3864629e269bb7758939496a965144d8fdac8
6
+ metadata.gz: 6552d0798f6c99f14fa4dc5f453091d5bba323759d20fbbac9a05b34a1cadce2eb65b10fcf53ef9b1a3e8ad095d8c198417794d02e7ebd832ad7ff1fdb4d2c50
7
+ data.tar.gz: 621f00981928f7d1a7e912274af295d7d5cf6c4613987068ef6b8fa850418719e651f0055c4c7e0b09c9bff4314918fc6b5156cae574484e8d537ca9cb57319e
@@ -1,3 +1,12 @@
1
+ # v0.2.2 2019-03-10
2
+
3
+ ### Added
4
+
5
+ - [internal] Allow to load NxtConfig from a hash source
6
+
7
+ [Compare v0.2.1...v0.2.2](https://github.com/nxt-insurance/nxt_config/compare/v0.2.0...v0.2.1)
8
+
9
+
1
10
  # v0.2.1 2019-01-11
2
11
 
3
12
  ### Added
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- nxt_config (0.2.1)
4
+ nxt_config (0.2.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -27,7 +27,8 @@ Or install it yourself as:
27
27
 
28
28
  ## Usage
29
29
 
30
- You can load YAML files and populate their content into a configuration object using `NxtConfig.load`. If you are in a rails application, you can do this in an initializer (e.g. `config/initializers/nxt_config.rb`).
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. Depending on where you assign it to a constant, you can have many configuration structs available via constants namespaced all over your application, scoped to the context where you need them.
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
@@ -5,8 +5,13 @@ require "nxt_config/struct"
5
5
  require "nxt_config/version"
6
6
 
7
7
  module NxtConfig
8
- def load(filename)
9
- source_hash = YAML.safe_load(ERB.new(File.read(filename)).result)
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
 
@@ -1,3 +1,3 @@
1
1
  module NxtConfig
2
- VERSION = "0.2.1".freeze
2
+ VERSION = "0.2.2".freeze
3
3
  end
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.1
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-01-11 00:00:00.000000000 Z
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.