Class: Codebot::Formatters::Gitlab::WikiPageHook

Inherits:
Codebot::Formatter show all
Defined in:
lib/codebot/formatters/gitlab_wiki_page_hook.rb

Overview

Triggers on a Wiki Page Hook event

Instance Attribute Summary

Attributes inherited from Codebot::Formatter

#payload

Instance Method Summary collapse

Methods inherited from Codebot::Formatter

#abbreviate, #ary_to_sentence, #closed?, #extract, #format_branch, #format_dangerous, #format_event, #format_hash, #format_number, #format_repository, #format_url, #format_user, #gitlab_action, #gitlab_closed?, #gitlab_opened?, #gitlab_repository_url, #gitlab_url, #initialize, #opened?, #prettify, #repository_url, #sanitize, #shorten_url, #url

Constructor Details

This class inherits a constructor from Codebot::Formatter

Instance Method Details

#actionObject



37
38
39
40
41
42
43
44
# File 'lib/codebot/formatters/gitlab_wiki_page_hook.rb', line 37

def action
  case wiki_action
  when 'create' then 'created'
  when 'delete' then 'deleted'
  when 'update', nil then 'updated'
  else wiki_action
  end
end

#default_formatObject



21
22
23
# File 'lib/codebot/formatters/gitlab_wiki_page_hook.rb', line 21

def default_format
  '[%<repository>s] %<sender>s %<action>s page \'%<title>s\''
end

#formatObject



8
9
10
# File 'lib/codebot/formatters/gitlab_wiki_page_hook.rb', line 8

def format
  ["#{summary}: #{format_url url}"]
end

#repository_nameObject



25
26
27
# File 'lib/codebot/formatters/gitlab_wiki_page_hook.rb', line 25

def repository_name
  extract(:project, :path_with_namespace)
end

#sender_nameObject



29
30
31
# File 'lib/codebot/formatters/gitlab_wiki_page_hook.rb', line 29

def sender_name
  extract(:user, :name)
end

#summaryObject



12
13
14
15
16
17
18
19
# File 'lib/codebot/formatters/gitlab_wiki_page_hook.rb', line 12

def summary
  default_format % {
    repository: format_repository(repository_name),
    sender: format_user(sender_name),
    action: action,
    title: wiki_title
  }
end

#summary_urlObject



33
34
35
# File 'lib/codebot/formatters/gitlab_wiki_page_hook.rb', line 33

def summary_url
  extract(:object_attributes, :url)
end

#wiki_actionObject



46
47
48
# File 'lib/codebot/formatters/gitlab_wiki_page_hook.rb', line 46

def wiki_action
  extract(:object_attributes, :action)
end

#wiki_titleObject



50
51
52
# File 'lib/codebot/formatters/gitlab_wiki_page_hook.rb', line 50

def wiki_title
  extract(:object_attributes, :title)
end