mayaml 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +4 -0
- data/LICENSE +675 -0
- data/README.md +57 -0
- data/bin/mayaml-check +41 -0
- data/lib/mayaml/error.rb +23 -0
- data/lib/mayaml/mail_account/builder.rb +108 -0
- data/lib/mayaml/mail_account/error.rb +38 -0
- data/lib/mayaml/mail_account/mailboxes_validator.rb +41 -0
- data/lib/mayaml/mail_account/port_validator.rb +37 -0
- data/lib/mayaml/mail_account/required_attributes_validator.rb +38 -0
- data/lib/mayaml/mail_account/type_validator.rb +39 -0
- data/lib/mayaml/mail_account.rb +49 -0
- data/lib/mayaml/parser.rb +29 -0
- data/lib/mayaml/version.rb +22 -0
- data/lib/mayaml.rb +43 -0
- metadata +117 -0
data/README.md
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# MAYaml
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/mayaml.svg)](http://badge.fury.io/rb/mayaml)
|
4
|
+
|
5
|
+
This is a base package for mail accounts configuration generators. The ideas is to store mail accounts configuration in one Yaml file and then generates dedicated configs for specific programs (like getmail, mutt, etc...).
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'mayaml'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install mayaml
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
If ruby bin dir is in your PATH, just call `mayaml-check <path_to_the_yaml_file>` to list recognized accounts.
|
24
|
+
On the other hand, In plugins:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
require "mayaml"
|
28
|
+
|
29
|
+
Mayaml.accounts_from_file(yaml_path).each { |account| ... }
|
30
|
+
```
|
31
|
+
|
32
|
+
### Mail account format in Yaml file
|
33
|
+
|
34
|
+
```yaml
|
35
|
+
- name: account_name
|
36
|
+
type: imap
|
37
|
+
server: test.mailserver.com
|
38
|
+
port: 998
|
39
|
+
user: user@mailserver.com
|
40
|
+
pass: sercet_password
|
41
|
+
mailboxes
|
42
|
+
- INBOX
|
43
|
+
```
|
44
|
+
|
45
|
+
## Versioning
|
46
|
+
|
47
|
+
See [semver.org][semver]
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
1. Fork it
|
52
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
53
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
54
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
55
|
+
5. Create new Pull Request
|
56
|
+
|
57
|
+
[semver]: http://semver.org/
|
data/bin/mayaml-check
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# Copyright (C) 2016 Szymon Kopciewski
|
4
|
+
#
|
5
|
+
# This file is part of Mayaml.
|
6
|
+
#
|
7
|
+
# This program is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
#
|
20
|
+
require "mayaml"
|
21
|
+
|
22
|
+
def puts_ussage_message
|
23
|
+
puts <<-END_HELP
|
24
|
+
Ussage: mayaml-check <path_to_yaml_file>
|
25
|
+
END_HELP
|
26
|
+
end
|
27
|
+
|
28
|
+
def main(args)
|
29
|
+
yaml_path = args.shift
|
30
|
+
if yaml_path.nil?
|
31
|
+
puts_ussage_message
|
32
|
+
exit 1
|
33
|
+
elsif File.exist? yaml_path
|
34
|
+
Mayaml.accounts_from_file(yaml_path).each { |acc| puts acc.to_str }
|
35
|
+
else
|
36
|
+
puts "Could not find file: #{yaml_path}"
|
37
|
+
exit 1
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
main ARGV if __FILE__ == $PROGRAM_NAME
|
data/lib/mayaml/error.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Copyright (C) 2016 Szymon Kopciewski
|
4
|
+
#
|
5
|
+
# This file is part of Mayaml.
|
6
|
+
#
|
7
|
+
# This program is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
|
20
|
+
module Mayaml
|
21
|
+
class Error < StandardError
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Copyright (C) 2016 Szymon Kopciewski
|
4
|
+
#
|
5
|
+
# This file is part of Mayaml.
|
6
|
+
#
|
7
|
+
# This program is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
require "mayaml/mail_account"
|
20
|
+
require "mayaml/mail_account/error"
|
21
|
+
require "mayaml/mail_account/required_attributes_validator"
|
22
|
+
require "mayaml/mail_account/type_validator"
|
23
|
+
require "mayaml/mail_account/port_validator"
|
24
|
+
require "mayaml/mail_account/mailboxes_validator"
|
25
|
+
|
26
|
+
module Mayaml
|
27
|
+
class MailAccount
|
28
|
+
class Builder
|
29
|
+
def self.build
|
30
|
+
builder = new
|
31
|
+
yield(builder)
|
32
|
+
builder.account
|
33
|
+
end
|
34
|
+
|
35
|
+
def initialize
|
36
|
+
@account = ::Mayaml::MailAccount.new
|
37
|
+
end
|
38
|
+
|
39
|
+
def name(name)
|
40
|
+
@account.name = name
|
41
|
+
end
|
42
|
+
|
43
|
+
def type(str)
|
44
|
+
if str.nil? || str == ""
|
45
|
+
@account.set_default_type
|
46
|
+
else
|
47
|
+
validator = TypeValidator.new str
|
48
|
+
unless validator.valid?
|
49
|
+
raise WrongAccountType, validator.errors.join(" ")
|
50
|
+
end
|
51
|
+
@account.type = str.to_sym
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def server(str)
|
56
|
+
@account.server = str
|
57
|
+
end
|
58
|
+
|
59
|
+
def port(nr)
|
60
|
+
if nr.nil? || nr == ""
|
61
|
+
@account.set_default_port
|
62
|
+
else
|
63
|
+
validator = PortValidator.new nr
|
64
|
+
unless validator.valid?
|
65
|
+
raise WrongAccountPort, validator.errors.join(" ")
|
66
|
+
end
|
67
|
+
@account.port = nr.to_i
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def user(str)
|
72
|
+
@account.user = str
|
73
|
+
end
|
74
|
+
|
75
|
+
def pass(str)
|
76
|
+
@account.pass = str
|
77
|
+
end
|
78
|
+
|
79
|
+
def mailboxes(arr)
|
80
|
+
if arr.nil? || arr.empty?
|
81
|
+
@account.set_default_mailboxes
|
82
|
+
else
|
83
|
+
validator = MailboxesValidator.new arr
|
84
|
+
unless validator.valid?
|
85
|
+
raise WrongAccountMailboxes, validator.errors.join(" ")
|
86
|
+
end
|
87
|
+
@account.mailboxes = arr
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def account
|
92
|
+
obj = valid_account
|
93
|
+
@account = ::Mayaml::MailAccount.new
|
94
|
+
obj
|
95
|
+
end
|
96
|
+
|
97
|
+
private
|
98
|
+
|
99
|
+
def valid_account
|
100
|
+
validator = RequiredAttributesValidator.new @account
|
101
|
+
unless validator.valid?
|
102
|
+
raise MissingAttributes, validator.errors.join(" ")
|
103
|
+
end
|
104
|
+
@account.dup
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Copyright (C) 2016 Szymon Kopciewski
|
4
|
+
#
|
5
|
+
# This file is part of Mayaml.
|
6
|
+
#
|
7
|
+
# This program is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
require "mayaml/error"
|
20
|
+
|
21
|
+
module Mayaml
|
22
|
+
class MailAccount
|
23
|
+
class Error < ::Mayaml::Error
|
24
|
+
end
|
25
|
+
|
26
|
+
class MissingAttributes < Error
|
27
|
+
end
|
28
|
+
|
29
|
+
class WrongAccountType < Error
|
30
|
+
end
|
31
|
+
|
32
|
+
class WrongAccountPort < Error
|
33
|
+
end
|
34
|
+
|
35
|
+
class WrongAccountMailboxes < Error
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Copyright (C) 2016 Szymon Kopciewski
|
4
|
+
#
|
5
|
+
# This file is part of Mayaml.
|
6
|
+
#
|
7
|
+
# This program is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
|
20
|
+
module Mayaml
|
21
|
+
class MailAccount
|
22
|
+
class MailboxesValidator
|
23
|
+
attr_reader :errors
|
24
|
+
|
25
|
+
def initialize(mailboxes)
|
26
|
+
@errors = []
|
27
|
+
@errors << "Mailboxes should be array." unless mailboxes.instance_of? Array
|
28
|
+
if mailboxes.instance_of?(Array) && mailboxes.empty?
|
29
|
+
@errors << "Mailboxes can not be empty."
|
30
|
+
end
|
31
|
+
if mailboxes.instance_of?(Array) && !mailboxes.all? { |box| box.instance_of? String }
|
32
|
+
@errors << "Mailboxes should all be strings."
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def valid?
|
37
|
+
@errors.empty?
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Copyright (C) 2016 Szymon Kopciewski
|
4
|
+
#
|
5
|
+
# This file is part of Mayaml.
|
6
|
+
#
|
7
|
+
# This program is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
|
20
|
+
module Mayaml
|
21
|
+
class MailAccount
|
22
|
+
class PortValidator
|
23
|
+
attr_reader :errors
|
24
|
+
|
25
|
+
def initialize(port)
|
26
|
+
@errors = []
|
27
|
+
port = port.respond_to?(:to_i) ? port.to_i : 0
|
28
|
+
@errors << "Mail account port is invalid." if port == 0
|
29
|
+
@errors << "Mail account port could not be negative." if port < 0
|
30
|
+
end
|
31
|
+
|
32
|
+
def valid?
|
33
|
+
@errors.empty?
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Copyright (C) 2016 Szymon Kopciewski
|
4
|
+
#
|
5
|
+
# This file is part of Mayaml.
|
6
|
+
#
|
7
|
+
# This program is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
|
20
|
+
module Mayaml
|
21
|
+
class MailAccount
|
22
|
+
class RequiredAttributesValidator
|
23
|
+
attr_reader :errors
|
24
|
+
|
25
|
+
def initialize(mail_account)
|
26
|
+
@errors = []
|
27
|
+
@errors << "Missing name attribute." if mail_account.name.nil?
|
28
|
+
@errors << "Missing server attribute." if mail_account.server.nil?
|
29
|
+
@errors << "Missing user attribute." if mail_account.user.nil?
|
30
|
+
@errors << "Missing pass attribute." if mail_account.pass.nil?
|
31
|
+
end
|
32
|
+
|
33
|
+
def valid?
|
34
|
+
@errors.empty?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Copyright (C) 2016 Szymon Kopciewski
|
4
|
+
#
|
5
|
+
# This file is part of Mayaml.
|
6
|
+
#
|
7
|
+
# This program is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
|
20
|
+
module Mayaml
|
21
|
+
class MailAccount
|
22
|
+
class TypeValidator
|
23
|
+
attr_reader :errors
|
24
|
+
VALID_TYPES = [:imap, :pop3].freeze
|
25
|
+
|
26
|
+
def initialize(type)
|
27
|
+
@errors = []
|
28
|
+
type = type.to_sym if type.respond_to? :to_sym
|
29
|
+
unless VALID_TYPES.include?(type)
|
30
|
+
@errors << "Mail account type is invalid. Allowed types: #{VALID_TYPES.join(", ")}."
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def valid?
|
35
|
+
@errors.empty?
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Copyright (C) 2016 Szymon Kopciewski
|
4
|
+
#
|
5
|
+
# This file is part of Mayaml.
|
6
|
+
#
|
7
|
+
# This program is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
|
20
|
+
module Mayaml
|
21
|
+
class MailAccount
|
22
|
+
attr_accessor :name, :type, :server, :port, :user, :pass, :mailboxes
|
23
|
+
|
24
|
+
def initialize
|
25
|
+
set_default_type
|
26
|
+
set_default_port
|
27
|
+
set_default_mailboxes
|
28
|
+
end
|
29
|
+
|
30
|
+
def set_default_type
|
31
|
+
@type = :imap
|
32
|
+
end
|
33
|
+
|
34
|
+
def set_default_port
|
35
|
+
@port = 993
|
36
|
+
end
|
37
|
+
|
38
|
+
def set_default_mailboxes
|
39
|
+
@mailboxes = []
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_str
|
43
|
+
<<-DESC
|
44
|
+
Account: #{@name} | user: #{@user}:#{@pass}
|
45
|
+
#{@type} - #{@server}:#{@port} [#{@mailboxes.join(",")}]
|
46
|
+
DESC
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Copyright (C) 2016 Szymon Kopciewski
|
4
|
+
#
|
5
|
+
# This file is part of Mayaml.
|
6
|
+
#
|
7
|
+
# This program is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
require "yaml"
|
20
|
+
|
21
|
+
module Mayaml
|
22
|
+
class Parser
|
23
|
+
def self.get_accounts(json_file)
|
24
|
+
YAML.load_file json_file
|
25
|
+
rescue Errno::ENOENT, Psych::SyntaxError
|
26
|
+
[]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Copyright (C) 2016 Szymon Kopciewski
|
4
|
+
#
|
5
|
+
# This file is part of Mayaml.
|
6
|
+
#
|
7
|
+
# This program is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
|
20
|
+
module Mayaml
|
21
|
+
VERSION = "1.0.0".freeze
|
22
|
+
end
|
data/lib/mayaml.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Copyright (C) 2016 Szymon Kopciewski
|
4
|
+
#
|
5
|
+
# This file is part of Mayaml.
|
6
|
+
#
|
7
|
+
# This program is free software: you can redistribute it and/or modify
|
8
|
+
# it under the terms of the GNU General Public License as published by
|
9
|
+
# the Free Software Foundation, either version 3 of the License, or
|
10
|
+
# (at your option) any later version.
|
11
|
+
#
|
12
|
+
# This program is distributed in the hope that it will be useful,
|
13
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
# GNU General Public License for more details.
|
16
|
+
#
|
17
|
+
# You should have received a copy of the GNU General Public License
|
18
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19
|
+
|
20
|
+
require "mayaml/version"
|
21
|
+
require "mayaml/mail_account/builder"
|
22
|
+
require "mayaml/parser"
|
23
|
+
|
24
|
+
module Mayaml
|
25
|
+
def self.accounts_from_file(yaml_accounts)
|
26
|
+
raw_accounts = Parser.get_accounts(yaml_accounts)
|
27
|
+
raw_accounts.map do |raw_account|
|
28
|
+
build_account(raw_account)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.build_account(raw_account)
|
33
|
+
MailAccount::Builder.build do |builder|
|
34
|
+
builder.name raw_account.fetch("name")
|
35
|
+
builder.type raw_account.fetch("type")
|
36
|
+
builder.server raw_account.fetch("server")
|
37
|
+
builder.port raw_account.fetch("port")
|
38
|
+
builder.user raw_account.fetch("user")
|
39
|
+
builder.pass raw_account.fetch("pass")
|
40
|
+
builder.mailboxes raw_account.fetch("mailboxes", [])
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
metadata
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mayaml
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Szymon Kopciewski
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: pry
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: minitest-reporters
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Mail Accounts from Yaml parser - the base classes
|
70
|
+
email:
|
71
|
+
- s.kopciewski@gmail.com
|
72
|
+
executables:
|
73
|
+
- mayaml-check
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- CHANGELOG.md
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE
|
80
|
+
- README.md
|
81
|
+
- bin/mayaml-check
|
82
|
+
- lib/mayaml.rb
|
83
|
+
- lib/mayaml/error.rb
|
84
|
+
- lib/mayaml/mail_account.rb
|
85
|
+
- lib/mayaml/mail_account/builder.rb
|
86
|
+
- lib/mayaml/mail_account/error.rb
|
87
|
+
- lib/mayaml/mail_account/mailboxes_validator.rb
|
88
|
+
- lib/mayaml/mail_account/port_validator.rb
|
89
|
+
- lib/mayaml/mail_account/required_attributes_validator.rb
|
90
|
+
- lib/mayaml/mail_account/type_validator.rb
|
91
|
+
- lib/mayaml/parser.rb
|
92
|
+
- lib/mayaml/version.rb
|
93
|
+
homepage: https://github.com/skopciewski/mayaml
|
94
|
+
licenses:
|
95
|
+
- GPL-3.0
|
96
|
+
metadata: {}
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options: []
|
99
|
+
require_paths:
|
100
|
+
- lib
|
101
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
requirements: []
|
112
|
+
rubyforge_project:
|
113
|
+
rubygems_version: 2.2.5
|
114
|
+
signing_key:
|
115
|
+
specification_version: 4
|
116
|
+
summary: Mail Accounts from Yaml parser - the base classes
|
117
|
+
test_files: []
|