dotenvx 4.0.4-x86_64-linux → 4.0.5-x86_64-linux
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/lib/dotenvx/dotenvx_native.so +0 -0
- data/lib/dotenvx/version.rb +1 -1
- data/lib/dotenvx.rb +40 -9
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eed8288974a56e99bb64dc3c42e68a8e29b6fe7dfc28ac2509a6c34ec6c9cdfe
|
|
4
|
+
data.tar.gz: 248c383166ac9a268f2ea1724cf733eaf7bb71587e297662bf7fe518b558f8a5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d378737dbc885ce124e8072a846234a2c08f15be242b84aace2deabdd70c2818d47c31fb3eae4f2e8ba843fc86fba6628a5d6fac79d5ac423f458c2ee392b815
|
|
7
|
+
data.tar.gz: 0060ab3dc3fdc4c6ae2a61d8eaecd9bbdb355a76a0bff013634a667989bfd2652fb08437ab229b15a1a5dad16b71fb39c12acef00ee9fc34dc9fa9a39ca35803
|
data/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
-
## [Unreleased](https://github.com/dotenvx/dotenvx-ruby/compare/v4.0.
|
|
5
|
+
## [Unreleased](https://github.com/dotenvx/dotenvx-ruby/compare/v4.0.5...main)
|
|
6
|
+
|
|
7
|
+
## [4.0.5](https://github.com/dotenvx/dotenvx-ruby/compare/v4.0.4...v4.0.5)
|
|
8
|
+
|
|
9
|
+
- Continue after parse and decryption errors by default, with strict and
|
|
10
|
+
error-code ignore options for callers that need them.
|
|
6
11
|
|
|
7
12
|
## [4.0.4](https://github.com/dotenvx/dotenvx-ruby/compare/v4.0.3...v4.0.4)
|
|
8
13
|
|
|
Binary file
|
data/lib/dotenvx/version.rb
CHANGED
data/lib/dotenvx.rb
CHANGED
|
@@ -13,14 +13,24 @@ module Dotenvx
|
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
class ParseError < RuntimeError
|
|
17
|
+
attr_reader :code
|
|
18
|
+
|
|
19
|
+
def initialize(code, message)
|
|
20
|
+
@code = code
|
|
21
|
+
super(message)
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
16
25
|
class << self
|
|
17
26
|
attr_accessor :instrumenter
|
|
18
27
|
|
|
19
|
-
def load(*filenames, overwrite: false, ignore: true)
|
|
28
|
+
def load(*filenames, overwrite: false, ignore: true, strict: false)
|
|
20
29
|
env, injected_keys, loaded_paths = parse_files(
|
|
21
30
|
*filenames,
|
|
22
31
|
overwrite: overwrite,
|
|
23
|
-
ignore: ignore
|
|
32
|
+
ignore: ignore,
|
|
33
|
+
strict: strict
|
|
24
34
|
)
|
|
25
35
|
changed = update(env, overwrite: overwrite)
|
|
26
36
|
log_injected(injected_keys, loaded_paths)
|
|
@@ -28,7 +38,7 @@ module Dotenvx
|
|
|
28
38
|
end
|
|
29
39
|
|
|
30
40
|
def load!(*filenames)
|
|
31
|
-
load(*filenames, ignore: false)
|
|
41
|
+
load(*filenames, ignore: false, strict: true)
|
|
32
42
|
end
|
|
33
43
|
|
|
34
44
|
def overwrite(*filenames)
|
|
@@ -37,12 +47,17 @@ module Dotenvx
|
|
|
37
47
|
alias overload overwrite
|
|
38
48
|
|
|
39
49
|
def overwrite!(*filenames)
|
|
40
|
-
load(*filenames, overwrite: true, ignore: false)
|
|
50
|
+
load(*filenames, overwrite: true, ignore: false, strict: true)
|
|
41
51
|
end
|
|
42
52
|
alias overload! overwrite!
|
|
43
53
|
|
|
44
|
-
def parse(*filenames, overwrite: false, ignore: true)
|
|
45
|
-
parse_files(
|
|
54
|
+
def parse(*filenames, overwrite: false, ignore: true, strict: false)
|
|
55
|
+
parse_files(
|
|
56
|
+
*filenames,
|
|
57
|
+
overwrite: overwrite,
|
|
58
|
+
ignore: ignore,
|
|
59
|
+
strict: strict
|
|
60
|
+
).first
|
|
46
61
|
end
|
|
47
62
|
|
|
48
63
|
def update(env = {}, overwrite: false)
|
|
@@ -72,7 +87,7 @@ module Dotenvx
|
|
|
72
87
|
|
|
73
88
|
private
|
|
74
89
|
|
|
75
|
-
def parse_files(*filenames, overwrite: false, ignore: true)
|
|
90
|
+
def parse_files(*filenames, overwrite: false, ignore: true, strict: false)
|
|
76
91
|
filenames = [".env"] if filenames.empty?
|
|
77
92
|
filenames = filenames.flatten.reverse if overwrite
|
|
78
93
|
|
|
@@ -84,16 +99,17 @@ module Dotenvx
|
|
|
84
99
|
begin
|
|
85
100
|
source = File.binread(path).sub(/\A\xEF\xBB\xBF/, "").force_encoding(Encoding::UTF_8)
|
|
86
101
|
rescue Errno::ENOENT, Errno::EISDIR
|
|
87
|
-
raise unless ignore
|
|
102
|
+
raise unless ignore_missing?(ignore)
|
|
88
103
|
next accumulator
|
|
89
104
|
end
|
|
90
105
|
|
|
91
|
-
parsed, injected = Native.parse_dotenv(JSON.generate(
|
|
106
|
+
parsed, injected, errors = Native.parse_dotenv(JSON.generate(
|
|
92
107
|
source: source,
|
|
93
108
|
process_env: process_env,
|
|
94
109
|
overwrite: overwrite == true,
|
|
95
110
|
key_files: key_files(path)
|
|
96
111
|
))
|
|
112
|
+
handle_errors(errors, ignore: ignore, strict: strict)
|
|
97
113
|
parsed = parsed.to_h
|
|
98
114
|
injected.each { |key, _value| injected_keys[key] = true }
|
|
99
115
|
loaded_paths << path
|
|
@@ -105,6 +121,21 @@ module Dotenvx
|
|
|
105
121
|
[values, injected_keys.keys, loaded_paths]
|
|
106
122
|
end
|
|
107
123
|
|
|
124
|
+
def handle_errors(errors, ignore:, strict:)
|
|
125
|
+
ignored_codes = Array(ignore).grep(String)
|
|
126
|
+
errors.each do |code, message|
|
|
127
|
+
next if ignored_codes.include?(code)
|
|
128
|
+
|
|
129
|
+
raise ParseError.new(code, message) if strict
|
|
130
|
+
|
|
131
|
+
warn "☠ #{message}"
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
135
|
+
def ignore_missing?(ignore)
|
|
136
|
+
ignore == true || Array(ignore).map(&:to_s).include?("MISSING_ENV_FILE")
|
|
137
|
+
end
|
|
138
|
+
|
|
108
139
|
def log_injected(injected_keys, loaded_paths)
|
|
109
140
|
message = "⟐ injected env (#{injected_keys.length})"
|
|
110
141
|
unless loaded_paths.empty?
|