knowledge 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +29 -0
- data/Gemfile.lock +1 -1
- data/lib/knowledge/adapters/environment.rb +25 -2
- data/lib/knowledge/exceptions.rb +7 -0
- data/lib/knowledge/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 409e3b9c102f85c26c55bec5aee42ab024fd8c6ade9b20f5cb54bb9c178a64fe
|
4
|
+
data.tar.gz: 0c783a29e26d3fcb7472c868976528950f921599390ca8e58f7c92394b210228
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ae56a1eedef1509142f30dca684398b734b8da5b7d17b1c050ff601ebcfa0be58b3fcb2c7b067308a1884233b3e8453f1e89a855147fa19d96182dd9fd93c96
|
7
|
+
data.tar.gz: 85f6bae4579b1755de739279f9a30ed5e62bb6bb2e1944eed482960e2507312ea2606acd73cf65fe8c27d7eaf823259650452a71eb23979bbb9f70b50a6307c7
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,34 @@
|
|
1
1
|
# Knowledge - Changelog
|
2
2
|
|
3
|
+
## 0.1.2 - 2018-12-15
|
4
|
+
|
5
|
+
### Added
|
6
|
+
|
7
|
+
- Ability to set default value while using `Knowledge::Adapters::Environment`
|
8
|
+
- Ability to raise error when env var not found
|
9
|
+
|
10
|
+
### Changed
|
11
|
+
|
12
|
+
Nothing
|
13
|
+
|
14
|
+
### Removed
|
15
|
+
|
16
|
+
Nothing
|
17
|
+
|
18
|
+
## 0.1.1 - 2018-12-08
|
19
|
+
|
20
|
+
### Added
|
21
|
+
|
22
|
+
- Backup feature
|
23
|
+
|
24
|
+
### Changed
|
25
|
+
|
26
|
+
- Comments / Generated YARD doc improved
|
27
|
+
|
28
|
+
### Removed
|
29
|
+
|
30
|
+
Nothing
|
31
|
+
|
3
32
|
## 0.1.0 - 2018-12-01
|
4
33
|
|
5
34
|
### Added
|
data/Gemfile.lock
CHANGED
@@ -25,15 +25,38 @@ module Knowledge
|
|
25
25
|
# @attr_reader [Hash] variables
|
26
26
|
#
|
27
27
|
class Environment < Base
|
28
|
+
# == Constructor =================================================================================================
|
29
|
+
|
30
|
+
#
|
31
|
+
# Just initializes instance variables with given params
|
32
|
+
#
|
33
|
+
# === Parameters
|
34
|
+
#
|
35
|
+
# @param :variables [Hash]
|
36
|
+
# @param :setter [Class]
|
37
|
+
# @param :params [Hash]
|
38
|
+
# @option :params [Boolean] :raise_on_value_not_found
|
39
|
+
#
|
40
|
+
def initialize(variables:, setter:, params: {})
|
41
|
+
super
|
42
|
+
|
43
|
+
@raise_not_found = params[:raise_on_value_not_found] || params['raise_on_value_not_found'] || false
|
44
|
+
end
|
45
|
+
|
28
46
|
# == Instance Methods ============================================================================================
|
29
47
|
|
30
48
|
#
|
31
49
|
# Runs the actual adapter.
|
32
50
|
#
|
33
51
|
def run
|
34
|
-
variables.each do |name_in_project, name_in_env|
|
35
|
-
|
52
|
+
variables.each do |name_in_project, (name_in_env, default_value)|
|
53
|
+
value = @raise_not_found ? ENV.fetch(name_in_env.to_s) : ENV.fetch(name_in_env.to_s) { default_value }
|
54
|
+
|
55
|
+
setter.set(name: name_in_project, value: value)
|
36
56
|
end
|
57
|
+
|
58
|
+
rescue ::KeyError => e
|
59
|
+
raise ::Knowledge::ValueNotFound, "[#{e.class}]: #{e.message}"
|
37
60
|
end
|
38
61
|
end
|
39
62
|
end
|
data/lib/knowledge/exceptions.rb
CHANGED
@@ -44,4 +44,11 @@ module Knowledge
|
|
44
44
|
# This error is used when we fail registering an adapter.
|
45
45
|
#
|
46
46
|
class RegisterError < Error; end
|
47
|
+
|
48
|
+
#
|
49
|
+
# === Description
|
50
|
+
#
|
51
|
+
# This error is used when an adapter cannot find the value of a variable
|
52
|
+
#
|
53
|
+
class ValueNotFound < Error; end
|
47
54
|
end
|
data/lib/knowledge/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knowledge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johann Wilfrid-Calixte
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-configurable
|