fastlane-plugin-gmail_notify 0.1.0 → 0.1.2
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11eb92c91ec2c321fd6bb98a34eea0344bf2d47d4bdf9360a73c8b792642ad60
|
4
|
+
data.tar.gz: f50b36732ce423bfefe9b247b727103b36dcc13d233fdcfedaf09ee1c32a92c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab3580acfad95be0036c468be8ad0c0fc1b90f917fc87b1c1b9922485815632f4268f5fc182b5c1413f2cee771d5a4112bc511fc47c93f76d9fc7421c904108a
|
7
|
+
data.tar.gz: ee469e09ca07b1ef7a1128ac4c4e7d44bf5292c9f20f33f636c4d40b46f4999595ca22d30dc961f10a6354e08ed99d1968b2272dbb74964c6c07062d7ece5b13
|
@@ -1,39 +1,45 @@
|
|
1
1
|
require "fastlane/action"
|
2
|
+
require "fastlane_core/configuration/config_item"
|
2
3
|
require_relative "../helper/gmail_notify_helper"
|
3
4
|
|
4
5
|
module Fastlane
|
5
6
|
module Actions
|
6
7
|
class GmailNotifyAction < Action
|
7
8
|
def self.run(params)
|
9
|
+
UI.message("The gmail_notify plugin is working!")
|
8
10
|
|
9
11
|
require 'pony'
|
12
|
+
require 'erb'
|
10
13
|
|
11
|
-
|
12
|
-
|
13
|
-
eth = Fastlane::ErbTemplateHelper
|
14
|
-
html_template = eth.load_from_path(params[:template_file])
|
15
|
-
|
16
|
-
body = eth.render(html_template, params[:placeholders])
|
14
|
+
body = ERB.new(File.read(params[:template_file]), trim_mode: nil).result_with_hash(params[:placeholders])
|
17
15
|
|
18
16
|
Pony.mail({
|
19
|
-
:
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
30
|
-
:
|
31
|
-
:
|
32
|
-
:
|
33
|
-
}
|
17
|
+
to: params[:recipients],
|
18
|
+
cc: params[:cc],
|
19
|
+
subject: params[:subject],
|
20
|
+
html_body: body,
|
21
|
+
body_part_header: { content_disposition: "inline" },
|
22
|
+
via: :smtp,
|
23
|
+
via_options: {
|
24
|
+
address: "smtp.gmail.com",
|
25
|
+
port: "587",
|
26
|
+
enable_starttls_auto: true,
|
27
|
+
user_name: params[:smtp_email],
|
28
|
+
password: params[:smtp_password],
|
29
|
+
authentication: :plain, # :plain, :login, :cram_md5, no auth by default
|
30
|
+
domain: "localhost.localdomain" # the HELO domain provided by the client to the server
|
31
|
+
}
|
34
32
|
})
|
35
33
|
end
|
36
34
|
|
35
|
+
def self.test(params)
|
36
|
+
UI.message("The gmail_notify plugin is working!")
|
37
|
+
|
38
|
+
body = ERB.new(File.read(params[:template_file]), trim_mode: nil).result_with_hash(params[:placeholders])
|
39
|
+
|
40
|
+
puts(body)
|
41
|
+
end
|
42
|
+
|
37
43
|
def self.description
|
38
44
|
"Sends a mail using SMTP"
|
39
45
|
end
|
@@ -53,12 +59,12 @@ module Fastlane
|
|
53
59
|
|
54
60
|
def self.available_options
|
55
61
|
[
|
56
|
-
FastlaneCore::ConfigItem.new(key: :
|
62
|
+
FastlaneCore::ConfigItem.new(key: :smtp_email,
|
57
63
|
env_name: "GMAIL_NOTIFY_SENDER_EMAIL",
|
58
64
|
description: "Gmail account to login with",
|
59
65
|
optional: false,
|
60
66
|
type: String),
|
61
|
-
FastlaneCore::ConfigItem.new(key: :
|
67
|
+
FastlaneCore::ConfigItem.new(key: :smtp_password,
|
62
68
|
env_name: "GMAIL_NOTIFY_SENDER_PASSWORD",
|
63
69
|
description: "Password of Gmail account to login with",
|
64
70
|
optional: false,
|
@@ -83,16 +89,11 @@ module Fastlane
|
|
83
89
|
description: "Path of template file",
|
84
90
|
optional: false,
|
85
91
|
type: String),
|
86
|
-
FastlaneCore::ConfigItem.new(key: :release_notes_file,
|
87
|
-
env_name: "GMAIL_NOTIFY_RELEASE_NOTES_FILE",
|
88
|
-
description: "Path of release notes file",
|
89
|
-
optional: false,
|
90
|
-
type: String),
|
91
92
|
FastlaneCore::ConfigItem.new(key: :placeholders,
|
92
93
|
env_name: "GMAIL_NOTIFY_TEMPLATE_PLACEHOLDERS",
|
93
94
|
description: "Placeholders for email template",
|
94
95
|
optional: false,
|
95
|
-
type: Hash)
|
96
|
+
type: Hash)
|
96
97
|
]
|
97
98
|
end
|
98
99
|
|
@@ -2,7 +2,7 @@ require "fastlane_core/ui/ui"
|
|
2
2
|
require "erb"
|
3
3
|
|
4
4
|
module Fastlane
|
5
|
-
UI = FastlaneCore::UI unless Fastlane.const_defined?(
|
5
|
+
UI = FastlaneCore::UI unless Fastlane.const_defined?(:UI)
|
6
6
|
|
7
7
|
module Helper
|
8
8
|
class GmailNotifyHelper
|
@@ -13,40 +13,5 @@ module Fastlane
|
|
13
13
|
UI.message("Hello from the gmail_notify plugin helper!")
|
14
14
|
end
|
15
15
|
end
|
16
|
-
|
17
|
-
class ErbTemplateHelper
|
18
|
-
def self.load(template_name)
|
19
|
-
path = "#{Fastlane::ROOT}/lib/assets/#{template_name}.erb"
|
20
|
-
load_from_path(path)
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.load_from_path(template_filepath)
|
24
|
-
unless File.exist?(template_filepath)
|
25
|
-
UI.user_error!("Could not find template at path '#{template_filepath}'")
|
26
|
-
end
|
27
|
-
File.read(template_filepath)
|
28
|
-
end
|
29
|
-
|
30
|
-
def self.render(template, template_vars_hash, trim_mode = nil)
|
31
|
-
Fastlane::Helper::ErbalT.new(template_vars_hash, trim_mode).render(template)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
class ErbalT < OpenStruct
|
36
|
-
def initialize(hash, trim_mode = nil)
|
37
|
-
super(hash)
|
38
|
-
@trim_mode = trim_mode
|
39
|
-
end
|
40
|
-
|
41
|
-
def render(template)
|
42
|
-
# From Ruby 2.6, ERB.new takes keyword arguments and positional ones are deprecated
|
43
|
-
# https://bugs.ruby-lang.org/issues/14256
|
44
|
-
if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new("2.6.0")
|
45
|
-
ERB.new(template, trim_mode: @trim_mode).result(binding)
|
46
|
-
else
|
47
|
-
# ERB.new(template, nil, @trim_mode).result(binding)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
16
|
end
|
52
17
|
end
|