appydays 0.3.1 → 0.5.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/configurable.rb +4 -1
- data/lib/appydays/dotenviable.rb +11 -1
- data/lib/appydays/loggable/sequel_logger.rb +2 -1
- data/lib/appydays/spec_helpers.rb +5 -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: ab72febd501e6dada1c4738598be500f24b98ab57183a8674e93e6622a82aaf4
|
4
|
+
data.tar.gz: c906e8cc5af47912035269aada22d832dfcb338079ac210207c2cfa26ac3bc64
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65b183daf0a109fe1dc95f06a4bb1e842489541fd1fab7ec1c2794766a664334dd53e8b7adb8da5a80446fffe46bad7ff41c8e6076465d4fea05182c0956906b
|
7
|
+
data.tar.gz: 4608508c05777a02fa77983b9d91cb597e4f995cd1b78af7ea363a301d91ec31245357f97610f658e25a577d9a96778a6fd5b798af3f62ef9a81cd6a8a450187
|
@@ -86,6 +86,8 @@ module Appydays::Configurable
|
|
86
86
|
# If convert is passed, that is used as the converter so the default value can be any type.
|
87
87
|
# key: The key to lookup the config value from the environment.
|
88
88
|
# If nil, use an auto-generated combo of the configuration key and method name.
|
89
|
+
# If key is an array, look up each (string) value as a key.
|
90
|
+
# The first non-nil (ie, `ENV.fetch(x, nil)`) value will be used.
|
89
91
|
# convert: If provided, call it with the string value so it can be parsed.
|
90
92
|
# For example, you can parse a string JSON value here.
|
91
93
|
# Convert will not be called with the default value.
|
@@ -106,7 +108,8 @@ module Appydays::Configurable
|
|
106
108
|
end
|
107
109
|
|
108
110
|
key ||= "#{@group_key}_#{name}".upcase
|
109
|
-
|
111
|
+
keys = Array(key)
|
112
|
+
env_value = keys.filter_map { |k| ENV.fetch(k, nil) }.first
|
110
113
|
converter = self._converter(default, convert)
|
111
114
|
value = env_value.nil? ? default : converter[env_value]
|
112
115
|
value = installer._set_value(name, value, side_effect)
|
data/lib/appydays/dotenviable.rb
CHANGED
@@ -9,8 +9,17 @@ require "appydays/version"
|
|
9
9
|
# (by convention, .env.<env>.local, .env.<env>, and .env).
|
10
10
|
#
|
11
11
|
# It can be called multiple times for the same environment.
|
12
|
+
# There are a couple special cases for RACK_ENV and PORT variables:
|
12
13
|
#
|
13
|
-
#
|
14
|
+
# RACK_ENV variable: Dotenviable defaults the $RACK_ENV variable to whatever
|
15
|
+
# is used for dotfile loading (ie, the `rack_env` or `default_rack_env` value).
|
16
|
+
# This avoids the surprising behavior where a caller does not have RACK_ENV set,
|
17
|
+
# they call +Dotenviable.load+, and RACK_ENV is still not set,
|
18
|
+
# though it had some implied usage within this method.
|
19
|
+
# If for some reason you do not want +ENV['RACK_ENV']+ to be set,
|
20
|
+
# you can store its value before calling `load` and set it back after.
|
21
|
+
#
|
22
|
+
# PORT variable: Foreman assigns the $PORT environment variable BEFORE we load config
|
14
23
|
# (get to what is defined in worker, like puma.rb), so even if we have it in the .env files,
|
15
24
|
# it won't get used, because .env files don't stomp what is already in the environment
|
16
25
|
# (we don't want to use `overload`).
|
@@ -26,5 +35,6 @@ module Appydays::Dotenviable
|
|
26
35
|
]
|
27
36
|
Dotenv.load(*paths)
|
28
37
|
env["PORT"] ||= original_port
|
38
|
+
env["RACK_ENV"] ||= rack_env
|
29
39
|
end
|
30
40
|
end
|
@@ -5,8 +5,9 @@ require "sequel/database/logging"
|
|
5
5
|
|
6
6
|
class Sequel::Database
|
7
7
|
def log_exception(exception, message)
|
8
|
+
level = message.match?(/^SELECT NULL AS "?nil"? FROM .* LIMIT 1$/i) ? :debug : :error
|
8
9
|
log_each(
|
9
|
-
|
10
|
+
level,
|
10
11
|
proc { "#{exception.class}: #{exception.message.strip if exception.message}: #{message}" },
|
11
12
|
proc { ["sequel_exception", {sequel_message: message}, exception] },
|
12
13
|
)
|
@@ -19,6 +19,8 @@ module Appydays::SpecHelpers
|
|
19
19
|
#
|
20
20
|
|
21
21
|
class HaveALineMatching
|
22
|
+
include RSpec::Matchers::Composable
|
23
|
+
|
22
24
|
def initialize(regexp)
|
23
25
|
@regexp = regexp
|
24
26
|
end
|
@@ -56,6 +58,8 @@ module Appydays::SpecHelpers
|
|
56
58
|
end
|
57
59
|
|
58
60
|
class MatchTime
|
61
|
+
include RSpec::Matchers::Composable
|
62
|
+
|
59
63
|
def initialize(expected)
|
60
64
|
@expected = expected
|
61
65
|
if expected == :now
|
@@ -70,6 +74,7 @@ module Appydays::SpecHelpers
|
|
70
74
|
def time(s)
|
71
75
|
return nil if s.nil?
|
72
76
|
return Time.parse(s) if s.is_a?(String)
|
77
|
+
return Time.at(s) if s.is_a?(Numeric)
|
73
78
|
return s.to_time
|
74
79
|
end
|
75
80
|
|
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.5.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: 2022-
|
11
|
+
date: 2022-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|