Sha256: bdfa5a72aa22339319261698c44d9a987a7487ea5baf52c40266263b5b04e557

Contents?: true

Size: 1.43 KB

Versions: 3

Compression:

Stored size: 1.43 KB

Contents

require 'nokogiri'

module Dcgen

  def self.workflowrule master , destination, output = true

    remove_workflowrules = []

    master_workflowrules = Dir.glob(master + '/workflows/*workflow').map {|c| c.match(/^.*\/(.*).workflow$/)[1] }

    master_workflowrules.each do |workflowrule|

      master_workflowrules_file = File.join(master,'workflows',workflowrule + '.workflow')
      destination_workflowrules_file = File.join(destination,'workflows',workflowrule + '.workflow')

      if File.exists? destination_workflowrules_file

        master_workflowrules_xml = File.open(master_workflowrules_file).read
        destination_workflowrules_xml = File.open(destination_workflowrules_file).read

        master_doc = Nokogiri::XML(master_workflowrules_xml).remove_namespaces!
        destination_doc = Nokogiri::XML(destination_workflowrules_xml).remove_namespaces!

        # Find all the customfields that are in destination, if they are not present in
        # master, then they have to be in the remove list
        destination_doc.xpath('//rules/fullName').each do |rule|
          remove_workflowrules << "#{workflowrule}.#{rule.text}" if master_doc.xpath("//rules[fullName=\"#{rule.text}\"]").empty?
        end

      end

    end

    if output
      puts "WorkflowRules:" if not remove_workflowrules.empty?
      remove_workflowrules.each do |workflowrule|
        puts "  #{workflowrule}"
      end
    end

    remove_workflowrules

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
salesforce-dcgen-0.8.0 lib/dcgen/plugins/workflowrule.rb
salesforce-dcgen-0.7.0 lib/dcgen/plugins/workflowrule.rb
salesforce-dcgen-0.6.0 lib/dcgen/plugins/workflowrule.rb