Class: RGitHook::RefUpdate
- Inherits:
-
Object
- Object
- RGitHook::RefUpdate
- Defined in:
- lib/rgithook/githook.rb
Overview
Un RefUpdate es una coleción de commits
Instance Attribute Summary collapse
-
#ref ⇒ Object
readonly
Returns the value of attribute ref.
Instance Method Summary collapse
-
#initialize(string) ⇒ RefUpdate
constructor
A new instance of RefUpdate.
- #sendmail(send = true) ⇒ Object
- #to_html ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(string) ⇒ RefUpdate
Returns a new instance of RefUpdate.
58 59 60 61 62 |
# File 'lib/rgithook/githook.rb', line 58 def initialize(string) @rev_old, @rev_new, @ref = string.split(" ") commits = Git.rev_list(@rev_old, @rev_new).split @commits = commits.map {|c| Commit.new(c)} end |
Instance Attribute Details
#ref ⇒ Object (readonly)
Returns the value of attribute ref.
57 58 59 |
# File 'lib/rgithook/githook.rb', line 57 def ref @ref end |
Instance Method Details
#sendmail(send = true) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/rgithook/githook.rb', line 64 def sendmail( send = true ) to = Git.config("hooks.mailinglist").strip part = ::TMail::Mail.new part.set_content_type "text", "html" part.body = HTML_HEADER+to_html+HTML_FOOTER mail = ::TMail::Mail.new mail.to = to mail.from = format("%s@%s",@ref.gsub("/","."),%x(hostname).strip) mail.subject = format("%s se actualizo",@ref) mail.body = to_s mail.parts << part if( send ) sendmail = IO.popen("/usr/sbin/sendmail #{to}", "w") sendmail.write mail.to_s sendmail.close end mail.to_s end |
#to_html ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/rgithook/githook.rb', line 91 def to_html html = "" html << "<div>\n" html << "<h2>Actualización de #{@ref}</h2>" if @commits.size > 1 html << "<div style='border: 1px #006 solid; padding: 6px;'><ul style=style='margin: 0; padding: 0;line-height:1.0em'>" @commits.each do |commit| html << "<li style='list-style-type: none; margin: 0;padding: 0; font-size: 90%;'>#{commit.message.split("\n")[0]}<br/><ul style='margin: 0; padding: 0;line-height:1.0em'>" commit.files.each do |file| html << "<li style='color: #444;font-size: 0.9em; padding-left: 20px;list-style-type: none; margin: 0;padding: 0; font-size: 90%;margin: 5px 0px 10px 20px'><span>#{file.name} (<span style='color: green;'>+#{file.ins.to_s}</span>/<span style='color: red;'>-#{file.del.to_s}</span>)</span></li>\n" end html << "</ul></li>" end html << "</ul></div>\n" end html << "\n#{map {|c|c.to_html}.join}\n</div>\n" html end |
#to_s ⇒ Object
86 87 88 89 |
# File 'lib/rgithook/githook.rb', line 86 def to_s commits = map {|commit| commit.to_s} commits.join("\n") end |