appydays 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/appydays/dotenviable.rb +17 -0
- data/lib/appydays/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: 191701f151a4b25333ee5f6cc1262e70c4d62dc063350bbebd4d00798cb2128e
|
4
|
+
data.tar.gz: 05d188d89e2db3047837f59784773284aa194f9435c2d6f83a8d8bc84b7c06d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd5f3a2c5ebfc6d172992e98ed34d6eb33a581b5ef3c55cb0744491cdb22274c9e519af561aba1014dedd68606be9b714e8c7bf5aa9d6deb4b849cbd7115ec1c
|
7
|
+
data.tar.gz: fd5c9afa41fa2d9ededce48760d147339029c29c21e9679e3d58cbf43f544419a95201634c8626413718da52eac91262fead6515361e2fd7017901e355ed5171
|
data/lib/appydays/dotenviable.rb
CHANGED
@@ -24,6 +24,13 @@ require "appydays/version"
|
|
24
24
|
# it won't get used, because .env files don't stomp what is already in the environment
|
25
25
|
# (we don't want to use `overload`).
|
26
26
|
# So we have some trickery to overwrite only PORT.
|
27
|
+
#
|
28
|
+
# @param rack_env [nil,String] Value like 'development' or 'production' to use to load .env files.
|
29
|
+
# If not given, use +env['RACK_ENV']+ or +default_rack_env+.
|
30
|
+
# @param default_rack_env [String] If +env['RACK_ENV']+ is not set, use this value.
|
31
|
+
# @param env [Hash] Hash to read and mutate.
|
32
|
+
# Pass in a different hash to load environment variables into it instead of ENV.
|
33
|
+
# Useful for testing, or to get the config for another environment.
|
27
34
|
module Appydays::Dotenviable
|
28
35
|
def self.load(rack_env: nil, default_rack_env: "development", env: ENV)
|
29
36
|
original_port = env.delete("PORT")
|
@@ -33,7 +40,17 @@ module Appydays::Dotenviable
|
|
33
40
|
".env.#{rack_env}",
|
34
41
|
".env",
|
35
42
|
]
|
43
|
+
orig_env = nil
|
44
|
+
if env.object_id != ENV.object_id
|
45
|
+
orig_env = ENV.to_h
|
46
|
+
ENV.replace(env)
|
47
|
+
end
|
36
48
|
Dotenv.load(*paths)
|
49
|
+
if orig_env
|
50
|
+
env.merge!(ENV)
|
51
|
+
ENV.replace(orig_env)
|
52
|
+
end
|
53
|
+
|
37
54
|
env["PORT"] ||= original_port
|
38
55
|
env["RACK_ENV"] ||= rack_env
|
39
56
|
end
|
data/lib/appydays/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: appydays
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lithic Tech
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|