Class: Giblish::FileTreeConverter
- Inherits:
-
Object
- Object
- Giblish::FileTreeConverter
- Defined in:
- lib/giblish/core.rb
Overview
Parse a directory tree and convert all asciidoc files matching the supplied critera to the supplied format
Direct Known Subclasses
Instance Attribute Summary collapse
-
#converter ⇒ Object
readonly
Returns the value of attribute converter.
Instance Method Summary collapse
- #convert ⇒ Object
-
#initialize(options) ⇒ FileTreeConverter
constructor
Required options: srcDirRoot dstDirRoot resourceDir.
Constructor Details
#initialize(options) ⇒ FileTreeConverter
Required options:
srcDirRoot
dstDirRoot
resourceDir
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/giblish/core.rb', line 25 def initialize() @options = .dup @paths = Giblish::PathManager.new( @options[:srcDirRoot], @options[:dstDirRoot], @options[:resourceDir], @options[:webRoot] ) @processed_docs = [] @converter = converter_factory @search_assets_path = @paths.dst_root_abs.realpath.join("search_assets") end |
Instance Attribute Details
#converter ⇒ Object (readonly)
Returns the value of attribute converter.
19 20 21 |
# File 'lib/giblish/core.rb', line 19 def converter @converter end |
Instance Method Details
#convert ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/giblish/core.rb', line 39 def convert # collect all doc ids and enable replacement of known doc ids with # valid references to adoc files manage_doc_ids if @options[:resolveDocid] # register add-on for handling searchability manage_searchability if @options[:make_searchable] # traverse the src file tree and convert all files deemed as # adoc files Find.find(@paths.src_root_abs) do |path| p = Pathname.new(path) to_asciidoc(p) if adocfile? p end if @paths.src_root_abs.directory? # create necessary search assets if needed create_search_assets if @options[:make_searchable] # check if we shall build index or not return if @options[:suppressBuildRef] # build a dependency graph (only if we resolve docids...) dep_graph_exist = if @options[:resolveDocid] if Giblish::GraphBuilderGraphviz.supported gb = Giblish::GraphBuilderGraphviz.new @processed_docs, @paths, {extension: @converter.[:fileext]} @converter.convert_str gb.source, @paths.dst_root_abs, "graph" else Giblog.logger.warn { "Lacking access to needed tools for generating a visual dependency graph." } Giblog.logger.warn { "The dependency graph will not be generated !!" } false end else false end # build a reference index ib = index_factory @converter.convert_str ib.source(dep_graph_exist,@options[:make_searchable]), @paths.dst_root_abs, "index" # clean up cached files and adoc resources remove_diagram_temps if dep_graph_exist GC.start end |