Class: Hookworm::Judger::EmailRenderContext

Inherits:
Object
  • Object
show all
Defined in:
lib/hookworm/rogue_commit_handler.rb

Instance Method Summary collapse

Constructor Details

#initialize(judger, payload, tmpl) ⇒ EmailRenderContext

Returns a new instance of EmailRenderContext.



202
203
204
205
206
207
208
209
210
# File 'lib/hookworm/rogue_commit_handler.rb', line 202

def initialize(judger, payload, tmpl)
  assign_judger_vars(judger)
  assign_payload_vars(payload)
  @tmpl = tmpl
  @date = Time.now.utc.rfc2822
  @message_id = Time.now.strftime('%s%9N')
  @hostname = Socket.gethostname
  assign_head_commit_vars(payload[:head_commit])
end

Instance Method Details

#assign_head_commit_vars(hc) ⇒ Object



228
229
230
231
232
233
234
235
236
# File 'lib/hookworm/rogue_commit_handler.rb', line 228

def assign_head_commit_vars(hc)
  @head_commit_id = hc[:id]
  @head_commit_url = hc[:url]
  @head_commit_author = hc[:author][:name]
  @head_commit_committer = hc[:committer][:name]
  @head_commit_message_text = hc[:message].to_plaintext
  @head_commit_message_html = hc[:message].to_html
  @head_commit_timestamp = hc[:timestamp]
end

#assign_judger_vars(judger) ⇒ Object



212
213
214
215
216
217
218
# File 'lib/hookworm/rogue_commit_handler.rb', line 212

def assign_judger_vars(judger)
  @cfg = judger.cfg
  @from = judger.fromaddr
  @recipients = judger.recipients.join(', ')
  @watched_branches = judger.watched_branches
  @watched_paths = judger.watched_paths
end

#assign_payload_vars(payload) ⇒ Object



220
221
222
223
224
225
226
# File 'lib/hookworm/rogue_commit_handler.rb', line 220

def assign_payload_vars(payload)
  @payload = payload
  @repo = "#{payload[:repository][:owner][:name]}/" <<
  "#{payload[:repository][:name]}"
  @ref = payload[:ref]
  @repo_url = payload[:repository][:url]
end

#renderObject



238
239
240
# File 'lib/hookworm/rogue_commit_handler.rb', line 238

def render
  @tmpl.result(binding)
end