eco-helpers 3.0.37 → 3.1.1
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/.rubocop.yml +1 -0
- data/CHANGELOG.md +116 -1
- data/lib/eco/api/common/loaders/base.rb +2 -2
- data/lib/eco/api/common/loaders/case_base.rb +2 -0
- data/lib/eco/api/common/loaders/config/block.rb +78 -0
- data/lib/eco/api/common/loaders/config/workflow/mailer.rb +39 -7
- data/lib/eco/api/common/loaders/config.rb +3 -26
- data/lib/eco/api/common/loaders/error_handler.rb +2 -0
- data/lib/eco/api/common/loaders/parser.rb +1 -4
- data/lib/eco/api/common/people/entries.rb +23 -6
- data/lib/eco/api/common/people/entry_factory.rb +1 -1
- data/lib/eco/api/common/people/person_entry.rb +104 -27
- data/lib/eco/api/common/people/person_parser.rb +50 -16
- data/lib/eco/api/common/people/supervisor_helpers.rb +12 -6
- data/lib/eco/api/common/session/base_session.rb +75 -81
- data/lib/eco/api/common/session/environment.rb +49 -55
- data/lib/eco/api/common/session/file_manager.rb +132 -135
- data/lib/eco/api/common/session/helpers/prompt_user.rb +23 -30
- data/lib/eco/api/common/session/helpers.rb +10 -15
- data/lib/eco/api/common/session/logger/cache.rb +89 -96
- data/lib/eco/api/common/session/logger/channels.rb +24 -32
- data/lib/eco/api/common/session/logger/log.rb +38 -46
- data/lib/eco/api/common/session/logger.rb +50 -54
- data/lib/eco/api/common/session/mailer/aws_provider.rb +63 -71
- data/lib/eco/api/common/session/mailer/provider_base.rb +43 -48
- data/lib/eco/api/common/session/mailer/sendgrid_provider.rb +101 -109
- data/lib/eco/api/common/session/mailer.rb +78 -83
- data/lib/eco/api/common/session/s3_uploader.rb +132 -138
- data/lib/eco/api/common/session/sftp.rb +202 -208
- data/lib/eco/api/common.rb +0 -3
- data/lib/eco/api/custom/mailer.rb +4 -2
- data/lib/eco/api/error/handlers.rb +1 -1
- data/lib/eco/api/microcases/people/apply_changes/set_core/core_excluded.rb +8 -2
- data/lib/eco/api/microcases/people/manage/search.rb +1 -1
- data/lib/eco/api/organization/people/similarity.rb +3 -3
- data/lib/eco/api/session/batch/base_policy.rb +42 -27
- data/lib/eco/api/session/batch/launcher/mode_size.rb +6 -1
- data/lib/eco/api/session/batch/launcher.rb +16 -3
- data/lib/eco/api/session/config/api.rb +4 -3
- data/lib/eco/api/session/config/apis/one_off.rb +1 -1
- data/lib/eco/api/session/config/files.rb +13 -12
- data/lib/eco/api/session/config/workflow.rb +1 -373
- data/lib/eco/api/session/config.rb +30 -9
- data/lib/eco/api/usecases/base_case/model.rb +6 -6
- data/lib/eco/api/usecases/base_case.rb +1 -1
- data/lib/eco/api/usecases/cli.rb +1 -1
- data/lib/eco/api/usecases/default/locations/tagtree_extract_case.rb +8 -9
- data/lib/eco/api/usecases/default_cases/to_csv_case.rb +4 -1
- data/lib/eco/api/usecases/graphql/samples/location/command/dsl.rb +2 -2
- data/lib/eco/api/usecases/lib/base/env.rb +21 -23
- data/lib/eco/api/usecases/lib/files/file_pattern.rb +41 -14
- data/lib/eco/api/usecases/lib/files/input_file.rb +110 -0
- data/lib/eco/api/usecases/lib/files/sftp.rb +5 -2
- data/lib/eco/api/usecases/lib/files.rb +1 -0
- data/lib/eco/api/usecases/lib/locations/base.rb +23 -0
- data/lib/eco/api/usecases/lib/locations/mapping.rb +94 -0
- data/lib/eco/api/usecases/lib/locations.rb +7 -0
- data/lib/eco/api/usecases/lib/people/base.rb +20 -0
- data/lib/eco/api/usecases/lib/people.rb +6 -0
- data/lib/eco/api/usecases/lib.rb +2 -0
- data/lib/eco/api/usecases/ooze_cases.rb +1 -1
- data/lib/eco/api/usecases/ooze_samples/register_export_case.rb +1 -0
- data/lib/eco/api/usecases/ooze_samples/register_update_case.rb +1 -0
- data/lib/eco/api/usecases/samples/drivers/sftp_sample.rb +2 -0
- data/lib/eco/api/usecases/samples/drivers/url_pull_sample.rb +8 -2
- data/lib/eco/api/usecases/service/sftp/with_target_config.rb +0 -33
- data/lib/eco/api/usecases/service/sftp.rb +7 -1
- data/lib/eco/api/usecases/use_case.rb +3 -2
- data/lib/eco/api/usecases/workflow.rb +5 -0
- data/lib/eco/api/usecases.rb +12 -5
- data/lib/eco/cli/scripting/args_helpers.rb +1 -9
- data/lib/eco/cli_default/options.rb +98 -68
- data/lib/eco/cli_default/workflow/end.rb +22 -0
- data/lib/eco/cli_default/workflow/launch_jobs.rb +14 -0
- data/lib/eco/cli_default/workflow/load/data.rb +27 -0
- data/lib/eco/cli_default/workflow/load/input.rb +28 -0
- data/lib/eco/cli_default/workflow/load.rb +13 -0
- data/lib/eco/cli_default/workflow/options.rb +10 -0
- data/lib/eco/cli_default/workflow/post_launch.rb +65 -0
- data/lib/eco/cli_default/workflow/report.rb +17 -0
- data/lib/eco/cli_default/workflow/rescued_exception.rb +21 -0
- data/lib/eco/cli_default/workflow/usecases.rb +23 -0
- data/lib/eco/cli_default/workflow.rb +24 -180
- data/lib/eco/data/count_trace.rb +51 -0
- data/lib/eco/data/files/content.rb +39 -0
- data/lib/eco/data/files/directory.rb +78 -45
- data/lib/eco/data/files/encoding.rb +12 -21
- data/lib/eco/data/files/file_pattern.rb +15 -8
- data/lib/eco/data/files/folder.rb +196 -0
- data/lib/eco/data/files/relative_path.rb +54 -0
- data/lib/eco/data/files/timestamp.rb +18 -0
- data/lib/eco/data/files.rb +46 -5
- data/lib/eco/data/fuzzy_match.rb +1 -1
- data/lib/eco/data/hashes/array_diff.rb +11 -5
- data/lib/eco/data/hashes/diff_result/meta.rb +12 -4
- data/lib/eco/data/locations/node_diff/accessors.rb +1 -1
- data/lib/eco/data/mapper.rb +5 -1
- data/lib/eco/data.rb +1 -0
- data/lib/eco/language/delegation/delegating_missing.rb +1 -1
- data/lib/eco/language/delegation/delegating_missing_const.rb +1 -1
- data/lib/eco/language/delegation/delegating_missing_on_class.rb +1 -1
- data/lib/eco/language/delegation/for_delegator/delegated_class.rb +1 -1
- data/lib/eco/language/klass/auto_loader.rb +129 -0
- data/lib/eco/language/klass/builder.rb +6 -6
- data/lib/eco/language/klass/const.rb +19 -0
- data/lib/eco/language/klass/helpers_built.rb +3 -1
- data/lib/eco/language/klass/hierarchy.rb +5 -1
- data/lib/eco/language/klass/naming.rb +5 -2
- data/lib/eco/language/klass/resolver.rb +21 -6
- data/lib/eco/language/klass/uid.rb +12 -0
- data/lib/eco/language/klass/when_inherited.rb +30 -6
- data/lib/eco/language/klass.rb +5 -2
- data/lib/eco/language/methods/access_modifier.rb +23 -0
- data/lib/eco/language/methods/instance_method_helpers.rb +6 -1
- data/lib/eco/language/methods.rb +1 -0
- data/lib/eco/language/models/hierarchy.rb +41 -0
- data/lib/eco/language/models/workflow.rb +385 -0
- data/lib/eco/language/models.rb +2 -1
- data/lib/eco/version.rb +1 -1
- metadata +31 -7
- data/lib/eco/api/common/class_auto_loader.rb +0 -114
- data/lib/eco/api/common/class_helpers.rb +0 -9
- data/lib/eco/api/common/class_hierarchy.rb +0 -45
- data/lib/eco/data/files/helpers.rb +0 -152
- data/lib/eco/language/models/class_helpers.rb +0 -136
@@ -1,43 +1,35 @@
|
|
1
|
-
|
2
|
-
module
|
3
|
-
|
4
|
-
module Session
|
5
|
-
class Logger
|
6
|
-
module Channels
|
7
|
-
CHANNELS = %i[general].freeze
|
1
|
+
class Eco::API::Common::Session::Logger
|
2
|
+
module Channels
|
3
|
+
CHANNELS = %i[general].freeze
|
8
4
|
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
class << self
|
6
|
+
def included(base)
|
7
|
+
super
|
12
8
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
module ClassMethods
|
18
|
-
def channels!(&def_block)
|
19
|
-
str = 'Block with channel implementation expected. None given.'
|
20
|
-
raise ArgumentError, str unless block_given?
|
21
|
-
|
22
|
-
channels.each do |channel|
|
23
|
-
meth = channel.to_s.downcase.to_sym
|
9
|
+
base.extend ClassMethods
|
10
|
+
end
|
11
|
+
end
|
24
12
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
13
|
+
module ClassMethods
|
14
|
+
def channels!(&def_block)
|
15
|
+
str = 'Block with channel implementation expected. None given.'
|
16
|
+
raise ArgumentError, str unless block_given?
|
31
17
|
|
32
|
-
|
18
|
+
channels.each do |channel|
|
19
|
+
meth = channel.to_s.downcase.to_sym
|
33
20
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
end
|
21
|
+
define_method(meth) do |msg = nil, &block|
|
22
|
+
# `block` instead of `&block`
|
23
|
+
instance_exec(meth, msg, block, &def_block)
|
38
24
|
end
|
39
25
|
end
|
40
26
|
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def channels
|
31
|
+
self::CHANNELS
|
32
|
+
end
|
41
33
|
end
|
42
34
|
end
|
43
35
|
end
|
@@ -1,49 +1,41 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
return value if value.is_a?(Time)
|
40
|
-
return unless value
|
41
|
-
|
42
|
-
Time.parse(value)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
1
|
+
class Eco::API::Common::Session::Logger
|
2
|
+
class Log
|
3
|
+
attr_accessor :level, :datetime, :message, :formatted
|
4
|
+
|
5
|
+
def initialize(level, datetime, message, formatted)
|
6
|
+
@level = level
|
7
|
+
@datetime = datetime
|
8
|
+
@message = message
|
9
|
+
@formatted = formatted
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_s
|
13
|
+
formatted
|
14
|
+
end
|
15
|
+
|
16
|
+
def <=>(other)
|
17
|
+
datetime <=> other.datetime
|
18
|
+
end
|
19
|
+
|
20
|
+
def before?(value)
|
21
|
+
return true unless value
|
22
|
+
|
23
|
+
datetime <= to_datetime(value)
|
24
|
+
end
|
25
|
+
|
26
|
+
def after?(value)
|
27
|
+
return true unless value
|
28
|
+
|
29
|
+
datetime >= to_datetime(value)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def to_datetime(value)
|
35
|
+
return value if value.is_a?(Time)
|
36
|
+
return unless value
|
37
|
+
|
38
|
+
Time.parse(value)
|
47
39
|
end
|
48
40
|
end
|
49
41
|
end
|
@@ -1,74 +1,70 @@
|
|
1
|
-
module Eco
|
2
|
-
|
3
|
-
|
4
|
-
module Session
|
5
|
-
class Logger < Eco::Language::BasicLogger
|
6
|
-
TIMESTAMP_PATTERN = '%Y-%m-%dT%H:%M:%S'.freeze
|
7
|
-
|
8
|
-
require_relative 'logger/channels'
|
9
|
-
include Channels
|
10
|
-
|
11
|
-
channels! do |channel, message = nil, block|
|
12
|
-
format_proc(console: true) do |severity, datetime, msg, formatted_msg|
|
13
|
-
cache.add(severity, datetime, msg, formatted_msg)
|
14
|
-
end.call(channel, Time.now, 'prog_name', message || block.call)
|
15
|
-
end
|
1
|
+
module Eco::API::Common::Session
|
2
|
+
class Logger < Eco::Language::BasicLogger
|
3
|
+
TIMESTAMP_PATTERN = '%Y-%m-%dT%H:%M:%S'.freeze
|
16
4
|
|
17
|
-
|
5
|
+
require_relative 'logger/channels'
|
6
|
+
include Channels
|
18
7
|
|
19
|
-
|
20
|
-
|
8
|
+
channels! do |channel, message = nil, block|
|
9
|
+
format_proc(console: true) do |severity, datetime, msg, formatted_msg|
|
10
|
+
cache.add(severity, datetime, msg, formatted_msg)
|
11
|
+
end.call(channel, Time.now, 'prog_name', message || block.call)
|
12
|
+
end
|
21
13
|
|
22
|
-
|
23
|
-
raise ArgumentError, msg if enviro && !enviro.is_a?(Eco::API::Common::Session::Environment)
|
14
|
+
attr_reader :cache
|
24
15
|
|
25
|
-
|
26
|
-
|
16
|
+
def initialize(file_level: ::Logger::DEBUG, log_file: nil, enviro: nil, **kargs)
|
17
|
+
super(**kargs)
|
27
18
|
|
28
|
-
|
29
|
-
|
30
|
-
logger.formatter = format_proc(console: false) do |severity, datetime, msg, formatted_msg|
|
31
|
-
cache.add(severity, datetime, msg, formatted_msg)
|
32
|
-
end
|
19
|
+
msg = "Required Environment object (enviro:). Given: #{enviro.class}"
|
20
|
+
raise ArgumentError, msg if enviro && !enviro.is_a?(Eco::API::Common::Session::Environment)
|
33
21
|
|
34
|
-
|
35
|
-
|
36
|
-
end
|
22
|
+
@enviro = enviro
|
23
|
+
@cache = Eco::API::Common::Session::Logger::Cache.new
|
37
24
|
|
38
|
-
|
39
|
-
|
40
|
-
|
25
|
+
if (log_file = fetch_log_file(log_file))
|
26
|
+
loggers[:file] = ::Logger.new(log_file).tap do |logger|
|
27
|
+
logger.formatter = format_proc(
|
28
|
+
console: false
|
29
|
+
) do |severity, datetime, msg, formatted_msg|
|
30
|
+
cache.add(severity, datetime, msg, formatted_msg)
|
41
31
|
end
|
42
32
|
|
43
|
-
|
44
|
-
|
45
|
-
|
33
|
+
logger.level = file_level
|
34
|
+
end
|
35
|
+
end
|
46
36
|
|
47
|
-
|
37
|
+
if_config(:timestamp_console) { |value| self.timestamp = value }
|
38
|
+
if_config(:console_level) { |value| self.level = value }
|
39
|
+
if_config(:file_level) { |value| self.file_level = value }
|
40
|
+
end
|
48
41
|
|
49
|
-
|
50
|
-
|
42
|
+
def file_level=(value)
|
43
|
+
loggers[:file]&.level = value
|
44
|
+
end
|
51
45
|
|
52
|
-
|
53
|
-
end
|
46
|
+
private
|
54
47
|
|
55
|
-
|
56
|
-
|
48
|
+
def config(attr)
|
49
|
+
return unless (cnf = @enviro&.config&.logger)
|
57
50
|
|
58
|
-
|
59
|
-
|
60
|
-
end
|
51
|
+
cnf.send(attr) if cnf.respond_to?(attr)
|
52
|
+
end
|
61
53
|
|
62
|
-
|
63
|
-
|
64
|
-
log_file = @enviro.file_manager.dir.file(log_file) if @enviro
|
65
|
-
FileManager.create_directory(log_file, includes_file: true)
|
66
|
-
end
|
54
|
+
def if_config(attr)
|
55
|
+
return if (value = config(attr)).nil?
|
67
56
|
|
68
|
-
|
69
|
-
|
70
|
-
|
57
|
+
yield(value) if block_given?
|
58
|
+
value
|
59
|
+
end
|
60
|
+
|
61
|
+
def fetch_log_file(log_file)
|
62
|
+
if log_file ||= config(:file)
|
63
|
+
log_file = @enviro.file_manager.dir.file(log_file) if @enviro
|
64
|
+
FileUtils.mkdir_p(File.dirname(log_file))
|
71
65
|
end
|
66
|
+
|
67
|
+
log_file
|
72
68
|
end
|
73
69
|
end
|
74
70
|
end
|
@@ -1,84 +1,76 @@
|
|
1
1
|
# rubocop:disable Naming/MethodParameterName
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
}
|
25
|
-
}
|
26
|
-
)
|
27
|
-
end
|
2
|
+
class Eco::API::Common::Session::Mailer
|
3
|
+
class AwsProvider < ProviderBase
|
4
|
+
def send_mail(subject:, body:, to: nil, cc: nil, bcc: nil)
|
5
|
+
ses.send_email(
|
6
|
+
destination: fetch_destination(to: to, cc: cc, bcc: bcc),
|
7
|
+
source: fetch_from,
|
8
|
+
message: {
|
9
|
+
subject: {
|
10
|
+
charset: 'UTF-8',
|
11
|
+
data: subject
|
12
|
+
},
|
13
|
+
body: {
|
14
|
+
# NOTE: (html) will let you send html instead
|
15
|
+
# you can use both at once if you like
|
16
|
+
text: {
|
17
|
+
charset: 'UTF-8',
|
18
|
+
data: body
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
22
|
+
)
|
23
|
+
end
|
28
24
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
25
|
+
# @return [Boolean] whether or not the mailer is configured for usage.
|
26
|
+
def configured?
|
27
|
+
fetch_access_key_id && fetch_secret_access_key && fetch_region
|
28
|
+
end
|
33
29
|
|
34
|
-
|
30
|
+
private
|
35
31
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
32
|
+
def credentials
|
33
|
+
@credentials ||= super.merge({
|
34
|
+
id: 'AWS_ACCESS_KEY_ID',
|
35
|
+
key: 'AWS_SECRET_ACCESS_KEY'
|
36
|
+
})
|
37
|
+
end
|
42
38
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
39
|
+
def ses
|
40
|
+
require 'aws-sdk-ses'
|
41
|
+
@ses ||= Aws::SES::Client.new(
|
42
|
+
access_key_id: fetch_access_key_id,
|
43
|
+
secret_access_key: fetch_secret_access_key,
|
44
|
+
region: fetch_region
|
45
|
+
)
|
46
|
+
rescue StandardError => err
|
47
|
+
log(:error) {
|
48
|
+
"Trying to send an email with wrong email configuration: #{err}"
|
49
|
+
}
|
50
|
+
end
|
55
51
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
52
|
+
def fetch_destination(to: nil, cc: nil, bcc: nil)
|
53
|
+
{
|
54
|
+
to_addresses: [fetch_to(to)].flatten.compact.uniq
|
55
|
+
}.tap do |dest|
|
56
|
+
cc = [cc].flatten.compact.uniq
|
57
|
+
bcc = [bcc].flatten.compact.uniq
|
62
58
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
59
|
+
dest.merge!(cc_addresses: cc) unless cc.empty?
|
60
|
+
dest.merge!(bcc_addresses: bcc) unless bcc.empty?
|
61
|
+
end
|
62
|
+
end
|
67
63
|
|
68
|
-
|
69
|
-
|
70
|
-
|
64
|
+
def fetch_region
|
65
|
+
config.mailer.region || ENV['AWS_REGION']
|
66
|
+
end
|
71
67
|
|
72
|
-
|
73
|
-
|
74
|
-
|
68
|
+
def fetch_server
|
69
|
+
config.mailer.server
|
70
|
+
end
|
75
71
|
|
76
|
-
|
77
|
-
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
72
|
+
def fetch_message_id_domain
|
73
|
+
config.mailer.message_id_domain
|
82
74
|
end
|
83
75
|
end
|
84
76
|
end
|
@@ -1,63 +1,58 @@
|
|
1
1
|
# rubocop:disable Naming/MethodParameterName
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
dest.merge!(bcc_addresses: bcc_to) unless bcc_to.empty?
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
2
|
+
class Eco::API::Common::Session::Mailer
|
3
|
+
class ProviderBase
|
4
|
+
class << self
|
5
|
+
def to_desc(to: nil, cc: nil, bcc: nil)
|
6
|
+
cc_to = [cc].flatten.compact.uniq
|
7
|
+
bcc_to = [bcc].flatten.compact.uniq
|
8
|
+
|
9
|
+
{ to_addresses: [to].flatten.compact.uniq }.tap do |dest|
|
10
|
+
dest.merge!(cc_addresses: cc_to) unless cc_to.empty?
|
11
|
+
dest.merge!(bcc_addresses: bcc_to) unless bcc_to.empty?
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
19
15
|
|
20
|
-
|
16
|
+
include Eco::Language::AuxiliarLogger
|
21
17
|
|
22
|
-
|
18
|
+
attr_reader :config
|
23
19
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
20
|
+
def initialize(config, logger:)
|
21
|
+
@config = config
|
22
|
+
@logger = logger
|
23
|
+
end
|
28
24
|
|
29
|
-
|
30
|
-
|
31
|
-
|
25
|
+
def send_mail(subject:, body:, to: nil, cc: nil, bcc: nil) # rubocop:disable Lint/UnusedMethodArgument
|
26
|
+
raise 'You must implement this method'
|
27
|
+
end
|
32
28
|
|
33
|
-
|
34
|
-
|
35
|
-
|
29
|
+
def fetch_to(value = nil)
|
30
|
+
value || config.mailer.to || env_credential(:to)
|
31
|
+
end
|
36
32
|
|
37
|
-
|
33
|
+
private
|
38
34
|
|
39
|
-
|
40
|
-
|
41
|
-
|
35
|
+
def credentials
|
36
|
+
{
|
37
|
+
to: 'MAILER_TO',
|
38
|
+
from: 'MAILER_FROM'
|
39
|
+
}
|
40
|
+
end
|
42
41
|
|
43
|
-
|
44
|
-
|
45
|
-
|
42
|
+
def fetch_from(value = nil)
|
43
|
+
value || config.mailer.from || env_credential(:from)
|
44
|
+
end
|
46
45
|
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
def fetch_access_key_id
|
47
|
+
env_credential(:id) || config.mailer.access_key_id
|
48
|
+
end
|
50
49
|
|
51
|
-
|
52
|
-
|
53
|
-
|
50
|
+
def fetch_secret_access_key
|
51
|
+
env_credential(:key) || config.mailer.secret_access_key
|
52
|
+
end
|
54
53
|
|
55
|
-
|
56
|
-
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
54
|
+
def env_credential(prop)
|
55
|
+
ENV[credentials[prop]]
|
61
56
|
end
|
62
57
|
end
|
63
58
|
end
|