conf_loader 2.0.0 → 2.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
- SHA1:
3
- metadata.gz: 0faf9108d7e238f50b273199aaffa4170995a137
4
- data.tar.gz: 19433f3f3b1595f0f1f1ed2f1c05bb8b381ff9de
2
+ SHA256:
3
+ metadata.gz: c82b9ec01e8a0a4b07b9714a1eaa35f4043c17e08b0c2ccce45df79ab8c3750e
4
+ data.tar.gz: e8a6aad65c5d641d972aac4b61921f96e65e2823b1e266c45bb6eaebe9bde363
5
5
  SHA512:
6
- metadata.gz: 8598f2926e6902f67cf6b9e4332cb1d90d7246dea1d64ed81257290223473cc25af0128314b846322f80b379016b06b752760bd5656936e5a37d8ac0e0edc50c
7
- data.tar.gz: 9f2b2b29c155fd56514fdb7a113794f6cd60e3d3f37501439fdbb5e55a042b2fe793018cc1e33091d9478a42e4ba146c2003cda97d16ec7ef15541c1fcd46220
6
+ metadata.gz: fb93f7a857e5d261942b4a4ff4faf32098ba02788fe2c4533bbab8b581c4a2202c6334fea4fff2e1be41b8f21d409786afe5e518304fd07203a5abded5e51c2c
7
+ data.tar.gz: add4a26b151f6b080cd282598c2181361636b69fc26eff5770641a16941ded9b4645d43c74952fbaa8513323ca26625c942aeba43e998e697e450c5269967453
@@ -0,0 +1,22 @@
1
+ name: Publish Gem
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ jobs:
8
+ build:
9
+ runs-on: ubuntu-latest
10
+
11
+ steps:
12
+ - uses: actions/checkout@v2
13
+ with:
14
+ fetch-depth: 2
15
+
16
+
17
+ - name: Release Gem
18
+ uses: discourse/publish-rubygems-action@b55d7b91b55e61752dc6cbc2972f8e16fe6c1a02
19
+ env:
20
+ GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
21
+ RUBYGEMS_API_KEY: ${{secrets.RUBYGEMS_API_KEY}}
22
+ RELEASE_COMMAND: rake release
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 2.2
1
+ 2.7.2
@@ -1,3 +1,3 @@
1
1
  class ConfLoader
2
- VERSION = '2.0.0'
2
+ VERSION = '2.2.0'
3
3
  end
data/lib/conf_loader.rb CHANGED
@@ -21,7 +21,9 @@ class ConfLoader
21
21
  # @api public
22
22
  def self.load(path, env)
23
23
  template = ERB.new File.new(path).read
24
- environments = YAML.load template.result(binding)
24
+ source = template.result(binding)
25
+
26
+ environments = load_environments(source)
25
27
 
26
28
  if environments.has_key?(env)
27
29
  hash = environments[env]
@@ -38,6 +40,16 @@ class ConfLoader
38
40
 
39
41
  private_class_method
40
42
 
43
+ if Gem::Version.new(RUBY_VERSION).release >= Gem::Version.new('3.1.0')
44
+ def self.load_environments(source)
45
+ YAML.load(source, aliases: true)
46
+ end
47
+ else
48
+ def self.load_environments(source)
49
+ YAML.load(source)
50
+ end
51
+ end
52
+
41
53
  def self.guarantee_key_presence(hash)
42
54
  hash.default_proc = proc do |h, k|
43
55
  raise KeyError, "#{k} not defined"
@@ -46,11 +58,11 @@ class ConfLoader
46
58
  end
47
59
 
48
60
  def self.check_value_presence(hash)
49
- errors = check_values_not_empty(hash)
50
- if errors.empty?
61
+ error_keys = check_values_not_empty(hash)
62
+ if error_keys.empty?
51
63
  hash
52
64
  else
53
- raise ValueNotDefinedError, errors.join(', ')
65
+ raise ValueNotDefinedError, "Undefined keys: #{error_keys.join(', ')}"
54
66
  end
55
67
  end
56
68
 
@@ -58,9 +70,9 @@ class ConfLoader
58
70
  hash.inject([]) do |acc, (key, value)|
59
71
  errors =
60
72
  if value.is_a?(Hash)
61
- check_values_not_empty(value)
73
+ check_values_not_empty(value).map { |child_key| "#{key}.#{child_key}" }
62
74
  elsif value.to_s.empty?
63
- ["#{key} value not defined"]
75
+ [key]
64
76
  else
65
77
  []
66
78
  end
@@ -15,3 +15,5 @@ invalid:
15
15
  empty_value: ''
16
16
  nested_field:
17
17
  nested_empty_value: ''
18
+ nested_empty_value2: ''
19
+ nested_non_empty_value: 'non-empty'
@@ -64,7 +64,7 @@ describe ConfLoader do
64
64
  it 'raises ValueNotDefinedError' do
65
65
  expect{conf}.to raise_error(
66
66
  described_class::ValueNotDefinedError,
67
- 'empty_value value not defined, nested_empty_value value not defined'
67
+ 'Undefined keys: empty_value, nested_field.nested_empty_value, nested_field.nested_empty_value2'
68
68
  )
69
69
  end
70
70
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conf_loader
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Indrek Juhkam
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-24 00:00:00.000000000 Z
11
+ date: 2023-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: symbolizer
@@ -31,6 +31,7 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
+ - ".github/workflows/publish.yml"
34
35
  - ".gitignore"
35
36
  - ".ruby-gemset"
36
37
  - ".ruby-version"
@@ -65,8 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
66
  - !ruby/object:Gem::Version
66
67
  version: '0'
67
68
  requirements: []
68
- rubyforge_project:
69
- rubygems_version: 2.6.7
69
+ rubygems_version: 3.1.4
70
70
  signing_key:
71
71
  specification_version: 4
72
72
  summary: Helps to load conf files in SaleMove ecosystem