Class: Giblish::SubtreeIndexBase
- Inherits:
-
SubtreeSrcItf
- Object
- SubtreeSrcItf
- Giblish::SubtreeIndexBase
- Defined in:
- lib/giblish/indexbuilders/subtree_indices.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#src_location ⇒ Object
readonly
Returns the value of attribute src_location.
Instance Method Summary collapse
- #adoc_source(pathtree, output_basename) ⇒ Object
- #document_details ⇒ Object
-
#initialize(opts) ⇒ SubtreeIndexBase
constructor
Required options: :erb_template_path - the absolute path to the erb template that will be used when generating the indices.
- #tree_summary ⇒ Object
Constructor Details
#initialize(opts) ⇒ SubtreeIndexBase
Required options:
:erb_template_path - the absolute path to the erb template that will be used when generating
the indices.
13 14 15 16 17 |
# File 'lib/giblish/indexbuilders/subtree_indices.rb', line 13 def initialize(opts) raise InvalidArgument unless opts.key?(:erb_template_path) @erb_path = Pathname(opts[:erb_template_path]) end |
Instance Attribute Details
#src_location ⇒ Object (readonly)
Returns the value of attribute src_location.
8 9 10 |
# File 'lib/giblish/indexbuilders/subtree_indices.rb', line 8 def src_location @src_location end |
Instance Method Details
#adoc_source(pathtree, output_basename) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/giblish/indexbuilders/subtree_indices.rb', line 19 def adoc_source(pathtree, output_basename) @pathtree = pathtree @output_basename = output_basename @parent_dirpath = pathtree.pathname.dirname @dirname = pathtree.segment Giblog.logger.debug { "using erb template: #{@erb_path} for index generation" } erb_template = File.read(@erb_path) ERB.new(erb_template, trim_mode: "<>").result(binding) end |
#document_details ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/giblish/indexbuilders/subtree_indices.rb', line 39 def document_details details_str = "" @pathtree.traverse_preorder do |_level, node| next unless node.leaf? d = node.data details_str << (d.converted ? document_detail(node) : document_detail_fail(d)) end details_str end |
#tree_summary ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/giblish/indexbuilders/subtree_indices.rb', line 31 def tree_summary VerbatimTree.new(@pathtree.sort_leaf_first!, {dir_index_base_name: @output_basename}).source # str = "++++\n" # str += D3TreeGraph.new(tree: @pathtree, options: {dir_index_base_name: @output_basename}).source # str += "\n++++" # str end |