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
convert all adoc files return true if all conversions went ok, false if at least one failed.
-
#initialize(options) ⇒ FileTreeConverter
constructor
Required options: srcDirRoot dstDirRoot resourceDir.
Constructor Details
#initialize(options) ⇒ FileTreeConverter
Required options:
srcDirRoot
dstDirRoot
resourceDir
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/giblish/core.rb', line 23 def initialize() @options = .dup @paths = Giblish::PathManager.new( @options[:srcDirRoot], @options[:dstDirRoot], @options[:resourceDir], @options[:makeSearchable] ) # set the path to the search data that will be sent to the cgi search script deploy_search_path = if @options[:makeSearchable] if @options[:searchAssetsDeploy].nil? @paths.search_assets_abs else Pathname.new(@options[:searchAssetsDeploy]).join("search_assets") end end @deploy_info = Giblish::DeploymentPaths.new( @options[:webPath], deploy_search_path ) @processed_docs = [] @converter = converter_factory end |
Instance Attribute Details
#converter ⇒ Object (readonly)
Returns the value of attribute converter.
17 18 19 |
# File 'lib/giblish/core.rb', line 17 def converter @converter end |
Instance Method Details
#convert ⇒ Object
convert all adoc files return true if all conversions went ok, false if at least one failed
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 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/giblish/core.rb', line 53 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(@options) if @options[:makeSearchable] # traverse the src file tree and convert all files deemed as # adoc files conv_error = false if @paths.src_root_abs.directory? Find.find(@paths.src_root_abs) do |path| p = Pathname.new(path) begin to_asciidoc(p) if adocfile? p rescue StandardError => e str = String.new("Error when converting file "\ "#{path}: #{e.}\nBacktrace:\n") e.backtrace.each { |l| str << " #{l}\n" } Giblog.logger.error { str } conv_error = true end end end # create necessary search assets if needed create_search_assets if @options[:makeSearchable] # build index and other fancy stuff if not suppressed unless @options[:suppressBuildRef] # build a dependency graph (only if we resolve docids...) dep_graph_exist = @options[:resolveDocid] && build_graph_page # build a reference index build_index_page(dep_graph_exist) end conv_error end |