Class: GitCommitMailer::PushInfo
- Defined in:
- lib/git-commit-mailer/push-info.rb
Constant Summary collapse
- REFERENCE_TYPE =
{ :branch => "branch", :annotated_tag => "annotated tag", :unannotated_tag => "unannotated tag" }
- CHANGE_TYPE =
{ :create => "created", :update => "updated", :delete => "deleted", }
Instance Attribute Summary collapse
-
#author_email ⇒ Object
readonly
Returns the value of attribute author_email.
-
#author_name ⇒ Object
readonly
Returns the value of attribute author_name.
-
#change_type ⇒ Object
readonly
Returns the value of attribute change_type.
-
#commits ⇒ Object
readonly
Returns the value of attribute commits.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#log ⇒ Object
readonly
Returns the value of attribute log.
-
#new_revision ⇒ Object
readonly
Returns the value of attribute new_revision.
-
#old_revision ⇒ Object
readonly
Returns the value of attribute old_revision.
-
#reference ⇒ Object
readonly
Returns the value of attribute reference.
-
#reference_type ⇒ Object
readonly
Returns the value of attribute reference_type.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
Instance Method Summary collapse
- #branch_changed? ⇒ Boolean
- #format_mail_body_html ⇒ Object
- #format_mail_body_text ⇒ Object
- #format_mail_subject ⇒ Object
- #headers ⇒ Object
-
#initialize(mailer, old_revision, new_revision, reference, reference_type, change_type, log, commits = []) ⇒ PushInfo
constructor
A new instance of PushInfo.
- #message_id ⇒ Object
- #revision ⇒ Object
Methods inherited from Info
#get_record, #get_records, #git, host_name, host_name=, #short_reference, #short_revision
Constructor Details
#initialize(mailer, old_revision, new_revision, reference, reference_type, change_type, log, commits = []) ⇒ PushInfo
Returns a new instance of PushInfo.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/git-commit-mailer/push-info.rb', line 24 def initialize(mailer, old_revision, new_revision, reference, reference_type, change_type, log, commits=[]) @mailer = mailer @old_revision = old_revision @new_revision = new_revision if @new_revision != '0' * 40 #XXX well, i need to properly fix this bug later. @revision = @new_revision else @revision = @old_revision end @reference = reference @reference_type = reference_type @log = log , = get_records(["%an", "%ae"]) @author_name = @author_email = @date = @mailer.date @change_type = change_type @commits = commits || [] end |
Instance Attribute Details
#author_email ⇒ Object (readonly)
Returns the value of attribute author_email.
22 23 24 |
# File 'lib/git-commit-mailer/push-info.rb', line 22 def @author_email end |
#author_name ⇒ Object (readonly)
Returns the value of attribute author_name.
22 23 24 |
# File 'lib/git-commit-mailer/push-info.rb', line 22 def @author_name end |
#change_type ⇒ Object (readonly)
Returns the value of attribute change_type.
22 23 24 |
# File 'lib/git-commit-mailer/push-info.rb', line 22 def change_type @change_type end |
#commits ⇒ Object (readonly)
Returns the value of attribute commits.
23 24 25 |
# File 'lib/git-commit-mailer/push-info.rb', line 23 def commits @commits end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
22 23 24 |
# File 'lib/git-commit-mailer/push-info.rb', line 22 def date @date end |
#log ⇒ Object (readonly)
Returns the value of attribute log.
21 22 23 |
# File 'lib/git-commit-mailer/push-info.rb', line 21 def log @log end |
#new_revision ⇒ Object (readonly)
Returns the value of attribute new_revision.
21 22 23 |
# File 'lib/git-commit-mailer/push-info.rb', line 21 def new_revision @new_revision end |
#old_revision ⇒ Object (readonly)
Returns the value of attribute old_revision.
21 22 23 |
# File 'lib/git-commit-mailer/push-info.rb', line 21 def old_revision @old_revision end |
#reference ⇒ Object (readonly)
Returns the value of attribute reference.
21 22 23 |
# File 'lib/git-commit-mailer/push-info.rb', line 21 def reference @reference end |
#reference_type ⇒ Object (readonly)
Returns the value of attribute reference_type.
21 22 23 |
# File 'lib/git-commit-mailer/push-info.rb', line 21 def reference_type @reference_type end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
22 23 24 |
# File 'lib/git-commit-mailer/push-info.rb', line 22 def subject @subject end |
Instance Method Details
#branch_changed? ⇒ Boolean
63 64 65 |
# File 'lib/git-commit-mailer/push-info.rb', line 63 def branch_changed? !@commits.empty? end |
#format_mail_body_html ⇒ Object
96 97 98 |
# File 'lib/git-commit-mailer/push-info.rb', line 96 def format_mail_body_html "<pre>#{ERB::Util.h(format_mail_body_text)}</pre>" end |
#format_mail_body_text ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/git-commit-mailer/push-info.rb', line 83 def format_mail_body_text body = "" body << "#{}\t#{@mailer.format_time(date)}\n" body << "\n" body << "New Push:\n" body << "\n" body << " Message:\n" log.rstrip.each_line do |line| body << " #{line}" end body << "\n\n" end |
#format_mail_subject ⇒ Object
78 79 80 81 |
# File 'lib/git-commit-mailer/push-info.rb', line 78 def format_mail_subject "(push) #{PushInfo::REFERENCE_TYPE[reference_type]} " + "(#{short_reference}) is #{PushInfo::CHANGE_TYPE[change_type]}." end |
#headers ⇒ Object
53 54 55 56 57 58 59 60 61 |
# File 'lib/git-commit-mailer/push-info.rb', line 53 def headers [ "X-Git-OldRev: #{old_revision}", "X-Git-NewRev: #{new_revision}", "X-Git-Refname: #{reference}", "X-Git-Reftype: #{REFERENCE_TYPE[reference_type]}", "Message-ID: #{}", ] end |
#message_id ⇒ Object
49 50 51 |
# File 'lib/git-commit-mailer/push-info.rb', line 49 def "<#{old_revision}.#{new_revision}@#{self.class.host_name}>" end |
#revision ⇒ Object
45 46 47 |
# File 'lib/git-commit-mailer/push-info.rb', line 45 def revision @new_revision end |