Class: Giblish::GenerateFromRefs

Inherits:
Object
  • Object
show all
Defined in:
lib/giblish/github_trigger/webhook_manager.rb

Overview

Generate documentation using giblish based on the supplied parameters

Constant Summary collapse

STANDARD_GIBLISH_FLAGS =
%W[-f html -m --copy-asset-folders _assets$ --server-search-path /cgi-bin/gibsearch.cgi]

Instance Method Summary collapse

Constructor Details

#initialize(doc_repo_url, ref_regexp, clone_dir_parent, clone_name, giblish_args, doc_src_rel, doc_dst_abs, logger) ⇒ GenerateFromRefs

doc_repo_url

the url of the repo hosting the docs to be generated. this repo will be cloned

ref_regexp

a regexp that both defines what git refs that trigger a document generation and what refs will be

generated.

clone_dir_parent

path to the local directory under which the doc_repo_url will be cloned.

clone_name

the name of the local clone of the doc_repo_url

doc_src_rel

the relative path from the repo root to the directory where the docs reside

doc_dst_abs

the absolute path to the target location for the generated docs

logger

a ruby Logger instance that will receive log messages



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/giblish/github_trigger/webhook_manager.rb', line 17

def initialize(doc_repo_url, ref_regexp, clone_dir_parent, clone_name, giblish_args, doc_src_rel, doc_dst_abs, logger)
  @doc_repo_url = doc_repo_url
  @ref_regexp = ref_regexp
  @giblish_args = STANDARD_GIBLISH_FLAGS
  @giblish_args += giblish_args unless giblish_args.nil?
  @doc_src_rel = doc_src_rel
  @dstdir = doc_dst_abs
  @logger = logger

  @repo_root = clone(doc_repo_url, clone_dir_parent, clone_name)
end

Instance Method Details

#docs_from_gh_webhook(github_hash) ⇒ Object

Generate documents from the git refs found in the GitHub webhook payload.



31
32
33
34
35
36
37
38
39
40
# File 'lib/giblish/github_trigger/webhook_manager.rb', line 31

def docs_from_gh_webhook(github_hash)
  # TODO Implement support for other refs than branches
  ref = github_hash.fetch(:ref).sub("refs/heads/", "")
  if ref.empty? || !(@ref_regexp =~ ref)
    @logger&.info { "Ref '#{ref}' does not match the document generation trigger -> No document generation triggereed" }
    return
  end

  generate_docs(ref)
end