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 +4 -4
- data/lib/precursor.rb +1 -0
- data/lib/version.rb +1 -1
- data/lib/yaml_vault.rb +35 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbe652293d6dbc1fe13cd17330f59a9e37e36d89fa2ff60c4af4bba81d80598f
|
4
|
+
data.tar.gz: b98e83f130cf813c408c2fc416245f5a3b8cc16d58c17b0b9229db1c4c034f55
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9b30d56c17c3bf072687cce95343b49853c4ba57f90632694070c864adb7a5a1d2549556a2e086a843af554b1c1617c254cfa68c87b2df931a2689d8234d455c
|
7
|
+
data.tar.gz: 45f98b6fd91306ef418438968a98d4f2ad83a24160f31644f803c9cacad6d56ddb0aaf583cae4ec83436ebec921d810104a3bdc43af0a940c59077bc071a4b29
|
data/lib/precursor.rb
CHANGED
data/lib/version.rb
CHANGED
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.
|
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
|