mayaml 2.0.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 460a5ca87aa475de21f9fa38f4c546a8ec4c4db3
4
- data.tar.gz: 9e44f1efb68113e3ff1a815f79871e60d5089e93
3
+ metadata.gz: 0fc2e662cee19930ae8a3802e1d42874f3ce5925
4
+ data.tar.gz: b7b2c54f4d44cc32270749c0d758ad47fba6fa45
5
5
  SHA512:
6
- metadata.gz: e5c58756f99dab2e33c41c67619b0578a07666da179128cfa3310d36b04bde06910c902ccfa0d2a767d9301ebc66b8f468af705fc75f73315da6a24eb7eb75aa
7
- data.tar.gz: d7e7a85789971c5a12103e982a32e72a3d3fd483191d01fa8249d15f29a926e1d46d13546d3e6d19b2393711ffb2f674bab90829808fc622d0058165964cd80a
6
+ metadata.gz: 79419e0e20c57900f1e9f62bd66de0af817d9d541ee15f40de0dafe4db1cdab090cb6821a2b18c98527ba3329f068b9985a7399a4fa85949bcc14c8f0d848126
7
+ data.tar.gz: d6fd36d5ac090d1f691cecc077cf1eee437a25d9e1277f06af12f36cf91341ac47a9d2b0dc16730edfb1df88fe1b16c4ea1862ae3c8e04d2007b9ef7bafa8ed4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ === 3.0.0 (2016.09.07)
2
+
3
+ * add new required arrtibutes: `smtp_protocol`, `smtp_port` and `smtp_authenticator`
4
+ * 4 valid account types: `imap`, `pop3`, `imapssl`, `pop3ssl`
5
+
1
6
  === 2.0.1 (2016.08.31)
2
7
 
3
8
  * update tests
data/README.md CHANGED
@@ -43,17 +43,23 @@ Mayaml.accounts_from_file(yaml_path).each { |account| ... }
43
43
  pass: sercet_password
44
44
  mailboxes:
45
45
  - INBOX
46
+ smtp_protocol: smtps
47
+ smtp_port: 587
48
+ smtp_authenticator: login
46
49
  ```
47
50
 
48
51
  #### Required attributes
49
52
 
50
53
  * `name`
51
- * `type`
54
+ * `realname`
55
+ * `type` [imap | imapssl | pop3 | pop3ssl]
52
56
  * `server`
53
57
  * `port`
54
58
  * `user`
55
59
  * `pass`
56
- * `realname`
60
+ * `smtp_protocol` [smpt | smtps]
61
+ * `smtp_port`
62
+ * `smtp_authenticator`
57
63
 
58
64
  #### Default attributes
59
65
 
data/lib/mayaml.rb CHANGED
@@ -40,6 +40,9 @@ module Mayaml
40
40
  builder.user raw_account.fetch("user")
41
41
  builder.pass raw_account.fetch("pass")
42
42
  builder.mailboxes raw_account.fetch("mailboxes", [])
43
+ builder.smtp_protocol raw_account.fetch("smtp_protocol")
44
+ builder.smtp_port raw_account.fetch("smtp_port")
45
+ builder.smtp_authenticator raw_account.fetch("smtp_authenticator")
43
46
  end
44
47
  end
45
48
  end
@@ -19,7 +19,8 @@
19
19
 
20
20
  module Mayaml
21
21
  class MailAccount
22
- attr_accessor :name, :default, :realname, :type, :server, :port, :user, :pass, :mailboxes
22
+ attr_accessor :name, :default, :realname, :type, :server, :port, :user, :pass, \
23
+ :mailboxes, :smtp_protocol, :smtp_port, :smtp_authenticator
23
24
 
24
25
  def initialize
25
26
  set_default_flag
@@ -39,6 +40,7 @@ module Mayaml
39
40
  <<-DESC
40
41
  Account#{default_mark}: #{@name}<#{@realname}> | user: #{@user}:#{@pass}
41
42
  #{@type} - #{@server}:#{@port} [#{@mailboxes.join(",")}]
43
+ #{@smtp_protocol} - #{@server}:#{@smtp_port} [auth: #{@smtp_authenticator}]
42
44
  DESC
43
45
  end
44
46
  end
@@ -23,6 +23,7 @@ require "mayaml/mail_account/type_validator"
23
23
  require "mayaml/mail_account/port_validator"
24
24
  require "mayaml/mail_account/mailboxes_validator"
25
25
  require "mayaml/mail_account/default_flag_validator"
26
+ require "mayaml/mail_account/smtp_protocol_validator"
26
27
 
27
28
  module Mayaml
28
29
  class MailAccount
@@ -85,6 +86,20 @@ module Mayaml
85
86
  end
86
87
  end
87
88
 
89
+ def smtp_protocol(str)
90
+ valid_attribute SmtpProtocolValidator, WrongAccountSmtpProtocol, str
91
+ @account.smtp_protocol = str.to_sym
92
+ end
93
+
94
+ def smtp_port(nr)
95
+ valid_attribute PortValidator, WrongAccountSmtpPort, nr
96
+ @account.smtp_port = nr.to_i
97
+ end
98
+
99
+ def smtp_authenticator(str)
100
+ @account.smtp_authenticator = str
101
+ end
102
+
88
103
  def account
89
104
  obj = valid_account
90
105
  @account = ::Mayaml::MailAccount.new
@@ -37,5 +37,11 @@ module Mayaml
37
37
 
38
38
  class WrongAccountMailboxes < Error
39
39
  end
40
+
41
+ class WrongAccountSmtpPort < Error
42
+ end
43
+
44
+ class WrongAccountSmtpProtocol < Error
45
+ end
40
46
  end
41
47
  end
@@ -24,17 +24,63 @@ module Mayaml
24
24
 
25
25
  def initialize(mail_account)
26
26
  @errors = []
27
- @errors << "Missing name attribute." if mail_account.name.nil?
28
- @errors << "Missing realname attribute." if mail_account.realname.nil?
29
- @errors << "Missing type attribute." if mail_account.type.nil?
30
- @errors << "Missing server attribute." if mail_account.server.nil?
31
- @errors << "Missing user attribute." if mail_account.user.nil?
32
- @errors << "Missing pass attribute." if mail_account.pass.nil?
27
+ @mail_account = mail_account
28
+ check_mail_account_attrs
33
29
  end
34
30
 
35
31
  def valid?
36
32
  @errors.empty?
37
33
  end
34
+
35
+ private
36
+
37
+ def check_mail_account_attrs
38
+ check_missing_name
39
+ check_missing_realname
40
+ check_missing_type
41
+ check_missing_server
42
+ check_missing_user
43
+ check_missing_pass
44
+ check_missing_smtp_protocol
45
+ check_missing_smtp_port
46
+ check_missing_smtp_authenticator
47
+ end
48
+
49
+ def check_missing_name
50
+ @errors << "Missing name attribute." if @mail_account.name.nil?
51
+ end
52
+
53
+ def check_missing_realname
54
+ @errors << "Missing realname attribute." if @mail_account.realname.nil?
55
+ end
56
+
57
+ def check_missing_type
58
+ @errors << "Missing type attribute." if @mail_account.type.nil?
59
+ end
60
+
61
+ def check_missing_server
62
+ @errors << "Missing server attribute." if @mail_account.server.nil?
63
+ end
64
+
65
+ def check_missing_user
66
+ @errors << "Missing user attribute." if @mail_account.user.nil?
67
+ end
68
+
69
+ def check_missing_pass
70
+ @errors << "Missing pass attribute." if @mail_account.pass.nil?
71
+ end
72
+
73
+ def check_missing_smtp_protocol
74
+ @errors << "Missing smtp_protocol attribute." if @mail_account.smtp_protocol.nil?
75
+ end
76
+
77
+ def check_missing_smtp_port
78
+ @errors << "Missing smtp_port attribute." if @mail_account.smtp_port.nil?
79
+ end
80
+
81
+ def check_missing_smtp_authenticator
82
+ @errors << "Missing smtp_authenticator attribute." if @mail_account.smtp_authenticator.nil?
83
+ end
38
84
  end
39
85
  end
40
86
  end
@@ -0,0 +1,40 @@
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 SmtpProtocolValidator
23
+ attr_reader :errors
24
+ VALID_TYPES = [:smtp, :smtps].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
+ types = VALID_TYPES.join(", ")
31
+ @errors << "Mail account smtp_protocol is invalid. Allowed types: #{types}."
32
+ end
33
+ end
34
+
35
+ def valid?
36
+ @errors.empty?
37
+ end
38
+ end
39
+ end
40
+ end
@@ -21,7 +21,7 @@ module Mayaml
21
21
  class MailAccount
22
22
  class TypeValidator
23
23
  attr_reader :errors
24
- VALID_TYPES = [:imap, :pop3].freeze
24
+ VALID_TYPES = [:imap, :pop3, :imapssl, :pop3ssl].freeze
25
25
 
26
26
  def initialize(type)
27
27
  @errors = []
@@ -18,5 +18,5 @@
18
18
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
19
 
20
20
  module Mayaml
21
- VERSION = "2.0.1".freeze
21
+ VERSION = "3.0.0".freeze
22
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mayaml
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Szymon Kopciewski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-31 00:00:00.000000000 Z
11
+ date: 2016-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -102,6 +102,7 @@ files:
102
102
  - lib/mayaml/mail_account/mailboxes_validator.rb
103
103
  - lib/mayaml/mail_account/port_validator.rb
104
104
  - lib/mayaml/mail_account/required_attributes_validator.rb
105
+ - lib/mayaml/mail_account/smtp_protocol_validator.rb
105
106
  - lib/mayaml/mail_account/type_validator.rb
106
107
  - lib/mayaml/parser.rb
107
108
  - lib/mayaml/version.rb