class Dcgen::App

Attributes

destination[RW]
exclude[RW]
include[RW]
master[RW]
output[RW]
verbose[RW]

Public Class Methods

new() click to toggle source
# File lib/dcgen/app.rb, line 6
def initialize 

  @verbose = true
  @metadata = {}
  @exclude = []
  @include = []

end

Public Instance Methods

generate_destructive_changes() click to toggle source
# File lib/dcgen/app.rb, line 64
def generate_destructive_changes

  # Validate directories
  validate_directories

  # header output
  print_header if @verbose

  # Load plugins and build metadata variables
  plugins = Dir.glob(File.dirname(__FILE__) + "/plugins/*")

  plugins.each do |plugin|

    require_relative plugin

    plugin_name = plugin.match(/^.*\/(.*).rb$/)[1]

    if @include.include?(plugin_name) || @include.empty?
      plugin_metadata = eval "Dcgen::#{plugin_name} @master, @destination, @verbose" 
      @metadata[plugin_name.to_sym] = plugin_metadata - @exclude unless plugin_metadata.nil?
    else
      @metadata[plugin_name.to_sym] = []
    end

  end

  # Generate the template and write to file
  generate_xml

end
generate_xml() click to toggle source
# File lib/dcgen/app.rb, line 24
    def generate_xml

      # Generate destructive change
      dc_erb_tpl = File.open(File.join(File.dirname(__FILE__),'..','..','tpl','destructiveChanges.xml.erb')).read
      renderer = ERB.new(dc_erb_tpl,0,'>') 

      out_file = @output || 'destructiveChanges.xml' 

      File.open(out_file,'w') do |file|
        file.write renderer.result(binding)
      end

      puts "
File generated:
===============

#{out_file}

" if @verbose

    end
print_header() click to toggle source
validate_directories() click to toggle source
# File lib/dcgen/app.rb, line 15
def validate_directories

  raise ArgumentError, "#{@master} dir not found" if not Dir.exists? @master
  raise ArgumentError, "#{@destination} dir not found" if not Dir.exists? @destination
  raise ArgumentError, "#{@master} package.xml not found" if not File.exists? File.join(@master,'package.xml')
  raise ArgumentError, "#{@destination} package.xml not found" if not File.exists? File.join(@destination,'package.xml')

end