Class: Utility
- Inherits:
-
Object
- Object
- Utility
- Defined in:
- lib/userextension/utilities.rb
Class Method Summary collapse
Class Method Details
.email(email_id, build_zip) ⇒ Object
18 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 18 def self.email(email_id, 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 to [email_id.to_s] from '[email protected]' subject Time.now.to_s + '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 |