class DataMetaDom::Sources

All sources including all includes from the master file.

For command line details either check the new method's source or the README.rdoc file, the usage section.

Attributes

masterPath[R]

Public Class Methods

new(masterFile) click to toggle source

Start parsing from the master file, collect all the files that are included.

# File lib/dataMetaDom/sources.rb, line 18
def initialize(masterFile)
    @masterPath = File.dirname(masterFile)
    @todo = {}; @done = {}
    libSpec = ENV[DATAMETA_LIB]
    @paths = libSpec ? libSpec.split(File::PATH_SEPARATOR).map { |e| uniPath(e) } : []
    @paths.unshift(@masterPath).flatten! if @masterPath
    @paths.unshift '.' # start looking in the current directory and then in the rest of the path
    src = SourceFile.new(@masterPath, File.basename(masterFile))
    @todo[src.key] = src
end

Public Instance Methods

[](key) click to toggle source

Fetches the instance of SourceFile by its key.

# File lib/dataMetaDom/sources.rb, line 37
def [](key); @done[key] end
doneKeys() click to toggle source

Returns the set of the keys of the source files alredy parsed.

# File lib/dataMetaDom/sources.rb, line 32
def doneKeys; @done.keys end
next() click to toggle source

Returns next source file in queue if any, returns nil if no more source files left to parse.

# File lib/dataMetaDom/sources.rb, line 59
def next
    return nil if @todo.empty?
    @key = nil
    @todo.each_key { |k| @key = k; break }
    @val = @todo[@key]
    @todo.delete @key; @done[@key] = @val
    @val
end
queue(name) click to toggle source

Queue a source file for parsing

# File lib/dataMetaDom/sources.rb, line 40
def queue(name)
    # need to resolve the name to the path first
    includeDir = nil
    @paths.each { |m|
        fullName = "#{m}#{File::SEPARATOR}#{name}"
        if File.exist?(fullName)
            includeDir = m
            break
        end
    }
    raise "Missing include '#{name}' in the path #{@paths.join(File::PATH_SEPARATOR)}" unless includeDir
    src = SourceFile.new(includeDir, name)
    @todo[src.key]=src unless @todo[src.key] || @done[src.key]
    self
end