precursor 0.2.0 → 0.3.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: a330cda13b62eafd9c37e48f3d0e5fee928b9d0ac4e1a1a034f4b2df6cb8c3ef
4
- data.tar.gz: 1c36ffb97fdd50bfebd093db7ca61c2ae9fe83c1b5b6f835c733acec986da79d
3
+ metadata.gz: dbe652293d6dbc1fe13cd17330f59a9e37e36d89fa2ff60c4af4bba81d80598f
4
+ data.tar.gz: b98e83f130cf813c408c2fc416245f5a3b8cc16d58c17b0b9229db1c4c034f55
5
5
  SHA512:
6
- metadata.gz: fcfb70401efcfcf80cb2f988c0b796b0f501d34da997ac4adb59d1f3969186b7093d76825f8a7889393acaa80eb5c04ca56cf7633d6567bc480449774f6ee4e6
7
- data.tar.gz: 24f13b6e7911b0197250a6af8fdc936ef84c67dc6f3abe11c530b62fb20e728495fdb45208d08304ee03508e3ce3bdb2aa65d6f40fef2e2345de57ee68c56feb
6
+ metadata.gz: 9b30d56c17c3bf072687cce95343b49853c4ba57f90632694070c864adb7a5a1d2549556a2e086a843af554b1c1617c254cfa68c87b2df931a2689d8234d455c
7
+ data.tar.gz: 45f98b6fd91306ef418438968a98d4f2ad83a24160f31644f803c9cacad6d56ddb0aaf583cae4ec83436ebec921d810104a3bdc43af0a940c59077bc071a4b29
data/lib/precursor.rb CHANGED
@@ -3,6 +3,7 @@
3
3
  require_relative 'config_root_builder'
4
4
 
5
5
  require_relative 'env_vault'
6
+ require_relative 'yaml_vault'
6
7
 
7
8
  module Precursor
8
9
  class << self
data/lib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Precursor
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
data/lib/yaml_vault.rb ADDED
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'yaml'
4
+
5
+ require_relative 'vault'
6
+
7
+ module Precursor
8
+ class YamlVault < Vault
9
+ def initialize(src)
10
+ @yaml = flat_hash(YAML.load(src))
11
+ end
12
+
13
+ def key?(key)
14
+ @yaml.key? key
15
+ end
16
+
17
+ def value(key)
18
+ @yaml[key]
19
+ end
20
+
21
+ private
22
+
23
+ def flat_hash(hash, prefix = nil)
24
+ flat_hash = hash.flat_map do |k, v|
25
+ k = "#{prefix}.#{k}" unless prefix.nil?
26
+ if v.is_a? Hash
27
+ flat_hash(v, k)
28
+ else
29
+ { k => v }
30
+ end
31
+ end
32
+ flat_hash.reduce(:merge).transform_keys { |k| k.to_sym }
33
+ end
34
+ end
35
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: precursor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Maraev
@@ -38,6 +38,7 @@ files:
38
38
  - lib/precursor.rb
39
39
  - lib/vault.rb
40
40
  - lib/version.rb
41
+ - lib/yaml_vault.rb
41
42
  homepage: https://github.com/the-vk/precursor
42
43
  licenses:
43
44
  - MIT