ppmtogdl 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e982d83fb1d9f1f23a6806989b87cb86642d3ee0
4
+ data.tar.gz: 56c07cdbfe9e0bbab96e9e038503fc519cc047f8
5
+ SHA512:
6
+ metadata.gz: bf58333bfc919b7e67fc376570bfcd8bfaa5eeddf7dac43790f62f91dff3dbd415e22238c1de2babc9e640952750b09407143f3050a417784eab313e5bf6af55
7
+ data.tar.gz: 2b5490cba9d00e246def90e61153301a6b08ed7ef38341602f55f2aa848ed081c40db6ec411c9a1763880e806887cc3b49066f6930d52d78c2217fa816688334
@@ -0,0 +1,6 @@
1
+ # .gitignore
2
+ pkg/
3
+ buildgem
4
+ buildgem.cmd
5
+ Gemfile.lock
6
+ test/data/*.yml
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ppmtogdl.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Jeff McAffee
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,72 @@
1
+ # PpmToGdl Documentation
2
+
3
+ ## Description
4
+
5
+ PpmToGdl provides both a command line application and a rake task
6
+ that is used to generate a .GDL file containing the PPMs parsed out
7
+ of the PrimaryParameters.xml file.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your gemfile:
12
+
13
+ require 'ppmtogdl'
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ or install it yourself as:
20
+
21
+ gem install ppmtogdl
22
+
23
+ ## Usage
24
+
25
+ ### Rake Task Usage
26
+
27
+ The rake task can be included in a rakefile by requiring ppmtogdl like so:
28
+
29
+ require 'ppmtogdl'
30
+
31
+ and called as:
32
+
33
+ PpmToGdlTask.new.execute( customer, srcPath, destPath )
34
+
35
+ ### Command Line Application
36
+
37
+ Usage info can be retrieved from the application by calling it with the -h or --help
38
+ options:
39
+
40
+ $ ppmtogdl --help
41
+
42
+
43
+ ### Notes
44
+
45
+ * Using a parameter of `all` for customer will generate GDL for all PPMs in the file.
46
+
47
+ ## Testing
48
+
49
+ PpmToGdl currently uses an outdated version of TestUnit for testing.
50
+ Tests can be found in the `test` directory.
51
+
52
+ ## TODO
53
+
54
+ Update method naming convention to ruby standards.
55
+
56
+ ## Contributing
57
+
58
+ 1. Fork it ( https://github.com/jmcaffee/ppmtogdl/fork )
59
+ 1. Clone it (`git clone git@github.com:[my-github-username]/ppmtogdl.git`)
60
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
61
+ 3. Create tests for your feature branch
62
+ 4. Commit your changes (`git commit -am 'Add some feature'`)
63
+ 5. Push to the branch (`git push origin my-new-feature`)
64
+ 6. Create a new Pull Request
65
+
66
+ ## LICENSE
67
+
68
+ PpmToGdl is licensed under the MIT license.
69
+
70
+ See [LICENSE](https://github.com/jmcaffee/ppmtogdl/blob/master/LICENSE) for
71
+ details.
72
+
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env ruby
2
+ ##############################################################################
3
+ # File:: ppmtogdl.rb
4
+ # Purpose:: Utility to ...
5
+ #
6
+ # Author:: Jeff McAffee 03/07/2010
7
+ # Copyright:: Copyright (c) 2010, kTech Systems LLC. All rights reserved.
8
+ # Website:: http://ktechsystems.com
9
+ ##############################################################################
10
+
11
+ require 'ppmtogdl'
12
+ require 'user-choices'
13
+
14
+ include PpmToGdl
15
+
16
+ class PpmToGdlApp < UserChoices::Command
17
+ include UserChoices
18
+
19
+
20
+ def initialize()
21
+ super
22
+ @controller = PpmToGdlController.new
23
+ end
24
+
25
+
26
+ def add_sources(builder)
27
+ builder.add_source(CommandLineSource, :usage,
28
+ "Usage: #{$0} [options] SRC_XML_FILE OUTPUT_FILE",
29
+ "PpmToGdl can parse a PrimaryParameter.xml file and generate GDL ppm definitions from it.",
30
+ "If SRC_XML_FILE does not end with an xml extension, .xml will be added.")
31
+ end # def add_sources
32
+
33
+
34
+ def add_choices(builder)
35
+ # Arguments
36
+ builder.add_choice(:cmdArg, :length=>2) { |command_line| # Use length to REQUIRE args.
37
+ #builder.add_choice(:cmdArg) { |command_line|
38
+ command_line.uses_arglist
39
+ }
40
+
41
+ # Switches
42
+ builder.add_choice(:verbose, :type=>:boolean, :default=>false) { |command_line|
43
+ command_line.uses_switch("-v", "--verbose",
44
+ "Turn on verbose output.")
45
+ }
46
+
47
+ # Options
48
+ builder.add_choice(:customer, :type=>:string) { |command_line|
49
+ command_line.uses_option("-c", "--customer ARG",
50
+ "Only generate PPMs for XML elements containing ARG in customer attribute.")
51
+ }
52
+
53
+ end # def add_choices
54
+
55
+
56
+ # Execute the PpmToGdl application.
57
+ # This method is called automatically when 'ppmtogdl(.rb)' is executed from the command line.
58
+ def execute
59
+ $LOG.debug "PpmToGdlApp::execute"
60
+
61
+ if(@user_choices[:customer])
62
+ @controller.customer = @user_choices[:customer]
63
+ end
64
+
65
+ if(@user_choices[:verbose])
66
+ @controller.verbose = @user_choices[:verbose]
67
+ end
68
+
69
+ if(@user_choices[:cmdArg].empty?) # If no cmd line arg...
70
+ @controller.noCmdLineArg()
71
+ return
72
+ end
73
+
74
+ result = @controller.setFilenames(@user_choices[:cmdArg])
75
+
76
+ @controller.doSomething()
77
+ end # def execute
78
+
79
+
80
+ end # class PpmToGdlApp
81
+
82
+
83
+ #if $0 == __FILE__
84
+ PpmToGdlApp.new.execute
85
+ #end
@@ -0,0 +1,39 @@
1
+ ##############################################################################
2
+ # File:: ppmtogdl.rb
3
+ # Purpose:: Include file for PpmToGdl library
4
+ #
5
+ # Author:: Jeff McAffee 03/07/2010
6
+ #
7
+ ##############################################################################
8
+
9
+ require 'find'
10
+ require 'logger'
11
+ require 'bundler/setup'
12
+
13
+ if(!$LOG)
14
+ $LOG = Logger.new(STDERR)
15
+ $LOG.level = Logger::ERROR
16
+ end
17
+
18
+ if ENV["DEBUG"] == '1'
19
+ puts "LOGGING: ON due to DEBUG=1"
20
+ $LOG.level = Logger::DEBUG
21
+ end
22
+
23
+ $LOG.info "**********************************************************************"
24
+ $LOG.info "Logging started for PpmToGdl library."
25
+ $LOG.info "**********************************************************************"
26
+
27
+
28
+ require_relative 'ppmtogdl/version'
29
+
30
+ require_relative 'ppmtogdl/ppmcontextobjs'
31
+ require_relative 'ppmtogdl/ppmcontext'
32
+ require_relative 'ppmtogdl/ppmtogdlcfg'
33
+ require_relative 'ppmtogdl/contextlistener'
34
+ require_relative 'ppmtogdl/contextparser'
35
+ require_relative 'ppmtogdl/gdldocbuilder'
36
+ require_relative 'ppmtogdl/gdldoc'
37
+ require_relative 'ppmtogdl/ppmtogdlcontroller'
38
+ require_relative 'ppmtogdl/ppmtogdltask'
39
+
@@ -0,0 +1,43 @@
1
+ ##############################################################################
2
+ # File:: contextlistener.rb
3
+ # Purpose:: ContextListener 'listens' to the incoming xml steam and parses
4
+ # tokens out of the stream.
5
+ #
6
+ # Author:: Jeff McAffee 04/30/2015
7
+ #
8
+ ##############################################################################
9
+
10
+ require 'rexml/streamlistener'
11
+ require 'xmlutils/listener'
12
+
13
+ include REXML
14
+
15
+ module PpmToGdl
16
+ class ContextListener < Listener
17
+
18
+ attr_reader :context
19
+
20
+ def initialize(ctx)
21
+ $LOG.debug "ContextListener::initialize()"
22
+ super()
23
+ @context = ctx
24
+ end
25
+
26
+ # Add a PPM variable to the context object
27
+ # attributes:: PPM element attributes
28
+ def openPPM(attributes)
29
+ $LOG.debug "ContextListener::openPPM( #{attributes} )"
30
+
31
+ if(@context.options.has_key?("customer") && !@context.options["customer"].empty?)
32
+ return unless (attributes.has_key?("Customer") && attributes["Customer"].include?(@context.options["customer"]))
33
+ end
34
+ ppmAlias = attributes["Name"]
35
+ confName = "p" + @context.createValidName(ppmAlias)
36
+ ppm = MPpm.new(confName, attributes)
37
+
38
+ @context.ppms[ppmAlias] = ppm
39
+ end # openPPM
40
+ end # class ContextListener
41
+ end # module PpmToGdl
42
+
43
+
@@ -0,0 +1,78 @@
1
+ ##############################################################################
2
+ # File:: contextparser.rb
3
+ # Purpose:: ContextParser holds all info and state about the current parsing
4
+ # process. This class will convert XML guideline files to GDL
5
+ # (Guideline Definition Language).
6
+ #
7
+ # Author:: Jeff McAffee 04/30/2015
8
+ #
9
+ ##############################################################################
10
+
11
+ require 'rexml/document'
12
+ require 'rexml/streamlistener'
13
+ require 'xmlutils/dumplistener'
14
+
15
+ module PpmToGdl
16
+ class ContextParser
17
+
18
+ attr_accessor :context
19
+
20
+ def initialize(ctx)
21
+ $LOG.debug "ContextParser::initialize()"
22
+ @context = ctx
23
+ @verbose = false
24
+ end
25
+
26
+ # Return true if verbose flag is set.
27
+ def verbose?()
28
+ return @verbose
29
+ end # verbose?
30
+
31
+ # Set configuration flags
32
+ # flg:: Array of options or single string option. Currently, only -v: verbose is available
33
+ def setFlag(flg)
34
+ $LOG.debug "ContextParser::setFlag( #{flg} )"
35
+ if (flg.class == Array)
36
+ flg.each do |f|
37
+ case f
38
+ when '-v'
39
+ @verbose = true
40
+ end
41
+ end # flg.each
42
+
43
+ return
44
+ end # if flg
45
+
46
+ case flg
47
+ when '-v'
48
+ @verbose = true
49
+ end
50
+ end
51
+
52
+ # Parse guideline XML
53
+ # fname:: Filename of XML file to parse
54
+ def parse(fname)
55
+ $LOG.debug "ContextParser::parse( #{fname} )"
56
+ puts "Parsing file." unless (!verbose?)
57
+ ctxListener = ContextListener.new(@context)
58
+ ctxListener.verbose = @verbose
59
+ parser = Parsers::StreamParser.new(File.new(fname), ctxListener)
60
+ parser.parse
61
+
62
+ =begin
63
+ puts "Parsing guideline." unless (!verbose?)
64
+ gdlListener = GdlListener.new(@context)
65
+ gdlListener.verbose = @verbose
66
+ parser = Parsers::StreamParser.new(File.new(fname), gdlListener)
67
+ parser.parse
68
+ =end
69
+ end # parse
70
+
71
+ # Dump collected context info to STDOUT
72
+ def dumpResults()
73
+ $LOG.debug "ContextParser::dumpResults()"
74
+ @listener.context.dumpPpms()
75
+ end # dumpResults
76
+ end # class ContextParser
77
+ end # module PpmToGdl
78
+
@@ -0,0 +1,396 @@
1
+ ###############################################################################
2
+ # File:: gdldoc.rb
3
+ # Purpose:: GdlDoc describes a GDL source document. It is used to create
4
+ # the final source doc.
5
+ #
6
+ # Author:: Jeff McAffee 04/30/2015
7
+ #
8
+ ##############################################################################
9
+
10
+ require 'xmlutils/gdltemplate'
11
+ require 'date'
12
+
13
+ module PpmToGdl
14
+ class GdlDoc
15
+
16
+ attr_reader :context
17
+ attr_reader :srcPath
18
+
19
+ def initialize(srcPath, ctx)
20
+ $LOG.debug "GdlDoc::initialize( #{srcPath}, ctx )"
21
+ #super()
22
+ @srcPath = srcPath
23
+ @context = ctx
24
+ end
25
+
26
+ #------------------------------------------------------------------------------------------------------------#
27
+ # setOptions - Set configuration option flags
28
+ #
29
+ # flg - Array of options or single string option. Currently, only -v: verbose is available
30
+ #
31
+ #------------------------------------------------------------------------------------------------------------#
32
+ def setOptions(flgs)
33
+ $LOG.debug "GdlDoc::setOptions( #{flgs} )"
34
+ if (flgs.class == Array)
35
+ flgs.each do |f|
36
+ case f
37
+ when '-v'
38
+ @verbose = true
39
+ end
40
+ end # flgs.each
41
+
42
+ return
43
+ end # if flgs
44
+
45
+ case flgs
46
+ when '-v'
47
+ @verbose = true
48
+ end
49
+ end
50
+
51
+ #-------------------------------------------------------------------------------------------------------------#
52
+ # currentDate - Generate today's date string
53
+ #
54
+ #
55
+ #------------------------------------------------------------------------------------------------------------#
56
+ def currentDate()
57
+ now = DateTime::now()
58
+ return now.strftime("%m/%d/%Y %H:%M:%S")
59
+ end # currentDate
60
+
61
+ #-------------------------------------------------------------------------------------------------------------#
62
+ # generate - Generate a GDL document
63
+ #
64
+ # returns string - generated file name
65
+ #
66
+ #------------------------------------------------------------------------------------------------------------#
67
+ def generate()
68
+ $LOG.debug "GdlDoc::generate()"
69
+ destDir = @context.options[:destdir]
70
+ destFile = @context.options[:destfile]
71
+ if(nil == destFile || destFile.empty?)
72
+ destFile = File.basename(@srcPath, ".xml") + ".gdl"
73
+ end
74
+
75
+ #if ($DEBUG)
76
+ puts "generate:"
77
+ puts " sourcePath: #{@srcPath}"
78
+ puts " destDir: #{destDir}"
79
+ puts " destFile: #{destFile}"
80
+ puts " context: #{@context}"
81
+ #end # if $DEBUG
82
+
83
+ tpl = GdlTemplate.new
84
+
85
+ genFile = File.join(destDir, destFile) # "#{@rootDir}/#{File.basename(@srcPath)}.gdl"
86
+
87
+ createOutdir(destDir)
88
+
89
+ misc = ""
90
+
91
+ if(@context.options.has_key?("customer") && !@context.options["customer"].empty?)
92
+ misc = "Using --customer option: #{@context.options['customer']}"
93
+ end
94
+
95
+ File.open("#{genFile}", "w") do |ofile|
96
+
97
+ ofile << tpl.fileHeader(destFile, currentDate(), misc )
98
+
99
+ ofile << tpl.sectionComment("PPM Definitions")
100
+
101
+ vars = @context.ppms.sort {|a, b| a[1].name.downcase <=> b[1].name.downcase}
102
+ vars.each do |rPpm|
103
+ ppm = rPpm[1]
104
+ ofile << tpl.ppm(ppm.dataType, ppm.varType, ppm.name, ppm.alias)
105
+ end # do
106
+
107
+ end # File.open
108
+
109
+ return genFile
110
+ end # generate
111
+
112
+ #-------------------------------------------------------------------------------------------------------------#
113
+ # generateRenameList - Generate a CSV rename list
114
+ #
115
+ # returns string - generated file name
116
+ #
117
+ #------------------------------------------------------------------------------------------------------------#
118
+ def generateRenameList()
119
+ $LOG.debug "GdlDoc::generateRenameList()"
120
+
121
+ if ($DEBUG)
122
+ puts "generateRenameList:"
123
+ puts " source: #{@srcPath}"
124
+ puts " rootDir: #{@rootDir}"
125
+ puts " context: #{@context}"
126
+ end # if $DEBUG
127
+
128
+ genFile = "#{@rootDir}/#{@srcPath}.rename.csv"
129
+
130
+ createOutdir(@rootDir)
131
+
132
+ File.open("#{genFile}", "w") do |ofile|
133
+
134
+ # Don't add to list if alias has '.'.
135
+ # Don't add to list if alias and name are identical.
136
+ vars = @context.rules.sort {|a, b| a[0].downcase <=> b[0].downcase}
137
+ vars.each do |ruleAry|
138
+ rule = ruleAry[1]
139
+ if (ruleAry[0] != rule.name)
140
+ if (nil == ruleAry[0].index('.'))
141
+ ofile << "rule,#{ruleAry[0]},#{rule.name}\n"
142
+ end # if no period
143
+ end # if name and alias do not match
144
+ end # do
145
+
146
+ # Don't add to list if ruleset is powerlookup.
147
+ # Don't add to list if alias and name are identical.
148
+ vars = @context.rulesets.sort {|a, b| a[0].downcase <=> b[0].downcase}
149
+ vars.each do |rulesetAry|
150
+ ruleset = rulesetAry[1]
151
+ if ("PL" != ruleset.type)
152
+ if (rulesetAry[0] != ruleset.name)
153
+ ofile << "ruleset,#{rulesetAry[0]},#{ruleset.name}\n"
154
+ end # if not identical
155
+ end # if not PL ruleset
156
+ end # do
157
+ end
158
+
159
+ return genFile
160
+ end # generateRenameList
161
+
162
+ #-------------------------------------------------------------------------------------------------------------#
163
+ # buildLookupList - Create a listing of lookup definitions from the context
164
+ #
165
+ #
166
+ #------------------------------------------------------------------------------------------------------------#
167
+ def buildLookupList()
168
+ $LOG.debug "GdlDoc::buildLookupList()"
169
+ lkups = Hash.new
170
+ lkList = ""
171
+ tpl = GdlTemplate.new
172
+
173
+ @context.lookups.each do |lkName, lkup|
174
+ params = @context.getLookupParamNames(lkName)
175
+ lkups[lkName] = tpl.lookup(lkName, params["xparam"], params["yparam"])
176
+ end # do
177
+
178
+ sorted = lkups.sort {|a, b| a[0].downcase <=> b[0].downcase}
179
+ sorted.each do |item|
180
+ lkList += "#{item[1]};\n"
181
+ end # do sorted
182
+
183
+ return lkList
184
+ end # def buildLookupList
185
+
186
+ #-------------------------------------------------------------------------------------------------------------#
187
+ # createOutdir - Create a directory if it does not exist
188
+ #
189
+ # outdir - Directory name/path to create
190
+ #
191
+ #------------------------------------------------------------------------------------------------------------#
192
+ def createOutdir(outdir)
193
+ if( !File.directory?(outdir) )
194
+ FileUtils.makedirs("#{outdir}")
195
+ end
196
+ end # def createOutdir
197
+
198
+ #-------------------------------------------------------------------------------------------------------------#
199
+ # outputFileHeader - output file header
200
+ #
201
+ # ofile - output file to write header to
202
+ # infile - Name of file to create header for
203
+ #
204
+ #------------------------------------------------------------------------------------------------------------#
205
+ def outputFileHeader(ofile, infile)
206
+ header = <<EOF
207
+ /* **************************************************************************
208
+ * File: #{infile}.gdl
209
+ * Generated guideline
210
+ *
211
+ * *************************************************************************/
212
+
213
+
214
+ EOF
215
+
216
+ ofile << header
217
+ end
218
+
219
+ #-------------------------------------------------------------------------------------------------------------#
220
+ # definitionHeader - output collected variables to file
221
+ #
222
+ # headerType - Header type (ex: DSM)
223
+ #
224
+ #------------------------------------------------------------------------------------------------------------#
225
+ def definitionHeader(headerType)
226
+ header = <<EOF
227
+
228
+
229
+
230
+
231
+ // ---------------------------- #{headerType} definitions ----------------------------
232
+
233
+ EOF
234
+
235
+ header
236
+ end # def definitionHeader
237
+
238
+ #-------------------------------------------------------------------------------------------------------------#
239
+ # outputPpm - generate a GDL version of a PPM definition based on PPM XML element
240
+ #
241
+ # var - XML element to generate output for
242
+ #
243
+ # @returns GDL output for PPM definition
244
+ #
245
+ #------------------------------------------------------------------------------------------------------------#
246
+ def outputPpm(var)
247
+ $LOG.debug "GdlDoc::outputPpm()"
248
+ xVarType = "text"
249
+ xvarSection = var.attribute('Type').to_s
250
+
251
+ case xvarSection
252
+ when 'APM'
253
+ varSection = "app"
254
+
255
+ when 'PRD'
256
+ varSection = "prd"
257
+
258
+ when 'CRP'
259
+ varSection = "crd"
260
+ end
261
+
262
+ varAlias = var.attribute('Alias')
263
+ varName = var.attribute('Name')
264
+
265
+ out = <<EOF
266
+ ppm #{xVarType} #{varSection} p#{varName} "#{varAlias}";
267
+ EOF
268
+
269
+ out # Return generated output
270
+ end # outputPpm
271
+
272
+ #-------------------------------------------------------------------------------------------------------------#
273
+ # outputDsm - generate a GDL version of a DSM definition based on DSM XML element
274
+ #
275
+ # var - XML element to generate output for
276
+ #
277
+ # @returns GDL output for DSM definition
278
+ #
279
+ #------------------------------------------------------------------------------------------------------------#
280
+ def outputDsm(var)
281
+ $LOG.debug "GdlDoc::outputDsm()"
282
+ xVarType = var.attribute('ProductType').to_s
283
+
284
+ case xVarType
285
+ when '1'
286
+ varType = "boolean"
287
+
288
+ when '2'
289
+ varType = "date"
290
+
291
+ when '3'
292
+ varType = "money"
293
+
294
+ when '4'
295
+ varType = "numeric"
296
+
297
+ when '5'
298
+ varType = "percentage"
299
+
300
+ when '6'
301
+ varType = "text"
302
+ end
303
+
304
+ varAlias = var.attribute('Alias')
305
+ varName = var.attribute('Name')
306
+
307
+ out = <<EOF
308
+ decision dpm #{varType} #{varName} "#{varAlias}";
309
+ EOF
310
+
311
+ out # Return generated output
312
+ end # outputDsm
313
+
314
+ #-------------------------------------------------------------------------------------------------------------#
315
+ # outputDpm - generate a GDL version of a DPM definition based on DPM XML element
316
+ #
317
+ # var - XML element to generate output for
318
+ #
319
+ # @returns GDL output for DPM definition
320
+ #
321
+ #------------------------------------------------------------------------------------------------------------#
322
+ def outputDpm(var)
323
+ $LOG.debug "GdlDoc::outputDpm()"
324
+ xVarType = var.attribute('ProductType').to_s
325
+
326
+ case xVarType
327
+ when '1'
328
+ varType = "boolean"
329
+
330
+ when '2'
331
+ varType = "date"
332
+
333
+ when '3'
334
+ varType = "money"
335
+
336
+ when '4'
337
+ varType = "numeric"
338
+
339
+ when '5'
340
+ varType = "percentage"
341
+
342
+ when '6'
343
+ varType = "text"
344
+ end
345
+
346
+ varAlias = var.attribute('Alias')
347
+ varName = var.attribute('Name')
348
+
349
+ out = <<EOF
350
+ dpm #{varType} #{varName} "#{varAlias}";
351
+ EOF
352
+
353
+ out # Return generated output
354
+ end # outputDpm
355
+
356
+ #-------------------------------------------------------------------------------------------------------------#
357
+ # outputRuleInfo - output collected variables to file
358
+ #
359
+ # ofile - output file handle
360
+ #
361
+ #------------------------------------------------------------------------------------------------------------#
362
+ def outputRuleInfo(ofile)
363
+ $LOG.debug "GdlDoc::outputRuleInfo()"
364
+
365
+ ofile << definitionHeader("Rule")
366
+
367
+ @rules.each_value do |rule|
368
+ ofile << outputRule(rule)
369
+ end
370
+ end # def outputRuleInfo
371
+
372
+ #-------------------------------------------------------------------------------------------------------------#
373
+ # outputRule - generate a GDL version of a rule definition based on Rule XML element
374
+ #
375
+ # rule - XML element to generate output for
376
+ #
377
+ # @returns GDL output for Rule definition
378
+ #
379
+ #------------------------------------------------------------------------------------------------------------#
380
+ def outputRule(rule)
381
+ $LOG.debug "GdlDoc::outputRule()"
382
+ ruleParts = rule.elements.to_a
383
+ puts ""
384
+ puts "Rule Parts:"
385
+ puts "#{ruleParts.inspect}"
386
+ puts ""
387
+
388
+ visitor = XmlRuleVisitor.new
389
+ output = ""
390
+ visitor.lookupData = @lookupData
391
+
392
+ return visitor.visit(rule, output)
393
+ end # outputRule
394
+ end # class GdlDoc
395
+ end # module PpmToGdl
396
+