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.



199
200
201
202
203
204
205
206
207
# File 'lib/hookworm/rogue_commit_handler.rb', line 199

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



225
226
227
228
229
230
231
232
233
# File 'lib/hookworm/rogue_commit_handler.rb', line 225

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



209
210
211
212
213
214
215
# File 'lib/hookworm/rogue_commit_handler.rb', line 209

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



217
218
219
220
221
222
223
# File 'lib/hookworm/rogue_commit_handler.rb', line 217

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



235
236
237
# File 'lib/hookworm/rogue_commit_handler.rb', line 235

def render
  @tmpl.result(binding)
end