Class: Capistrano::Committed::Output
- Inherits:
-
Mustache
- Object
- Mustache
- Capistrano::Committed::Output
- Defined in:
- lib/capistrano/committed/output.rb
Constant Summary collapse
- @@template_format =
'txt'
Instance Method Summary collapse
- #commits ⇒ Object
- #get_output_path(file) ⇒ Object
- #get_output_template_path(format = 'txt', set_template_format = true) ⇒ Object
- #has_commits ⇒ Object
- #has_issue_links ⇒ Object
- #has_item_lines ⇒ Object
- #has_item_subtitle ⇒ Object
- #issue_link ⇒ Object
- #issue_links ⇒ Object
- #item_created_by ⇒ Object
- #item_created_on ⇒ Object
- #item_lines ⇒ Object
- #item_link ⇒ Object
- #item_subtitle ⇒ Object
- #item_title ⇒ Object
- #items ⇒ Object
- #release_header ⇒ Object
- #template_format ⇒ Object
Instance Method Details
#commits ⇒ Object
131 132 133 134 135 136 |
# File 'lib/capistrano/committed/output.rb', line 131 def commits return unless context.current[:type] == :pull_request return unless context.current[:commits] return if context.current[:commits].empty? context.current[:commits].flatten end |
#get_output_path(file) ⇒ Object
11 12 13 |
# File 'lib/capistrano/committed/output.rb', line 11 def get_output_path(file) format('%s/output/%s', File.dirname(__FILE__), file) end |
#get_output_template_path(format = 'txt', set_template_format = true) ⇒ Object
15 16 17 18 |
# File 'lib/capistrano/committed/output.rb', line 15 def get_output_template_path(format = 'txt', set_template_format = true) @@template_format = format if set_template_format get_output_path(format('output_%s.mustache', format)) end |
#has_commits ⇒ Object
138 139 140 |
# File 'lib/capistrano/committed/output.rb', line 138 def has_commits !commits.nil? end |
#has_issue_links ⇒ Object
96 97 98 |
# File 'lib/capistrano/committed/output.rb', line 96 def has_issue_links !issue_links.empty? end |
#has_item_lines ⇒ Object
77 78 79 |
# File 'lib/capistrano/committed/output.rb', line 77 def has_item_lines !item_lines.empty? end |
#has_item_subtitle ⇒ Object
62 63 64 |
# File 'lib/capistrano/committed/output.rb', line 62 def has_item_subtitle !item_subtitle.nil? end |
#issue_link ⇒ Object
92 93 94 |
# File 'lib/capistrano/committed/output.rb', line 92 def issue_link format_link(context.current) end |
#issue_links ⇒ Object
81 82 83 84 85 86 87 88 89 90 |
# File 'lib/capistrano/committed/output.rb', line 81 def issue_links return unless context.current[:info] case context.current[:type] when :commit return unless context.current[:info][:commit] ::Capistrano::Committed.get_issue_urls(context.current[:info][:commit][:message]) when :pull_request ::Capistrano::Committed.get_issue_urls(context.current[:info][:title] + context.current[:info][:body]) end end |
#item_created_by ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/capistrano/committed/output.rb', line 110 def item_created_by return unless context.current[:info] case context.current[:type] when :commit format_created_by('committed.output.committed_by', context.current[:info][:committer]) when :pull_request format_created_by('committed.output.merged_by', context.current[:info][:merged_by]) else return end end |
#item_created_on ⇒ Object
100 101 102 103 104 105 106 107 108 |
# File 'lib/capistrano/committed/output.rb', line 100 def item_created_on return unless context.current[:info] case context.current[:type] when :commit commit_created_on(context.current[:info]) when :pull_request pull_request_created_on(context.current[:info]) end end |
#item_lines ⇒ Object
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/capistrano/committed/output.rb', line 66 def item_lines return unless context.current[:info] case context.current[:type] when :commit = context.current[:info][:commit][:message] when :pull_request = context.current[:info][:body] end .nil? ? [] : .chomp.delete("\r").split("\n") end |
#item_link ⇒ Object
122 123 124 125 126 127 128 129 |
# File 'lib/capistrano/committed/output.rb', line 122 def item_link return unless context.current[:info] case context.current[:type] when :commit, :pull_request return unless context.current[:info][:html_url] format_link(context.current[:info][:html_url]) end end |
#item_subtitle ⇒ Object
56 57 58 59 60 |
# File 'lib/capistrano/committed/output.rb', line 56 def item_subtitle return unless context.current[:type] == :pull_request return unless context.current[:info] context.current[:info][:title] end |
#item_title ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/capistrano/committed/output.rb', line 44 def item_title return unless context.current[:info] case context.current[:type] when :commit t('committed.output.commit_sha', sha: context.current[:info][:sha]) when :pull_request t('committed.output.pull_request_number', number: context.current[:info][:number]) end end |
#items ⇒ Object
39 40 41 42 |
# File 'lib/capistrano/committed/output.rb', line 39 def items return unless context.current[:entries] Hash[context.current[:entries].sort_by { |date, _entries| date }.reverse].values.flatten end |
#release_header ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/capistrano/committed/output.rb', line 24 def release_header case context.current[:release] when :next t('committed.output.next_release') when :previous t('committed.output.previous_release', time: context.current[:date]) else t('committed.output.current_release', release_time: Time.parse(context.current[:release]).iso8601, sha: context.current[:sha], commit_time: context.current[:date]) end end |
#template_format ⇒ Object
20 21 22 |
# File 'lib/capistrano/committed/output.rb', line 20 def template_format @@template_format end |