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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 26d7ecee28ecca4444ab9b42c7f98a0a429783fcb4692dbf13db06d30382bbef
4
- data.tar.gz: e4775687f169d0171b5b9ab97afb0b676a0222bc90046862e4cddb248d715145
3
+ metadata.gz: 409e3b9c102f85c26c55bec5aee42ab024fd8c6ade9b20f5cb54bb9c178a64fe
4
+ data.tar.gz: 0c783a29e26d3fcb7472c868976528950f921599390ca8e58f7c92394b210228
5
5
  SHA512:
6
- metadata.gz: e338eb5b0dc2b621d66a1370c10f5080218a949c8dbf1ab1f6729b37bc48dc60288cbb09f8467898b4ccf2e496d2f8bc5a76323b27e450e3e764749b80549021
7
- data.tar.gz: 5849a2224c0f9a436d323e868d7e69f4105d3d9c088b4c67846e886536caf35b78fbdf81946a392c5eb90094696f52e42bf80d199852999e5e248b4de501fdc2
6
+ metadata.gz: 9ae56a1eedef1509142f30dca684398b734b8da5b7d17b1c050ff601ebcfa0be58b3fcb2c7b067308a1884233b3e8453f1e89a855147fa19d96182dd9fd93c96
7
+ data.tar.gz: 85f6bae4579b1755de739279f9a30ed5e62bb6bb2e1944eed482960e2507312ea2606acd73cf65fe8c27d7eaf823259650452a71eb23979bbb9f70b50a6307c7
@@ -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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- knowledge (0.1.0)
4
+ knowledge (0.1.2)
5
5
  dry-configurable (~> 0.7)
6
6
 
7
7
  GEM
@@ -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
- setter.set(name: name_in_project, value: ENV[name_in_env.to_s])
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
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Knowledge
4
- VERSION = '0.1.1'.freeze
4
+ VERSION = '0.1.2'.freeze
5
5
  end
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.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-08 00:00:00.000000000 Z
11
+ date: 2018-12-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dry-configurable