class ParseDecision::Plugin::PpmXpath

#######################################################################

PPM XPath plugin

Public Class Methods

new() click to toggle source
# File lib/parse_decision/plugin/ppm_xpath.rb, line 19
def initialize()
  $LOG.debug "PpmXpath::initialize"
  @fnameTemplate = "@INDEX@-APP-PPMXPATH.xml"
  @searchStr1 = "*APP XPATH xml*"
  @searchStr2 = "<PPXPATH>"
end

Public Instance Methods

execute(context, ln) click to toggle source
# File lib/parse_decision/plugin/ppm_xpath.rb, line 26
def execute(context, ln)
 #$LOG.debug "PpmXpath::execute"
 #require 'pry'; binding.pry
 case context.state
 when :app
   return is_ppm_xpath context, ln

 when :appPpmXpath
   return store_xpath_content context, ln

 else
   return false
 end # case
end
is_ppm_xpath(context,ln) click to toggle source
# File lib/parse_decision/plugin/ppm_xpath.rb, line 41
def is_ppm_xpath(context,ln)
  if ln.include?(@searchStr1)
    context.state = :appPpmXpath
    return true
  end
  return false
end
store_xpath_content(context, ln) click to toggle source
# File lib/parse_decision/plugin/ppm_xpath.rb, line 49
def store_xpath_content(context, ln)
  if ln.include?(@searchStr2)
    context.state = :app
    outfile = apply_template(@fnameTemplate, "@INDEX@", context.indexStr)
    puts "Creating App XML XPath file: #{outfile}" if context.verbose
    File.open(context.outputPath(outfile), "w") do |f|
      write_to_file(f,ln)
    end
    return true
  end

  # This is probably an empty line.
  # Return true since we're in the xpath state and there is no need for
  # any other plugin to handle this line.
  return true
end