Class: DocbookFiles::Docbook
- Inherits:
-
Object
- Object
- DocbookFiles::Docbook
- Defined in:
- lib/docbook_files/docbook.rb
Overview
Analyzes a DocBook 5 file for included and referenced files.
Constant Summary collapse
- DOCBOOK_NS =
The DocBook 5 namespace URL
'http://docbook.org/ns/docbook'- XINCLUDE_NS =
The XInclude namespace URL
'http://www.w3.org/2001/XInclude'
Instance Attribute Summary collapse
-
#fd_tree ⇒ Object
readonly
The FileData tree representing the file hierarchy.
Instance Method Summary collapse
-
#initialize(fname) ⇒ Docbook
constructor
Initialize vars and quiet the libxml error handler.
-
#list ⇒ Object
Return the FileData tree representing the include hierarchy.
-
#list_as_table(props) ⇒ Object
Return a flat array of FileDatas, a table with level indicator.
-
#list_names ⇒ Object
Return all file names in a tree.
Constructor Details
#initialize(fname) ⇒ Docbook
Initialize vars and quiet the libxml error handler. See libxml.rubyforge.org/rdoc/classes/LibXML/XML/Error.html
21 22 23 24 25 |
# File 'lib/docbook_files/docbook.rb', line 21 def initialize(fname) @main_name = fname @fd_tree = nil XML::Error.set_handler(&XML::Error::QUIET_HANDLER) end |
Instance Attribute Details
#fd_tree ⇒ Object (readonly)
The FileData tree representing the file hierarchy
17 18 19 |
# File 'lib/docbook_files/docbook.rb', line 17 def fd_tree @fd_tree end |
Instance Method Details
#list ⇒ Object
Return the FileData tree representing the include hierarchy.
30 31 32 33 |
# File 'lib/docbook_files/docbook.rb', line 30 def list @fd_tree ||= analyze_file(@main_name,File.dirname(@main_name)) @fd_tree end |
#list_as_table(props) ⇒ Object
Return a flat array of FileDatas, a table with level indicator. The format is easier for tabular output.
44 45 46 47 |
# File 'lib/docbook_files/docbook.rb', line 44 def list_as_table(props) tree = self.list() tree.traverse_as_table(props) end |
#list_names ⇒ Object
Return all file names in a tree
36 37 38 39 |
# File 'lib/docbook_files/docbook.rb', line 36 def list_names fl = self.list() fl.names end |