nitro_config 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d2106328cb7a570bf8f1be2906373b809cefde5e04f23f6a304f29c5a0326e72
4
- data.tar.gz: a91b2f3fd1fb4094d0355d7f5f1143ee5e093f94766be229b1166771d7fe4579
3
+ metadata.gz: b383168080e40e84e5ddced9ee9a956bb7b86c90eb90b69980deebd33ab01827
4
+ data.tar.gz: b49df3dee2c71b884a8a8dd315626d01ab1f2f6fb6a6a0ab1c700bd13f83d516
5
5
  SHA512:
6
- metadata.gz: 5af554d4c85dd235f48be6fc2a4e35763bf86fd48903ab7419814fbbf7701cd0c55db8ea826bfdacff26731f2c63e7e55db2694e5c114519d19a4f171737d45f
7
- data.tar.gz: ccb35797f5102f1888ba4ef6f9a78bb3241e00f8d293584cb838a04572438f713b2ea53497986baf801eb9717404e77c902d44f4695da0259347fe015f9f276e
6
+ metadata.gz: 4afcc350cee4f6635691404ca3232c6b530780889b0f3ba067448534c4a8d1f4d860f50da01a3b9404b54a7519fd3a2b84ac30bb3a98a957d6c393271c1c5aff
7
+ data.tar.gz: 9651578ae8f6e6c418ecf6bffd6cdc3d004d5f1b52eb1f2385d71bdfa1f0e077af9d789d1a70793a2ce705255d3def5b44ea1b75942956ff4de497a849b0adef
data/config/config.yml CHANGED
@@ -1,4 +1,6 @@
1
1
  base: &base
2
+ another:
3
+ config: <%= "vrum " * 10 %>
2
4
  key:
3
5
  nested:
4
6
  value: "Hello World"
data/docs/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.0] - 2022-08-29
4
+
5
+ - Parse ERb from loaded config
6
+
3
7
  ## [0.1.1] - 2022-07-28
4
8
 
5
9
  - Support multiple versions of rails (>= 5.2.8.1)
data/docs/README.md CHANGED
@@ -22,6 +22,8 @@ Given the following example config file, the following examples demonstrate how
22
22
  base: &base
23
23
  some:
24
24
  nested: value
25
+ service:
26
+ api: <%= ENV.fetch("SERVICE_API_URL", "http://localhost:3000/api") %>
25
27
 
26
28
  development:
27
29
  <<: *base
@@ -43,9 +45,15 @@ test:
43
45
  [3] pry(main)> NitroConfig.config.get!('some/other')
44
46
  NitroConfig::Error: some/other not found in app config!
45
47
  from /Users/ben/code/power/nitro/components/nitro_config/lib/nitro_config/options.rb:20:in `block in get!'
46
- [2] pry(main)> NitroConfig.config.get('some/other', 'default')
48
+ [4] pry(main)> NitroConfig.config.get('some/other', 'default')
47
49
  => "default"
50
+ [5] pry(main)> NitroConfig.config.get('service/api')
51
+ => "http://localhost:3000/api"
48
52
 
49
53
  $ RAILS_ENV=test rails c
50
54
  [1] pry(main)> NitroConfig.config.get('some/nested')
51
55
  => "testvalue"
56
+
57
+ $ SERVICE_API_URL="http://test.com" rails c
58
+ [1] pry(main)> NitroConfig.config.get('service/api')
59
+ => "http://test.com"
@@ -9,11 +9,13 @@ module NitroConfig
9
9
  # Representation of a config key-value tree with path-based access
10
10
  class Options < HashWithIndifferentAccess
11
11
  def self.load_yml(path, environment)
12
+ erb_result = ::ERB.new(File.read(path)).result
12
13
  yaml = begin
13
- YAML.load_file(path, aliases: true)
14
+ YAML.safe_load(erb_result, [], [], true)
14
15
  rescue ArgumentError
15
- YAML.load_file(path)
16
+ YAML.safe_load(erb_result, aliases: true)
16
17
  end
18
+
17
19
  new(yaml[environment])
18
20
  end
19
21
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module NitroConfig
4
- VERSION = "0.1.1"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nitro_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carlos Palhares
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2022-08-01 00:00:00.000000000 Z
12
+ date: 2022-08-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport