Class: XmlToGdlController

Inherits:
Object
  • Object
show all
Defined in:
lib/xmlutils/xmltogdlcontroller.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeXmlToGdlController

Returns a new instance of XmlToGdlController.



19
20
21
22
23
24
25
# File 'lib/xmlutils/xmltogdlcontroller.rb', line 19

def initialize()
  $LOG.debug "XmlToGdlController::initialize"
  @verbose = false
  @srcPath = ""
  @destPath = ""
  @includes = []
end

Instance Attribute Details

#destPathObject (readonly)

Returns the value of attribute destPath.



17
18
19
# File 'lib/xmlutils/xmltogdlcontroller.rb', line 17

def destPath
  @destPath
end

#srcPathObject (readonly)

Returns the value of attribute srcPath.



16
17
18
# File 'lib/xmlutils/xmltogdlcontroller.rb', line 16

def srcPath
  @srcPath
end

#verboseObject

Returns the value of attribute verbose.



15
16
17
# File 'lib/xmlutils/xmltogdlcontroller.rb', line 15

def verbose
  @verbose
end

Instance Method Details

#addInclude(arg) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/xmlutils/xmltogdlcontroller.rb', line 70

def addInclude(arg)
  $LOG.debug "XmlToGdlController::addInclude( #{arg} )"
  arg = File.rubypath(arg)
  if(!File.file?(arg))
    arg = File.expand_path(arg)
    if(!File.file?(arg))
      $LOG.error "Unable to find include file: #{arg}"
      puts "Missing file: #{arg}"
      arg = nil
    end
  end
  if(nil != arg)
    @includes << arg
    $LOG.info "Include file added: #{arg}"
  end
end

#doSomethingObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/xmlutils/xmltogdlcontroller.rb', line 28

def doSomething()
  $LOG.debug "XmlToGdlController::doSomething"
  options = {}
  options["verbose"]  = @verbose

  destFile = ""
  destFile = File.basename(@destPath) unless File.directory?(@destPath)
  if(!destFile.empty?)
    options[:destfile] = destFile
  end
  destDir  = @destPath      # Extract the dir if it is a file path.

  destDir  = File.dirname(@destPath) unless File.directory?(@destPath)
  if(destDir.length() < 1)
    destDir = Dir.getwd()   # Use working dir if nothing there.

  end
  options[:destdir] = destDir

  options[:includes] = @includes

                # Go to work.

  docBuilder = GdlDocBuilder.new(options)
  docBuilder.createDocument(@srcPath)

end

#noCmdLineArgObject



88
89
90
91
# File 'lib/xmlutils/xmltogdlcontroller.rb', line 88

def noCmdLineArg()
  $LOG.debug "XmlToGdlController::noCmdLineArg"
  #exit "Should never reach here."

end

#setFilenames(arg) ⇒ Object



60
61
62
63
64
65
66
67
# File 'lib/xmlutils/xmltogdlcontroller.rb', line 60

def setFilenames(arg)
  $LOG.debug "XmlToGdlController::setFilenames( #{arg} )"
  @srcPath  = arg[0]
  @destPath = arg[1]

  @srcPath  = File.rubypath(@srcPath)
  @destPath = File.rubypath(@destPath)
end

#setVerbose(arg) ⇒ Object



54
55
56
57
# File 'lib/xmlutils/xmltogdlcontroller.rb', line 54

def setVerbose(arg)
  $LOG.debug "XmlToGdlController::setVerbose( #{arg} )"
  @verbose = arg
end