Class: GitCommitMailer::CommitInfo
- Defined in:
- lib/git-commit-mailer/commit-info.rb
Instance Attribute Summary collapse
-
#added_files ⇒ Object
readonly
Returns the value of attribute added_files.
-
#author_email ⇒ Object
readonly
Returns the value of attribute author_email.
-
#author_name ⇒ Object
readonly
Returns the value of attribute author_name.
-
#copied_files ⇒ Object
readonly
Returns the value of attribute copied_files.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#deleted_files ⇒ Object
readonly
Returns the value of attribute deleted_files.
-
#diffs ⇒ Object
readonly
Returns the value of attribute diffs.
-
#mailer ⇒ Object
readonly
Returns the value of attribute mailer.
-
#merge_commits ⇒ Object
readonly
Returns the value of attribute merge_commits.
-
#merge_status ⇒ Object
Returns the value of attribute merge_status.
-
#reference ⇒ Object
Returns the value of attribute reference.
-
#renamed_files ⇒ Object
readonly
Returns the value of attribute renamed_files.
-
#revision ⇒ Object
readonly
Returns the value of attribute revision.
-
#subject ⇒ Object
readonly
Returns the value of attribute subject.
-
#summary ⇒ Object
readonly
Returns the value of attribute summary.
-
#type_changed_files ⇒ Object
readonly
Returns the value of attribute type_changed_files.
-
#updated_files ⇒ Object
readonly
Returns the value of attribute updated_files.
Class Method Summary collapse
Instance Method Summary collapse
- #file_index(name) ⇒ Object
- #first_parent ⇒ Object
- #format_mail_body_html ⇒ Object
- #format_mail_body_text ⇒ Object
- #format_mail_subject ⇒ Object
- #headers ⇒ Object
-
#initialize(mailer, reference, revision) ⇒ CommitInfo
constructor
A new instance of CommitInfo.
- #merge? ⇒ Boolean
- #message_id ⇒ Object
- #other_parents ⇒ Object
- #related_mail_headers ⇒ Object
- #rss_content ⇒ Object
- #rss_title ⇒ Object
- #short_revision ⇒ Object
Methods inherited from Info
#get_record, #get_records, #git, host_name, host_name=, #short_reference
Constructor Details
#initialize(mailer, reference, revision) ⇒ CommitInfo
Returns a new instance of CommitInfo.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/git-commit-mailer/commit-info.rb', line 50 def initialize(mailer, reference, revision) @mailer = mailer @reference = reference @revision = revision @files = [] @added_files = [] @copied_files = [] @deleted_files = [] @updated_files = [] @renamed_files = [] @type_changed_files = [] set_records parse_file_status parse_diff @merge_status = [] @merge_commits = [] end |
Instance Attribute Details
#added_files ⇒ Object (readonly)
Returns the value of attribute added_files.
44 45 46 |
# File 'lib/git-commit-mailer/commit-info.rb', line 44 def added_files @added_files end |
#author_email ⇒ Object (readonly)
Returns the value of attribute author_email.
46 47 48 |
# File 'lib/git-commit-mailer/commit-info.rb', line 46 def @author_email end |
#author_name ⇒ Object (readonly)
Returns the value of attribute author_name.
46 47 48 |
# File 'lib/git-commit-mailer/commit-info.rb', line 46 def @author_name end |
#copied_files ⇒ Object (readonly)
Returns the value of attribute copied_files.
44 45 46 |
# File 'lib/git-commit-mailer/commit-info.rb', line 44 def copied_files @copied_files end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
46 47 48 |
# File 'lib/git-commit-mailer/commit-info.rb', line 46 def date @date end |
#deleted_files ⇒ Object (readonly)
Returns the value of attribute deleted_files.
44 45 46 |
# File 'lib/git-commit-mailer/commit-info.rb', line 44 def deleted_files @deleted_files end |
#diffs ⇒ Object (readonly)
Returns the value of attribute diffs.
45 46 47 |
# File 'lib/git-commit-mailer/commit-info.rb', line 45 def diffs @diffs end |
#mailer ⇒ Object (readonly)
Returns the value of attribute mailer.
43 44 45 |
# File 'lib/git-commit-mailer/commit-info.rb', line 43 def mailer @mailer end |
#merge_commits ⇒ Object (readonly)
Returns the value of attribute merge_commits.
49 50 51 |
# File 'lib/git-commit-mailer/commit-info.rb', line 49 def merge_commits @merge_commits end |
#merge_status ⇒ Object
Returns the value of attribute merge_status.
47 48 49 |
# File 'lib/git-commit-mailer/commit-info.rb', line 47 def merge_status @merge_status end |
#reference ⇒ Object
Returns the value of attribute reference.
43 44 45 |
# File 'lib/git-commit-mailer/commit-info.rb', line 43 def reference @reference end |
#renamed_files ⇒ Object (readonly)
Returns the value of attribute renamed_files.
45 46 47 |
# File 'lib/git-commit-mailer/commit-info.rb', line 45 def renamed_files @renamed_files end |
#revision ⇒ Object (readonly)
Returns the value of attribute revision.
43 44 45 |
# File 'lib/git-commit-mailer/commit-info.rb', line 43 def revision @revision end |
#subject ⇒ Object (readonly)
Returns the value of attribute subject.
46 47 48 |
# File 'lib/git-commit-mailer/commit-info.rb', line 46 def subject @subject end |
#summary ⇒ Object (readonly)
Returns the value of attribute summary.
46 47 48 |
# File 'lib/git-commit-mailer/commit-info.rb', line 46 def summary @summary end |
#type_changed_files ⇒ Object (readonly)
Returns the value of attribute type_changed_files.
45 46 47 |
# File 'lib/git-commit-mailer/commit-info.rb', line 45 def type_changed_files @type_changed_files end |
#updated_files ⇒ Object (readonly)
Returns the value of attribute updated_files.
44 45 46 |
# File 'lib/git-commit-mailer/commit-info.rb', line 44 def updated_files @updated_files end |
Class Method Details
.unescape_file_path(file_path) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/git-commit-mailer/commit-info.rb', line 22 def unescape_file_path(file_path) if file_path =~ /\A"(.*)"\z/ escaped_file_path = $1 if escaped_file_path.respond_to?(:encoding) encoding = escaped_file_path.encoding else encoding = nil end unescaped_file_path = escaped_file_path.gsub(/\\\\/, '\\'). gsub(/\\\"/, '"'). gsub(/\\([0-9]{1,3})/) do $1.to_i(8).chr end unescaped_file_path.force_encoding(encoding) if encoding unescaped_file_path else file_path end end |
Instance Method Details
#file_index(name) ⇒ Object
141 142 143 |
# File 'lib/git-commit-mailer/commit-info.rb', line 141 def file_index(name) @files.index(name) end |
#first_parent ⇒ Object
71 72 73 74 75 |
# File 'lib/git-commit-mailer/commit-info.rb', line 71 def first_parent return nil if @parent_revisions.length.zero? @parent_revisions[0] end |
#format_mail_body_html ⇒ Object
133 134 135 |
# File 'lib/git-commit-mailer/commit-info.rb', line 133 def format_mail_body_html HTMLMailBodyFormatter.new(self).format end |
#format_mail_body_text ⇒ Object
129 130 131 |
# File 'lib/git-commit-mailer/commit-info.rb', line 129 def format_mail_body_text TextMailBodyFormatter.new(self).format end |
#format_mail_subject ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/git-commit-mailer/commit-info.rb', line 117 def format_mail_subject affected_path_info = "" if @mailer.show_path? _affected_paths = affected_paths unless _affected_paths.empty? affected_path_info = " (#{_affected_paths.join(',')})" end end "[#{short_reference}#{affected_path_info}] " + subject end |
#headers ⇒ Object
95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/git-commit-mailer/commit-info.rb', line 95 def headers [ "X-Git-Author: #{@author_name}", "X-Git-Revision: #{@revision}", # "X-Git-Repository: #{path}", "X-Git-Repository: XXX", "X-Git-Commit-Id: #{@revision}", "Message-ID: #{}", * ] end |
#merge? ⇒ Boolean
83 84 85 |
# File 'lib/git-commit-mailer/commit-info.rb', line 83 def merge? @parent_revisions.length >= 2 end |
#message_id ⇒ Object
87 88 89 90 91 92 93 |
# File 'lib/git-commit-mailer/commit-info.rb', line 87 def if merge? "<merge.#{@parent_revisions.first}.#{@revision}@#{self.class.host_name}>" else "<#{@revision}@#{self.class.host_name}>" end end |
#other_parents ⇒ Object
77 78 79 80 81 |
# File 'lib/git-commit-mailer/commit-info.rb', line 77 def other_parents return [] if @parent_revisions.length.zero? @parent_revisions[1..-1] end |
#related_mail_headers ⇒ Object
107 108 109 110 111 112 113 114 115 |
# File 'lib/git-commit-mailer/commit-info.rb', line 107 def headers = [] @merge_commits.each do |merge_commit| = merge_commit. headers << "References: #{}" headers << "In-Reply-To: #{}" end headers end |
#rss_content ⇒ Object
149 150 151 |
# File 'lib/git-commit-mailer/commit-info.rb', line 149 def rss_content "<pre>#{ERB::Util.h(format_mail_body_text)}</pre>" end |
#rss_title ⇒ Object
145 146 147 |
# File 'lib/git-commit-mailer/commit-info.rb', line 145 def rss_title format_mail_subject end |
#short_revision ⇒ Object
137 138 139 |
# File 'lib/git-commit-mailer/commit-info.rb', line 137 def short_revision GitCommitMailer.short_revision(@revision) end |