Class: Utility
- Inherits:
-
Object
- Object
- Utility
- Defined in:
- lib/userextension/utilities.rb
Class Method Summary collapse
- .email(from_email_id, to_email_id, cc_email_id, prj_name, build_zip) ⇒ Object
- .zip(dir, zip_dir, remove_after = false) ⇒ Object
Class Method Details
.email(from_email_id, to_email_id, cc_email_id, prj_name, build_zip) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/userextension/utilities.rb', line 19 def self.email(from_email_id, to_email_id, cc_email_id, prj_name, build_zip) Mail.defaults do delivery_method :smtp, {:address => 'smtp.sendgrid.net', :port => 587, :domain => 'vtr.com', :user_name => 'locamotiv', :password => 'locamotiv', :authentication => 'plain', :enable_starttls_auto => true} end mail = Mail.new do from [from_email_id.to_s] to [to_email_id.to_s] cc [cc_email_id.to_s] subject Time.now.to_s + prj_name +' Test - Automation Script Result' html_part do content_type 'text/html; charset=UTF-8' body '<b>Script Result</b>' end add_file build_zip end mail.deliver! end |
.zip(dir, zip_dir, remove_after = false) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/userextension/utilities.rb', line 3 def self.zip(dir, zip_dir, remove_after = false) Zip::ZipFile.open(zip_dir, Zip::ZipFile::CREATE) do |zipfile| Find.find(dir) do |path| Find.prune if File.basename(path)[0] == ?. dest = /#{dir}\/(\w.*)/.match(path) # Skip files if they exists begin zipfile.add(dest[1], path) if dest rescue Zip::ZipEntryExistsError end end end FileUtils.rm_rf(dir) if remove_after end |