Class: Lazylead::Task::Svn::Diff
- Inherits:
-
Object
- Object
- Lazylead::Task::Svn::Diff
- Defined in:
- lib/lazylead/task/svn/diff.rb
Overview
Send notification about modification of svn files since particular
revision.
Instance Method Summary collapse
-
#initialize(log = Log.new) ⇒ Diff
constructor
A new instance of Diff.
-
#make_attachment(stdout, opts) ⇒ Object
Assemble HTML for attachment based on SVN output.
- #run(_, postman, opts) ⇒ Object
-
#send_email(stdout, postman, opts) ⇒ Object
Send email with svn log as an attachment.
Constructor Details
Instance Method Details
#make_attachment(stdout, opts) ⇒ Object
Assemble HTML for attachment based on SVN output
76 77 78 79 80 81 |
# File 'lib/lazylead/task/svn/diff.rb', line 76 def (stdout, opts) Email.new( opts["template-attachment"], opts.merge(stdout: stdout, version: Lazylead::VERSION) ).render end |
#run(_, postman, opts) ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/lazylead/task/svn/diff.rb', line 44 def run(_, postman, opts) cmd = [ "svn log --diff --no-auth-cache", "--username #{opts.decrypt('svn_user', 'svn_salt')}", "--password #{opts.decrypt('svn_password', 'svn_salt')}", "-r#{opts['since_rev']}:HEAD #{opts['svn_url']}" ] stdout = `#{cmd.join(" ")}` send_email stdout, postman, opts unless stdout.blank? end |
#send_email(stdout, postman, opts) ⇒ Object
Send email with svn log as an attachment. The attachment won’t be stored locally and we’ll be removed once
mail sent.
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/lazylead/task/svn/diff.rb', line 58 def send_email(stdout, postman, opts) Dir.mktmpdir do |dir| name = "svn-log-#{Date.today.strftime('%d-%b-%Y')}.html" f = File.open(File.join(dir, name), "w") begin f.write (stdout, opts) f.close postman.send opts.merge(stdout: stdout, attachments: [f.path]) ensure File.delete(f) end rescue StandardError => e @log.error "ll-010: Can't send an email for #{opts} due to " \ "#{Backtrace.new(e)}' based on #{stdout}'" end end |