Module: Duxml::Meta

Included in:
Duxml, MetaClass
Defined in:
lib/duxml/meta.rb,
lib/duxml/meta.rb

Constant Summary collapse

FILE_EXT =
'.duxml'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.meta_path(path) ⇒ String

Returns full path of metadata file based on content file’s name e.g. ‘design.xml’ => ‘.design.xml.duxml’.

Parameters:

  • path (String)

    path of XML-content file

Returns:

  • (String)

    full path of metadata file based on content file’s name e.g. ‘design.xml’ => ‘.design.xml.duxml’



39
40
41
42
# File 'lib/duxml/meta.rb', line 39

def self.meta_path(path)
  dir = File.dirname(path)
  "#{dir}/.#{File.basename(path)}#{FILE_EXT}"
end

.xmlDoc

Returns metadata document.

Returns:

  • (Doc)

    metadata document



30
31
32
33
34
# File 'lib/duxml/meta.rb', line 30

def self.xml
  d = Doc.new << (Element.new(name.nmtokenize) << Grammar.xml << History.xml)
  d.root.grammar[:ref] = @grammar_path if @grammar_path
  d
end

Instance Method Details

#grammar=(g) ⇒ Object



44
45
46
47
48
49
# File 'lib/duxml/meta.rb', line 44

def grammar=(g)
  @grammar = g.is_a?(GrammarClass) ? g : Grammar.import(g)
  history.delete_observers if history.respond_to?(:delete_observers)
  history.add_observer(grammar, :qualify)
  grammar.add_observer history
end