fastlane-plugin-gmail_notify 0.1.0 → 0.1.1

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: 77e3ddcf0622cd912e25c11e52279f57e8a0d3ae65fd12fa1a4901b6db29c40d
4
- data.tar.gz: 89998b8ea6018a9a85bab741f4b5347f88ecf188595e8bc9af1a2afbbb3691c1
3
+ metadata.gz: a65c983d4b84841241522deef085b6e5be94d8c66378b799de2adf71db1a7d8f
4
+ data.tar.gz: c810ff562a4206036e8489f73aa7dfce69e6c9108e498d03df3802a6b37a2aa4
5
5
  SHA512:
6
- metadata.gz: cfd29dcc45e16812151d7ed423ae2ebe767b408b19ddf171ae21fe1417a93230eaad099ec17f9a42d76ff1cf1260c5debb5701fe5610b3207534776a2142b7ff
7
- data.tar.gz: db4d9479c5a2065d0306c30bb505e94bea27e9af9da91298cf5c323680639f68c9d0ad25395c09c49485bb3aeb5593e55134b669d228ffb199f41b5b8275abc5
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
- release_notes = File.read(params[:release_notes_file]).gsub("*", "<li>").gsub("\n", "</li>")
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
- :to => params[:recipients],
20
- :cc => params[:cc],
21
- :subject => params[:subject],
22
- :html_body => body,
23
- :body_part_header => { content_disposition: "inline" },
24
- :via => :smtp,
25
- :via_options => {
26
- :address => "smtp.gmail.com",
27
- :port => "587",
28
- :enable_starttls_auto => true,
29
- :user_name => params[:sender_email],
30
- :password => params[:sender_password],
31
- :authentication => :plain, # :plain, :login, :cram_md5, no auth by default
32
- :domain => "localhost.localdomain", # the HELO domain provided by the client to the server
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?("UI")
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
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module GmailNotify
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-gmail_notify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Antony Leons