xmlutils 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +6 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE +22 -0
  5. data/README.md +77 -0
  6. data/bin/xmltogdl +88 -0
  7. data/docs/README.txt +20 -0
  8. data/lib/xmlutils/contextlistener.rb +432 -0
  9. data/lib/xmlutils/contextparser.rb +111 -0
  10. data/lib/xmlutils/dumplistener.rb +57 -0
  11. data/lib/xmlutils/gdlcontext.rb +305 -0
  12. data/lib/xmlutils/gdlcontextobjs.rb +286 -0
  13. data/lib/xmlutils/gdldoc.rb +547 -0
  14. data/lib/xmlutils/gdldocbuilder.rb +181 -0
  15. data/lib/xmlutils/gdllistener.rb +265 -0
  16. data/lib/xmlutils/gdltemplate.rb +488 -0
  17. data/lib/xmlutils/lineparser.rb +193 -0
  18. data/lib/xmlutils/listener.rb +459 -0
  19. data/lib/xmlutils/rulelistener.rb +414 -0
  20. data/lib/xmlutils/ruleparser.rb +112 -0
  21. data/lib/xmlutils/varlistener.rb +86 -0
  22. data/lib/xmlutils/version.rb +5 -0
  23. data/lib/xmlutils/xmlrulevisitor.rb +704 -0
  24. data/lib/xmlutils/xmltogdlcontroller.rb +93 -0
  25. data/lib/xmlutils/xmltogdltask.rb +23 -0
  26. data/lib/xmlutils/xmlvisitor.rb +690 -0
  27. data/lib/xmlutils.rb +40 -0
  28. data/rakefile.rb +34 -0
  29. data/unittests/2830.xml +1 -0
  30. data/unittests/chunks.rb +31 -0
  31. data/unittests/curDirTest.rb +2 -0
  32. data/unittests/data/2830-GENERATED.gdl +309 -0
  33. data/unittests/data/2830-GENERATED.xml +1 -0
  34. data/unittests/data/AUGuideline.xml +12 -0
  35. data/unittests/data/AUGuideline.xml.gdl +19190 -0
  36. data/unittests/data/BAKUP.DCTEST1.xml +1 -0
  37. data/unittests/data/DCTEST.xml +1 -0
  38. data/unittests/data/DCTEST1.xml +1 -0
  39. data/unittests/data/DCTEST1.xml.gdl +14890 -0
  40. data/unittests/data/DCTEST1.xml.rename.csv +180 -0
  41. data/unittests/data/DCTEST1wLookups.xml +174 -0
  42. data/unittests/data/DCTEST1wLookups.xml.gdl +127 -0
  43. data/unittests/data/GENERATED.gdl.xml +1 -0
  44. data/unittests/data/Message.xml +1 -0
  45. data/unittests/data/Message.xml.gdl +142 -0
  46. data/unittests/data/Pricing2ndGuideline.xml +1 -0
  47. data/unittests/data/Pricing2ndGuideline.xml.gdl +52670 -0
  48. data/unittests/data/Z-TEMP-Jeff.xml +1 -0
  49. data/unittests/data/Z-TEMP-Jeff.xml.gdl +288 -0
  50. data/unittests/tc_convert_xml_to_gdl.rb +23 -0
  51. data/unittests/ts_allTests.rb +2 -0
  52. data/xmlutils.gemspec +25 -0
  53. metadata +139 -0
@@ -0,0 +1,93 @@
1
+ ##############################################################################
2
+ # File:: xmltogdlcontroller.rb
3
+ # Purpose:: Main Controller object for XmlToGdl utility
4
+ #
5
+ # Author:: Jeff McAffee 03/07/2010
6
+ # Copyright:: Copyright (c) 2010, kTech Systems LLC. All rights reserved.
7
+ # Website:: http://ktechsystems.com
8
+ ##############################################################################
9
+
10
+ require 'ktcommon/ktpath'
11
+ require 'ktcommon/ktcmdline'
12
+
13
+ class XmlToGdlController
14
+
15
+ attr_accessor :verbose
16
+ attr_reader :srcPath
17
+ attr_reader :destPath
18
+
19
+ def initialize()
20
+ $LOG.debug "XmlToGdlController::initialize"
21
+ @verbose = false
22
+ @srcPath = ""
23
+ @destPath = ""
24
+ @includes = []
25
+ end
26
+
27
+
28
+ def doSomething()
29
+ $LOG.debug "XmlToGdlController::doSomething"
30
+ options = {}
31
+ options["verbose"] = @verbose
32
+
33
+ destFile = ""
34
+ destFile = File.basename(@destPath) unless File.directory?(@destPath)
35
+ if(!destFile.empty?)
36
+ options[:destfile] = destFile
37
+ end
38
+ destDir = @destPath # Extract the dir if it is a file path.
39
+ destDir = File.dirname(@destPath) unless File.directory?(@destPath)
40
+ if(destDir.length() < 1)
41
+ destDir = Dir.getwd() # Use working dir if nothing there.
42
+ end
43
+ options[:destdir] = destDir
44
+
45
+ options[:includes] = @includes
46
+
47
+ # Go to work.
48
+ docBuilder = GdlDocBuilder.new(options)
49
+ docBuilder.createDocument(@srcPath)
50
+
51
+ end
52
+
53
+
54
+ def setVerbose(arg)
55
+ $LOG.debug "XmlToGdlController::setVerbose( #{arg} )"
56
+ @verbose = arg
57
+ end
58
+
59
+
60
+ def setFilenames(arg)
61
+ $LOG.debug "XmlToGdlController::setFilenames( #{arg} )"
62
+ @srcPath = arg[0]
63
+ @destPath = arg[1]
64
+
65
+ @srcPath = File.rubypath(@srcPath)
66
+ @destPath = File.rubypath(@destPath)
67
+ end
68
+
69
+
70
+ def addInclude(arg)
71
+ $LOG.debug "XmlToGdlController::addInclude( #{arg} )"
72
+ arg = File.rubypath(arg)
73
+ if(!File.file?(arg))
74
+ arg = File.expand_path(arg)
75
+ if(!File.file?(arg))
76
+ $LOG.error "Unable to find include file: #{arg}"
77
+ puts "Missing file: #{arg}"
78
+ arg = nil
79
+ end
80
+ end
81
+ if(nil != arg)
82
+ @includes << arg
83
+ $LOG.info "Include file added: #{arg}"
84
+ end
85
+ end
86
+
87
+
88
+ def noCmdLineArg()
89
+ $LOG.debug "XmlToGdlController::noCmdLineArg"
90
+ #exit "Should never reach here."
91
+ end
92
+ end # class XmlToGdlController
93
+
@@ -0,0 +1,23 @@
1
+ ##############################################################################
2
+ # File:: xmltogdltask.rb
3
+ # Purpose:: Rake Task for running the application
4
+ #
5
+ # Author:: Jeff McAffee 04/13/2010
6
+ # Copyright:: Copyright (c) 2010, kTech Systems LLC. All rights reserved.
7
+ # Website:: http://ktechsystems.com
8
+ ##############################################################################
9
+
10
+ require 'xmlutils'
11
+ class XmlToGdlTask
12
+
13
+ def execute(srcPath, destPath, verbose=false)
14
+ filenames = [srcPath, destPath]
15
+
16
+ app = XmlToGdlController.new
17
+ app.setFilenames(filenames)
18
+ app.setVerbose(verbose)
19
+ app.doSomething()
20
+ end
21
+ end # class XmlToGdlTask
22
+
23
+