fastlane-plugin-gmail_notify 0.1.0 → 0.1.1
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a65c983d4b84841241522deef085b6e5be94d8c66378b799de2adf71db1a7d8f
|
4
|
+
data.tar.gz: c810ff562a4206036e8489f73aa7dfce69e6c9108e498d03df3802a6b37a2aa4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90bd144efbe4052a6c87c9689ec4e66f628f2a2dac68746634e4dae414ef68c8077c0045fb33d4012256047499ed098b688e60803904e41134673dd4db8c3f55
|
7
|
+
data.tar.gz: 006cbd2d1d56671fdda86f21b4db19c1043ab4ac901d72df76dce69afccbddfa37d3417a28c61287539550dfbdc068c085f4c28556b70d910960dac737f9b861
|
@@ -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[:sender_email],
|
28
|
+
password: params[:sender_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
|
@@ -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
|