mayaml 4.0.4 → 5.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -13
- data/README.md +4 -4
- data/bin/mayaml-mutt-init +75 -0
- data/lib/mayaml/base.rb +19 -0
- data/lib/mayaml/mutt_account_alternates/generator.rb +29 -0
- data/lib/mayaml/mutt_account_alternates/presenter.rb +18 -0
- data/lib/mayaml/mutt_account_alternates/template.mustache +1 -0
- data/lib/mayaml/mutt_account_alternates/validator.rb +18 -0
- data/lib/mayaml/mutt_account_alternates.rb +32 -0
- data/lib/mayaml/mutt_account_creds/generator.rb +29 -0
- data/lib/mayaml/mutt_account_creds/presenter.rb +29 -0
- data/lib/mayaml/mutt_account_creds/template.mustache +8 -0
- data/lib/mayaml/mutt_account_creds/validator.rb +25 -0
- data/lib/mayaml/mutt_account_creds.rb +32 -0
- data/lib/mayaml/mutt_account_init/generator.rb +30 -0
- data/lib/mayaml/mutt_account_init/presenter.rb +37 -0
- data/lib/mayaml/mutt_account_init/template.mustache +3 -0
- data/lib/mayaml/mutt_account_init/validator.rb +24 -0
- data/lib/mayaml/mutt_account_init.rb +32 -0
- data/lib/mayaml/mutt_config_accounts.rb +19 -0
- data/lib/mayaml/mutt_config_default_account.rb +18 -0
- data/lib/mayaml/mutt_config_init.rb +20 -0
- data/lib/mayaml/mutt_config_static.rb +18 -0
- data/lib/mayaml/mutt_configs_accounts/handler.rb +30 -0
- data/lib/mayaml/mutt_configs_default_account/handler.rb +46 -0
- data/lib/mayaml/mutt_configs_init/handler.rb +37 -0
- data/lib/mayaml/mutt_configs_static/assets/account_chooser.sh +20 -0
- data/lib/mayaml/mutt_configs_static/assets/csk.muttrc +94 -0
- data/lib/mayaml/mutt_configs_static/assets/mailcap +4 -0
- data/lib/mayaml/mutt_configs_static/assets/muttrc +125 -0
- data/lib/mayaml/mutt_configs_static/handler.rb +40 -0
- data/lib/mayaml/version.rb +1 -18
- data/lib/mayaml.rb +3 -47
- metadata +82 -24
- data/bin/mayaml-check +0 -42
- data/lib/mayaml/error.rb +0 -23
- data/lib/mayaml/mail_account/builder.rb +0 -127
- data/lib/mayaml/mail_account/default_flag_validator.rb +0 -43
- data/lib/mayaml/mail_account/error.rb +0 -47
- data/lib/mayaml/mail_account/mailboxes_validator.rb +0 -53
- data/lib/mayaml/mail_account/port_validator.rb +0 -44
- data/lib/mayaml/mail_account/required_attributes_validator.rb +0 -91
- data/lib/mayaml/mail_account/smtp_protocol_validator.rb +0 -53
- data/lib/mayaml/mail_account/type_validator.rb +0 -53
- data/lib/mayaml/mail_account.rb +0 -47
- data/lib/mayaml/parser.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1a2cc0729f9e6289cf3f91e4ecbfb67471cae58ac168eff55711079bc90fd9a
|
4
|
+
data.tar.gz: f3910c55a87c3522ba5efebd8c497a24971c69e3f31a2b30b400f10eea7d1e0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58488c42247204a511581bfc7a1a80f5f6bd4bca563cbfff41ec05700f1f3b9eea79fb514a923439e43217b7336dcef3f15d83a29c6e4557907e67d24b567a2a
|
7
|
+
data.tar.gz: 8c11e026f550e33d70bbb8e8455dbe896724a4ced341111af49eeb4c81e2ae614766d2022f090a3545765f4785a08e31e5aa0bdd5a0e8c5f4cbab244e21d7386
|
data/CHANGELOG.md
CHANGED
@@ -1,60 +1,66 @@
|
|
1
|
-
|
1
|
+
# develop
|
2
|
+
|
3
|
+
# 5.0.0 (2024.02.22)
|
4
|
+
|
5
|
+
* refactoring
|
6
|
+
|
7
|
+
# 4.0.4 (2018.07.07)
|
2
8
|
|
3
9
|
* update travis
|
4
10
|
|
5
|
-
|
11
|
+
# 4.0.3 (2018.07.07)
|
6
12
|
|
7
13
|
* update docs
|
8
14
|
|
9
|
-
|
15
|
+
# 4.0.2 (2018.07.07)
|
10
16
|
|
11
17
|
* update license
|
12
18
|
* update to ruby 2.5
|
13
19
|
|
14
|
-
|
20
|
+
# 4.0.1 (2017.04.06)
|
15
21
|
|
16
22
|
* update license
|
17
23
|
* fix makefile
|
18
24
|
* cleanup
|
19
25
|
|
20
|
-
|
26
|
+
# 4.0.0 (2017.04.06)
|
21
27
|
|
22
28
|
* add smpt_server attribute
|
23
29
|
* some refactoring
|
24
30
|
* update license and cleanup
|
25
31
|
|
26
|
-
|
32
|
+
# 3.0.1 (2017.04.06)
|
27
33
|
|
28
34
|
* fix travis integration
|
29
35
|
* cleanup
|
30
36
|
|
31
|
-
|
37
|
+
# 3.0.0 (2016.09.07)
|
32
38
|
|
33
39
|
* add new required arrtibutes: `smtp_protocol`, `smtp_port` and `smtp_authenticator`
|
34
40
|
* 4 valid account types: `imap`, `pop3`, `imapssl`, `pop3ssl`
|
35
41
|
|
36
|
-
|
42
|
+
# 2.0.1 (2016.08.31)
|
37
43
|
|
38
44
|
* update tests
|
39
45
|
|
40
|
-
|
46
|
+
# 2.0.0 (2016.08.31)
|
41
47
|
|
42
48
|
* add new attributes to the mail_account format: `default` and `realname`
|
43
49
|
* now only `mailboxes` and `default` attributes are optional
|
44
50
|
* add travis integration
|
45
51
|
|
46
|
-
|
52
|
+
# 1.0.3 (2016.06.24)
|
47
53
|
|
48
54
|
* fix bin script
|
49
55
|
|
50
|
-
|
56
|
+
# 1.0.2 (2016.06.24)
|
51
57
|
|
52
58
|
* fix bin path in gemspec
|
53
59
|
|
54
|
-
|
60
|
+
# 1.0.1 (2016.06.24)
|
55
61
|
|
56
62
|
* fix typos in docs
|
57
63
|
|
58
|
-
|
64
|
+
# 1.0.0 (2016.06.24)
|
59
65
|
|
60
66
|
* publication of the code
|
data/README.md
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
# MAYaml
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/mayaml.svg)](http://badge.fury.io/rb/mayaml)
|
4
|
-
[![Code Climate](https://codeclimate.com/github/skopciewski/mayaml/badges/gpa.svg)](https://codeclimate.com/github/skopciewski/mayaml)
|
5
4
|
|
6
|
-
This is a
|
5
|
+
This is a package for generating mutt configuration based on the yaml config. The idea is to store mail accounts configuration in one Yaml file and then generates dedicated mutt environment to handle them.
|
7
6
|
|
8
7
|
## Installation
|
9
8
|
|
@@ -21,8 +20,9 @@ Or install it yourself as:
|
|
21
20
|
|
22
21
|
## Usage
|
23
22
|
|
24
|
-
If ruby bin dir is in your PATH, just call `mayaml-
|
25
|
-
|
23
|
+
If ruby bin dir is in your PATH, just call `mayaml-mutt-init <path_to_the_yaml_file> <mutt_config_dir>`.
|
24
|
+
|
25
|
+
Or
|
26
26
|
|
27
27
|
```ruby
|
28
28
|
require "mayaml"
|
@@ -0,0 +1,75 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "mayaml"
|
5
|
+
require "fileutils"
|
6
|
+
require "yaml"
|
7
|
+
|
8
|
+
def check_yaml_path(yaml_path)
|
9
|
+
if yaml_path.nil?
|
10
|
+
puts_ussage_message
|
11
|
+
exit 1
|
12
|
+
end
|
13
|
+
return if File.exist? yaml_path
|
14
|
+
puts "Could not find file: #{yaml_path}"
|
15
|
+
exit 1
|
16
|
+
end
|
17
|
+
|
18
|
+
def check_destintaion_dir(dir)
|
19
|
+
if dir.nil?
|
20
|
+
puts_ussage_message
|
21
|
+
exit 1
|
22
|
+
end
|
23
|
+
return if Dir.exist? dir
|
24
|
+
puts "Unknown destination dir: #{dir}"
|
25
|
+
exit 1
|
26
|
+
end
|
27
|
+
|
28
|
+
def puts_ussage_message
|
29
|
+
puts <<-END_HELP
|
30
|
+
Ussage: mayaml-mutt-init <path_to_yaml_file> <destination_dir>
|
31
|
+
END_HELP
|
32
|
+
end
|
33
|
+
|
34
|
+
def get_accounts(yaml_path)
|
35
|
+
Psych.safe_load_file yaml_path, symbolize_names: true
|
36
|
+
rescue
|
37
|
+
puts "Could not parse file: #{yaml_path}"
|
38
|
+
exit 1
|
39
|
+
end
|
40
|
+
|
41
|
+
def create_files(data)
|
42
|
+
data.each do |hsh|
|
43
|
+
path = hsh.keys.first
|
44
|
+
content = hsh.values.first
|
45
|
+
FileUtils.mkdir_p File.dirname(path)
|
46
|
+
File.open(path, "w") do |f|
|
47
|
+
f.write(content)
|
48
|
+
end
|
49
|
+
pp "* File created: #{path}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def create_aliases(data)
|
54
|
+
data.each do |hsh|
|
55
|
+
path = hsh.keys.first
|
56
|
+
dest = hsh.values.first
|
57
|
+
FileUtils.ln_s(dest, path, force: true)
|
58
|
+
pp "* Symlink created: #{dest} -> #{path}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def main(args)
|
63
|
+
yaml_path = args.shift
|
64
|
+
destination_dir = args.shift
|
65
|
+
check_yaml_path yaml_path
|
66
|
+
check_destintaion_dir destination_dir
|
67
|
+
accounts = get_accounts yaml_path
|
68
|
+
create_files Mayaml::Base.mutt_configs_accounts_handler.execute accounts, destination_dir
|
69
|
+
create_files Mayaml::Base.mutt_configs_init_handler.execute accounts, destination_dir
|
70
|
+
create_files Mayaml::Base.mutt_configs_static_handler.execute destination_dir
|
71
|
+
create_aliases Mayaml::Base.mutt_configs_default_account_handler.execute accounts, destination_dir
|
72
|
+
# destination_file.nil? ? present_configs(configs) : store_configs(configs, destination_file)
|
73
|
+
end
|
74
|
+
|
75
|
+
main ARGV
|
data/lib/mayaml/base.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "mainapp/base"
|
4
|
+
require "ougai"
|
5
|
+
|
6
|
+
module Mayaml
|
7
|
+
class Base
|
8
|
+
extend ::Mainapp::Base
|
9
|
+
end
|
10
|
+
|
11
|
+
STRUCTURE = {
|
12
|
+
logger: Ougai::Logger.new($stdout).tap do |logger|
|
13
|
+
logger.level = Kernel.const_get(ENV["LOG_LEVEL"] || "Logger::INFO")
|
14
|
+
logger.with_fields = {name: "mayaml"}
|
15
|
+
end
|
16
|
+
}.freeze
|
17
|
+
|
18
|
+
::Mayaml::Base.set Mayaml::STRUCTURE
|
19
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "mainapp/component"
|
4
|
+
require "mustache"
|
5
|
+
|
6
|
+
module Mayaml
|
7
|
+
module MuttAccountAlternates
|
8
|
+
class Generator
|
9
|
+
include ::Mainapp::Component
|
10
|
+
attr_struct :logger, :presenter, :validator
|
11
|
+
|
12
|
+
def render(data)
|
13
|
+
validate_data(data)
|
14
|
+
render_view(data)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def validate_data(data)
|
20
|
+
validator.validate data
|
21
|
+
end
|
22
|
+
|
23
|
+
def render_view(data)
|
24
|
+
::Mustache.template_path = __dir__
|
25
|
+
::Mustache.render :template, presenter.for_render(data)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "mainapp/component"
|
4
|
+
|
5
|
+
module Mayaml
|
6
|
+
module MuttAccountAlternates
|
7
|
+
class Presenter
|
8
|
+
include ::Mainapp::Component
|
9
|
+
attr_struct :logger
|
10
|
+
|
11
|
+
def for_render(data)
|
12
|
+
{
|
13
|
+
accounts: data.map { _1[:name] }.join(" ")
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
alternates {{ accounts }}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "mainapp/component"
|
4
|
+
|
5
|
+
module Mayaml
|
6
|
+
module MuttAccountAlternates
|
7
|
+
class Validator
|
8
|
+
include ::Mainapp::Component
|
9
|
+
attr_struct :logger
|
10
|
+
|
11
|
+
def validate(data)
|
12
|
+
raise ArgumentError.new "Missing accounts value" if data.nil?
|
13
|
+
raise ArgumentError.new "Invalid accounts value" unless data.is_a? Array
|
14
|
+
raise ArgumentError.new "Empty accounts value" if data.empty?
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "mayaml/base"
|
4
|
+
require "mayaml/mutt_account_alternates/generator"
|
5
|
+
require "mayaml/mutt_account_alternates/presenter"
|
6
|
+
require "mayaml/mutt_account_alternates/validator"
|
7
|
+
|
8
|
+
module Mayaml
|
9
|
+
module MuttAccountAlternates
|
10
|
+
STRUCTURE = {
|
11
|
+
mutt_account_alternates_generator: proc do
|
12
|
+
Generator.new(
|
13
|
+
logger: logger.child(component: "mutt_account_alternates_generator"),
|
14
|
+
presenter: mutt_account_alternates_presenter,
|
15
|
+
validator: mutt_account_alternates_validator
|
16
|
+
)
|
17
|
+
end,
|
18
|
+
mutt_account_alternates_validator: proc do
|
19
|
+
Validator.new(
|
20
|
+
logger: logger.child(component: "mutt_account_alternates_validator")
|
21
|
+
)
|
22
|
+
end,
|
23
|
+
mutt_account_alternates_presenter: proc do
|
24
|
+
Presenter.new(
|
25
|
+
logger: logger.child(component: "mutt_account_alternates_presenter")
|
26
|
+
)
|
27
|
+
end
|
28
|
+
}.freeze
|
29
|
+
|
30
|
+
::Mayaml::Base.set STRUCTURE
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "mainapp/component"
|
4
|
+
require "mustache"
|
5
|
+
|
6
|
+
module Mayaml
|
7
|
+
module MuttAccountCreds
|
8
|
+
class Generator
|
9
|
+
include ::Mainapp::Component
|
10
|
+
attr_struct :logger, :presenter, :validator
|
11
|
+
|
12
|
+
def render(data)
|
13
|
+
validate_data(data)
|
14
|
+
render_view(data)
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def validate_data(data)
|
20
|
+
validator.validate data
|
21
|
+
end
|
22
|
+
|
23
|
+
def render_view(data)
|
24
|
+
::Mustache.template_path = __dir__
|
25
|
+
::Mustache.render :template, presenter.for_render(data)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "mainapp/component"
|
4
|
+
|
5
|
+
module Mayaml
|
6
|
+
module MuttAccountCreds
|
7
|
+
class Presenter
|
8
|
+
include ::Mainapp::Component
|
9
|
+
attr_struct :logger
|
10
|
+
|
11
|
+
def for_render(data)
|
12
|
+
%i[realname name smtp_authenticator smtp_protocol smtp_server smtp_port
|
13
|
+
user pass].inject({}) do |result, key|
|
14
|
+
result.merge key => send(key, data)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def method_missing(key, *args)
|
21
|
+
args.dig 0, key
|
22
|
+
end
|
23
|
+
|
24
|
+
def respond_to_missing?(method_name, include_private = false)
|
25
|
+
super
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
# vim: filetype=muttrc
|
2
|
+
|
3
|
+
set realname="{{ realname }}"
|
4
|
+
set from="{{ name }}"
|
5
|
+
set smtp_url="{{ smtp_protocol }}://{{ user }}@{{ smtp_server }}:{{ smtp_port }}/" smtp_pass="{{ pass }}"
|
6
|
+
set smtp_authenticators="{{ smtp_authenticator }}"
|
7
|
+
set ssl_force_tls=yes
|
8
|
+
set ssl_starttls=yes
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "mainapp/component"
|
4
|
+
|
5
|
+
module Mayaml
|
6
|
+
module MuttAccountCreds
|
7
|
+
class Validator
|
8
|
+
include ::Mainapp::Component
|
9
|
+
attr_struct :logger
|
10
|
+
|
11
|
+
def validate(data)
|
12
|
+
%i[realname name smtp_protocol smtp_server smtp_port smtp_authenticator
|
13
|
+
user pass].each do |value|
|
14
|
+
raise ArgumentError.new "Missing #{value}" if missing?(data, value)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def missing?(data, value)
|
21
|
+
data[value].to_s.strip == ""
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "mayaml/base"
|
4
|
+
require "mayaml/mutt_account_creds/generator"
|
5
|
+
require "mayaml/mutt_account_creds/presenter"
|
6
|
+
require "mayaml/mutt_account_creds/validator"
|
7
|
+
|
8
|
+
module Mayaml
|
9
|
+
module MuttAccountCreds
|
10
|
+
STRUCTURE = {
|
11
|
+
mutt_account_creds_generator: proc do
|
12
|
+
Generator.new(
|
13
|
+
logger: logger.child(component: "mutt_account_creds_generator"),
|
14
|
+
presenter: mutt_account_creds_presenter,
|
15
|
+
validator: mutt_account_creds_validator
|
16
|
+
)
|
17
|
+
end,
|
18
|
+
mutt_account_creds_validator: proc do
|
19
|
+
Validator.new(
|
20
|
+
logger: logger.child(component: "mutt_account_creds_validator")
|
21
|
+
)
|
22
|
+
end,
|
23
|
+
mutt_account_creds_presenter: proc do
|
24
|
+
Presenter.new(
|
25
|
+
logger: logger.child(component: "mutt_account_creds_presenter")
|
26
|
+
)
|
27
|
+
end
|
28
|
+
}.freeze
|
29
|
+
|
30
|
+
::Mayaml::Base.set STRUCTURE
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "mainapp/component"
|
4
|
+
require "mustache"
|
5
|
+
|
6
|
+
module Mayaml
|
7
|
+
module MuttAccountInit
|
8
|
+
class Generator
|
9
|
+
include ::Mainapp::Component
|
10
|
+
attr_struct :logger, :presenter, :default_accounts_dir, :validator
|
11
|
+
|
12
|
+
def render(index, prefix_path, data)
|
13
|
+
ext_data = data.merge(index: index, prefix_path: prefix_path)
|
14
|
+
validate_data(ext_data)
|
15
|
+
render_view(ext_data)
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def validate_data(data)
|
21
|
+
validator.validate data
|
22
|
+
end
|
23
|
+
|
24
|
+
def render_view(data)
|
25
|
+
::Mustache.template_path = __dir__
|
26
|
+
::Mustache.render :template, presenter.for_render(data)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "mainapp/component"
|
4
|
+
|
5
|
+
module Mayaml
|
6
|
+
module MuttAccountInit
|
7
|
+
class Presenter
|
8
|
+
include ::Mainapp::Component
|
9
|
+
attr_struct :logger
|
10
|
+
|
11
|
+
def for_render(data)
|
12
|
+
{
|
13
|
+
name: name(data),
|
14
|
+
accounts_path: accounts_path(data),
|
15
|
+
clean_name: clean_name(data)
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def name(data)
|
22
|
+
data[:name]
|
23
|
+
end
|
24
|
+
|
25
|
+
def accounts_path(data)
|
26
|
+
File.join(
|
27
|
+
data[:prefix_path],
|
28
|
+
"accounts"
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
def clean_name(data)
|
33
|
+
"#{data[:index]}_#{data[:name].gsub(/\W/, "_")}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "mainapp/component"
|
4
|
+
|
5
|
+
module Mayaml
|
6
|
+
module MuttAccountInit
|
7
|
+
class Validator
|
8
|
+
include ::Mainapp::Component
|
9
|
+
attr_struct :logger
|
10
|
+
|
11
|
+
def validate(data)
|
12
|
+
%i[name index].each do |value|
|
13
|
+
raise ArgumentError.new "Missing #{value}" if missing?(data, value)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def missing?(data, value)
|
20
|
+
data[value].to_s.strip == ""
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "mayaml/base"
|
4
|
+
require "mayaml/mutt_account_init/generator"
|
5
|
+
require "mayaml/mutt_account_init/presenter"
|
6
|
+
require "mayaml/mutt_account_init/validator"
|
7
|
+
|
8
|
+
module Mayaml
|
9
|
+
module MuttAccountInit
|
10
|
+
STRUCTURE = {
|
11
|
+
mutt_account_init_generator: proc do
|
12
|
+
Generator.new(
|
13
|
+
logger: logger.child(component: "mutt_account_init_generator"),
|
14
|
+
presenter: mutt_account_init_presenter,
|
15
|
+
validator: mutt_account_init_validator
|
16
|
+
)
|
17
|
+
end,
|
18
|
+
mutt_account_init_validator: proc do
|
19
|
+
Validator.new(
|
20
|
+
logger: logger.child(component: "mutt_account_init_validator")
|
21
|
+
)
|
22
|
+
end,
|
23
|
+
mutt_account_init_presenter: proc do
|
24
|
+
Presenter.new(
|
25
|
+
logger: logger.child(component: "mutt_account_init_presenter")
|
26
|
+
)
|
27
|
+
end
|
28
|
+
}.freeze
|
29
|
+
|
30
|
+
::Mayaml::Base.set STRUCTURE
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "mayaml/base"
|
4
|
+
require "mayaml/mutt_configs_accounts/handler"
|
5
|
+
|
6
|
+
module Mayaml
|
7
|
+
module MuttConfigsAccounts
|
8
|
+
STRUCTURE = {
|
9
|
+
mutt_configs_accounts_handler: proc do
|
10
|
+
Handler.new(
|
11
|
+
mutt_account_creds_generator: mutt_account_creds_generator,
|
12
|
+
logger: logger.child(component: "mutt_configs_accounts_handler")
|
13
|
+
)
|
14
|
+
end
|
15
|
+
}.freeze
|
16
|
+
|
17
|
+
::Mayaml::Base.set STRUCTURE
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "mayaml/base"
|
4
|
+
require "mayaml/mutt_configs_default_account/handler"
|
5
|
+
|
6
|
+
module Mayaml
|
7
|
+
module MuttConfigsDefaultAccount
|
8
|
+
STRUCTURE = {
|
9
|
+
mutt_configs_default_account_handler: proc do
|
10
|
+
Handler.new(
|
11
|
+
logger: logger.child(component: "mutt_configs_default_account_handler")
|
12
|
+
)
|
13
|
+
end
|
14
|
+
}.freeze
|
15
|
+
|
16
|
+
::Mayaml::Base.set STRUCTURE
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "mayaml/base"
|
4
|
+
require "mayaml/mutt_configs_init/handler"
|
5
|
+
|
6
|
+
module Mayaml
|
7
|
+
module MuttConfigsInit
|
8
|
+
STRUCTURE = {
|
9
|
+
mutt_configs_init_handler: proc do
|
10
|
+
Handler.new(
|
11
|
+
mutt_account_init_generator: mutt_account_init_generator,
|
12
|
+
mutt_account_alternates_generator: mutt_account_alternates_generator,
|
13
|
+
logger: logger.child(component: "mutt_configs_init_handler")
|
14
|
+
)
|
15
|
+
end
|
16
|
+
}.freeze
|
17
|
+
|
18
|
+
::Mayaml::Base.set STRUCTURE
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "mayaml/base"
|
4
|
+
require "mayaml/mutt_configs_static/handler"
|
5
|
+
|
6
|
+
module Mayaml
|
7
|
+
module MuttConfigsStatic
|
8
|
+
STRUCTURE = {
|
9
|
+
mutt_configs_static_handler: proc do
|
10
|
+
Handler.new(
|
11
|
+
logger: logger.child(component: "mutt_configs_static_handler")
|
12
|
+
)
|
13
|
+
end
|
14
|
+
}.freeze
|
15
|
+
|
16
|
+
::Mayaml::Base.set STRUCTURE
|
17
|
+
end
|
18
|
+
end
|