Class: Giblish::SubtreeIndexGit

Inherits:
SubtreeIndexBase show all
Defined in:
lib/giblish/indexbuilders/subtree_indices.rb

Overview

Generates a directory index with history info for all files under the given subdir node.

Constant Summary collapse

HISTORY_TABLE_HEADING =

The fixed heading of the table used to display file history

<<~HISTORY_HEADER
  File history::

  [cols=\"2,3,8,3\",options=\"header\"]
  |===
  |Date |Author |Message |Sha1
HISTORY_HEADER
HISTORY_TABLE_FOOTING =
<<~HIST_FOOTER

  |===\n\n
HIST_FOOTER

Instance Attribute Summary

Attributes inherited from SubtreeIndexBase

#src_location

Instance Method Summary collapse

Methods inherited from SubtreeIndexBase

#adoc_source, #document_details, #tree_summary

Methods inherited from SubtreeSrcItf

#adoc_source

Constructor Details

#initialize(erb_template_path) ⇒ SubtreeIndexGit

Returns a new instance of SubtreeIndexGit.



113
114
115
# File 'lib/giblish/indexbuilders/subtree_indices.rb', line 113

def initialize(erb_template_path)
  super(erb_template_path)
end

Instance Method Details

#document_detail(node_data) ⇒ Object



125
126
127
# File 'lib/giblish/indexbuilders/subtree_indices.rb', line 125

def document_detail(node_data)
  super(node_data) + generate_history_info(node_data)
end

#document_detail_fail(node_data) ⇒ Object



121
122
123
# File 'lib/giblish/indexbuilders/subtree_indices.rb', line 121

def document_detail_fail(node_data)
  super(node_data) + generate_history_info(node_data)
end

#generate_history_info(node_data) ⇒ Object



129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/giblish/indexbuilders/subtree_indices.rb', line 129

def generate_history_info(node_data)
  return "Could not find history information\n\n" unless node_data.respond_to?(:history)

  # Generate table rows of history information
  rows = node_data.history.collect do |h|
    <<~HISTORY_ROW
      |#{h.date.strftime("%Y-%m-%d")}
      |#{h.author}
      |#{h.message}
      |#{h.sha1[0..7]} ...
    HISTORY_ROW
  end.join("\n\n")
  HISTORY_TABLE_HEADING + rows + HISTORY_TABLE_FOOTING
end

#subtitle(dst_node) ⇒ Object



117
118
119
# File 'lib/giblish/indexbuilders/subtree_indices.rb', line 117

def subtitle(dst_node)
  "from #{dst_node.data.branch}"
end