mayaml 3.0.1 → 4.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e9874c9e37bfc49de675f95dfc81d13b97e54f4d
4
- data.tar.gz: a476d041cbf9d53b1d839a02a88a57bb67a561ec
3
+ metadata.gz: 74e3d6707b071d1f972bfb024d43eac1f5a1ca54
4
+ data.tar.gz: 088d0075bbb947df082e5477bf9ea97528511a5f
5
5
  SHA512:
6
- metadata.gz: 55e738f33f89bde34d756cfeb4f77a8771e29ab6d59c6eab69c58ac19de0078994862f39f8e6c83c5bd20b8c05de4b4d946669e2a6ccf07b98ebdbed8a28d2cd
7
- data.tar.gz: 608733f46b565b35b775e97b31d340d56317f3f349b3bdc2cc87a83ccbe5ee8573bcf3f0c990f1c37586fc14d5a702a4ff74a4cca3f8af231f3f12f89d0bb031
6
+ metadata.gz: 5b567d121147740c830bb684ec926607b35275bbc8ae328c6932fbfe56cbdb8e4e4a72363742861fc6ab8f4eaa92454a6f2da75ac81dbbfacb3740fa82d405c7
7
+ data.tar.gz: b5a057671e202871bfd38de08745055186b9653e1daa926dba0ef71436b7b2723c2a4c2f5ab1758605144fdee944eeec3c439c4ba8f4d5db12c5d19d50d8894c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ### 4.0.0 (2017.04.06)
2
+
3
+ * add smpt_server attribute
4
+ * some refactoring
5
+ * update license and cleanup
6
+
1
7
  ### 3.0.1 (2017.04.06)
2
8
 
3
9
  * fix travis integration
data/README.md CHANGED
@@ -47,6 +47,7 @@ Mayaml.accounts_from_file(yaml_path).each { |account| ... }
47
47
  smtp_protocol: smtps
48
48
  smtp_port: 587
49
49
  smtp_authenticator: login
50
+ smtp_server: test.mailserver.com
50
51
  ```
51
52
 
52
53
  #### Required attributes
@@ -61,6 +62,7 @@ Mayaml.accounts_from_file(yaml_path).each { |account| ... }
61
62
  * `smtp_protocol` [smpt | smtps]
62
63
  * `smtp_port`
63
64
  * `smtp_authenticator`
65
+ * `smtp_server`
64
66
 
65
67
  #### Default attributes
66
68
 
data/bin/mayaml-check CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- # Copyright (C) 2016 Szymon Kopciewski
4
+ # Copyright (C) 2017 Szymon Kopciewski
5
5
  #
6
6
  # This file is part of Mayaml.
7
7
  #
data/lib/mayaml/error.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  # frozen_string_literal: true
3
3
 
4
- # Copyright (C) 2016 Szymon Kopciewski
4
+ # Copyright (C) 2017 Szymon Kopciewski
5
5
  #
6
6
  # This file is part of Mayaml.
7
7
  #
@@ -1,7 +1,6 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
- # Copyright (C) 2016 Szymon Kopciewski
3
+ # Copyright (C) 2017 Szymon Kopciewski
5
4
  #
6
5
  # This file is part of Mayaml.
7
6
  #
@@ -101,6 +100,10 @@ module Mayaml
101
100
  @account.smtp_authenticator = str
102
101
  end
103
102
 
103
+ def smtp_server(str)
104
+ @account.smtp_server = str
105
+ end
106
+
104
107
  def account
105
108
  obj = valid_account
106
109
  @account = ::Mayaml::MailAccount.new
@@ -1,7 +1,6 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
- # Copyright (C) 2016 Szymon Kopciewski
3
+ # Copyright (C) 2017 Szymon Kopciewski
5
4
  #
6
5
  # This file is part of Mayaml.
7
6
  #
@@ -21,17 +20,23 @@
21
20
  module Mayaml
22
21
  class MailAccount
23
22
  class DefaultFlagValidator
24
- attr_reader :errors
25
-
26
23
  def initialize(flag)
27
- @errors = []
28
- unless [true, false, "true", "false"].include? flag
29
- @errors << "Flag need to be 'true' or 'false'"
30
- end
24
+ @flag = flag
25
+ errors << "Flag need to be 'true' or 'false'" unless valid_flag?
31
26
  end
32
27
 
33
28
  def valid?
34
- @errors.empty?
29
+ errors.empty?
30
+ end
31
+
32
+ def errors
33
+ @errors ||= []
34
+ end
35
+
36
+ private
37
+
38
+ def valid_flag?
39
+ [true, false, "true", "false"].include? @flag
35
40
  end
36
41
  end
37
42
  end
@@ -1,7 +1,6 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
- # Copyright (C) 2016 Szymon Kopciewski
3
+ # Copyright (C) 2017 Szymon Kopciewski
5
4
  #
6
5
  # This file is part of Mayaml.
7
6
  #
@@ -1,7 +1,6 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
- # Copyright (C) 2016 Szymon Kopciewski
3
+ # Copyright (C) 2017 Szymon Kopciewski
5
4
  #
6
5
  # This file is part of Mayaml.
7
6
  #
@@ -21,21 +20,33 @@
21
20
  module Mayaml
22
21
  class MailAccount
23
22
  class MailboxesValidator
24
- attr_reader :errors
25
-
26
23
  def initialize(mailboxes)
27
- @errors = []
28
- @errors << "Mailboxes should be array." unless mailboxes.instance_of? Array
29
- if mailboxes.instance_of?(Array) && mailboxes.empty?
30
- @errors << "Mailboxes can not be empty."
31
- end
32
- if mailboxes.instance_of?(Array) && !mailboxes.all? { |box| box.instance_of? String }
33
- @errors << "Mailboxes should all be strings."
34
- end
24
+ @mailboxes = mailboxes
25
+ errors << "Mailboxes should be array." unless right_mailboxes_type?
26
+ errors << "Mailboxes can not be empty." unless mailboxes_exists?
27
+ errors << "Mailboxes should all be strings." unless right_mailboxes_content?
35
28
  end
36
29
 
37
30
  def valid?
38
- @errors.empty?
31
+ errors.empty?
32
+ end
33
+
34
+ def errors
35
+ @errors ||= []
36
+ end
37
+
38
+ private
39
+
40
+ def right_mailboxes_type?
41
+ @mailboxes.instance_of? Array
42
+ end
43
+
44
+ def mailboxes_exists?
45
+ right_mailboxes_type? && !@mailboxes.empty?
46
+ end
47
+
48
+ def right_mailboxes_content?
49
+ right_mailboxes_type? && @mailboxes.all? { |box| box.instance_of? String }
39
50
  end
40
51
  end
41
52
  end
@@ -1,7 +1,6 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
- # Copyright (C) 2016 Szymon Kopciewski
3
+ # Copyright (C) 2017 Szymon Kopciewski
5
4
  #
6
5
  # This file is part of Mayaml.
7
6
  #
@@ -21,17 +20,24 @@
21
20
  module Mayaml
22
21
  class MailAccount
23
22
  class PortValidator
24
- attr_reader :errors
25
-
26
23
  def initialize(port)
27
- @errors = []
28
- port = port.respond_to?(:to_i) ? port.to_i : 0
29
- @errors << "Mail account port is invalid." if port == 0
30
- @errors << "Mail account port could not be negative." if port < 0
24
+ port = conver_port(port)
25
+ errors << "Mail account port is invalid." if port.zero?
26
+ errors << "Mail account port could not be negative." if port.negative?
31
27
  end
32
28
 
33
29
  def valid?
34
- @errors.empty?
30
+ errors.empty?
31
+ end
32
+
33
+ def errors
34
+ @errors ||= []
35
+ end
36
+
37
+ private
38
+
39
+ def conver_port(port)
40
+ port.respond_to?(:to_i) ? port.to_i : 0
35
41
  end
36
42
  end
37
43
  end
@@ -1,7 +1,6 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
- # Copyright (C) 2016 Szymon Kopciewski
3
+ # Copyright (C) 2017 Szymon Kopciewski
5
4
  #
6
5
  # This file is part of Mayaml.
7
6
  #
@@ -45,6 +44,7 @@ module Mayaml
45
44
  check_missing_smtp_protocol
46
45
  check_missing_smtp_port
47
46
  check_missing_smtp_authenticator
47
+ check_missing_smtp_server
48
48
  end
49
49
 
50
50
  def check_missing_name
@@ -82,6 +82,10 @@ module Mayaml
82
82
  def check_missing_smtp_authenticator
83
83
  @errors << "Missing smtp_authenticator attribute." if @mail_account.smtp_authenticator.nil?
84
84
  end
85
+
86
+ def check_missing_smtp_server
87
+ @errors << "Missing smtp_server attribute." if @mail_account.smtp_server.nil?
88
+ end
85
89
  end
86
90
  end
87
91
  end
@@ -1,7 +1,6 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
- # Copyright (C) 2016 Szymon Kopciewski
3
+ # Copyright (C) 2017 Szymon Kopciewski
5
4
  #
6
5
  # This file is part of Mayaml.
7
6
  #
@@ -21,20 +20,33 @@
21
20
  module Mayaml
22
21
  class MailAccount
23
22
  class SmtpProtocolValidator
24
- attr_reader :errors
25
23
  VALID_TYPES = [:smtp, :smtps].freeze
26
24
 
27
25
  def initialize(type)
28
- @errors = []
29
- type = type.to_sym if type.respond_to? :to_sym
30
- unless VALID_TYPES.include?(type)
31
- types = VALID_TYPES.join(", ")
32
- @errors << "Mail account smtp_protocol is invalid. Allowed types: #{types}."
33
- end
26
+ @type = convert_type(type)
27
+ errors << "Mail account smtp_protocol is invalid. Allowed: #{types}." unless valid_type?
34
28
  end
35
29
 
36
30
  def valid?
37
- @errors.empty?
31
+ errors.empty?
32
+ end
33
+
34
+ def errors
35
+ @errors ||= []
36
+ end
37
+
38
+ private
39
+
40
+ def convert_type(type)
41
+ type.to_sym if type.respond_to? :to_sym
42
+ end
43
+
44
+ def valid_type?
45
+ VALID_TYPES.include? @type
46
+ end
47
+
48
+ def types
49
+ VALID_TYPES.join(", ")
38
50
  end
39
51
  end
40
52
  end
@@ -1,7 +1,6 @@
1
- # encoding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
- # Copyright (C) 2016 Szymon Kopciewski
3
+ # Copyright (C) 2017 Szymon Kopciewski
5
4
  #
6
5
  # This file is part of Mayaml.
7
6
  #
@@ -21,19 +20,33 @@
21
20
  module Mayaml
22
21
  class MailAccount
23
22
  class TypeValidator
24
- attr_reader :errors
25
23
  VALID_TYPES = [:imap, :pop3, :imapssl, :pop3ssl].freeze
26
24
 
27
25
  def initialize(type)
28
- @errors = []
29
- type = type.to_sym if type.respond_to? :to_sym
30
- unless VALID_TYPES.include?(type)
31
- @errors << "Mail account type is invalid. Allowed types: #{VALID_TYPES.join(", ")}."
32
- end
26
+ @type = convert_type(type)
27
+ errors << "Mail account type is invalid. Allowed types: #{valid_types}." unless valid_type?
33
28
  end
34
29
 
35
30
  def valid?
36
- @errors.empty?
31
+ errors.empty?
32
+ end
33
+
34
+ def errors
35
+ @errors ||= []
36
+ end
37
+
38
+ private
39
+
40
+ def convert_type(type)
41
+ type.to_sym if type.respond_to? :to_sym
42
+ end
43
+
44
+ def valid_type?
45
+ VALID_TYPES.include? @type
46
+ end
47
+
48
+ def valid_types
49
+ VALID_TYPES.join(", ")
37
50
  end
38
51
  end
39
52
  end
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  # frozen_string_literal: true
3
3
 
4
- # Copyright (C) 2016 Szymon Kopciewski
4
+ # Copyright (C) 2017 Szymon Kopciewski
5
5
  #
6
6
  # This file is part of Mayaml.
7
7
  #
@@ -21,7 +21,7 @@
21
21
  module Mayaml
22
22
  class MailAccount
23
23
  attr_accessor :name, :default, :realname, :type, :server, :port, :user, :pass, \
24
- :mailboxes, :smtp_protocol, :smtp_port, :smtp_authenticator
24
+ :mailboxes, :smtp_protocol, :smtp_port, :smtp_authenticator, :smtp_server
25
25
 
26
26
  def initialize
27
27
  set_default_flag
@@ -41,7 +41,7 @@ module Mayaml
41
41
  <<-DESC
42
42
  Account#{default_mark}: #{@name}<#{@realname}> | user: #{@user}:#{@pass}
43
43
  #{@type} - #{@server}:#{@port} [#{@mailboxes.join(",")}]
44
- #{@smtp_protocol} - #{@server}:#{@smtp_port} [auth: #{@smtp_authenticator}]
44
+ #{@smtp_protocol} - #{@smtp_server}:#{@smtp_port} [auth: #{@smtp_authenticator}]
45
45
  DESC
46
46
  end
47
47
  end
data/lib/mayaml/parser.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  # frozen_string_literal: true
3
3
 
4
- # Copyright (C) 2016 Szymon Kopciewski
4
+ # Copyright (C) 2017 Szymon Kopciewski
5
5
  #
6
6
  # This file is part of Mayaml.
7
7
  #
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  # frozen_string_literal: true
3
3
 
4
- # Copyright (C) 2016 Szymon Kopciewski
4
+ # Copyright (C) 2017 Szymon Kopciewski
5
5
  #
6
6
  # This file is part of Mayaml.
7
7
  #
@@ -19,5 +19,5 @@
19
19
  # along with this program. If not, see <http://www.gnu.org/licenses/>.
20
20
 
21
21
  module Mayaml
22
- VERSION = "3.0.1"
22
+ VERSION = "4.0.0"
23
23
  end
data/lib/mayaml.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  # frozen_string_literal: true
3
3
 
4
- # Copyright (C) 2016 Szymon Kopciewski
4
+ # Copyright (C) 2017 Szymon Kopciewski
5
5
  #
6
6
  # This file is part of Mayaml.
7
7
  #
@@ -44,6 +44,7 @@ module Mayaml
44
44
  builder.smtp_protocol raw_account.fetch("smtp_protocol")
45
45
  builder.smtp_port raw_account.fetch("smtp_port")
46
46
  builder.smtp_authenticator raw_account.fetch("smtp_authenticator")
47
+ builder.smtp_server raw_account.fetch("smtp_server")
47
48
  end
48
49
  end
49
50
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mayaml
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Szymon Kopciewski