module Dcgen

Constants

VERSION

Public Class Methods

apexclass(master , destination, output = true) click to toggle source
# File lib/dcgen/plugins/apexclass.rb, line 3
def self.apexclass master , destination, output = true

  master_classes = Dir.glob(master + '/classes/*cls').map {|c| c.match(/^.*\/(.*).cls$/)[1] }
  destination_classes = Dir.glob(destination + '/classes/*cls').map {|c| c.match(/^.*\/(.*).cls$/)[1] }

  remove_classes = destination_classes - master_classes

  if output
    puts "ApexClasses:" if not remove_classes.empty?
    remove_classes.each do |apexclass|
      puts "  #{apexclass}"
    end
  end

  remove_classes

end
apexcomponent(master , destination, output = true) click to toggle source
# File lib/dcgen/plugins/apexcomponent.rb, line 3
def self.apexcomponent master , destination, output = true

  master_components = Dir.glob(master + '/components/*component').map {|c| c.match(/^.*\/(.*).component$/)[1] }
  destination_components = Dir.glob(destination + '/components/*component').map {|c| c.match(/^.*\/(.*).component$/)[1] }

  remove_components = destination_components - master_components

  if output
    puts "ApexComponents:" if not remove_components.empty?
    remove_components.each do |apexcomponent|
      puts "  #{apexcomponent}"
    end
  end

  remove_components

end
apexpage(master , destination, output = true) click to toggle source
# File lib/dcgen/plugins/apexpage.rb, line 3
def self.apexpage master , destination, output = true

  master_pages = Dir.glob(master + '/pages/*page').map {|c| c.match(/^.*\/(.*).page$/)[1] }
  destination_pages = Dir.glob(destination + '/pages/*page').map {|c| c.match(/^.*\/(.*).page$/)[1] }

  remove_pages = destination_pages - master_pages

  if output
    puts "ApexPages:" if not remove_pages.empty?
    remove_pages.each do |aplexpage|
      puts "  #{aplexpage}"
    end
  end

  remove_pages

end
apextrigger(master , destination, output = true) click to toggle source
# File lib/dcgen/plugins/apextrigger.rb, line 3
def self.apextrigger master , destination, output = true

  master_triggers = Dir.glob(master + '/triggers/*trigger').map {|c| c.match(/^.*\/(.*).trigger$/)[1] }
  destination_triggers = Dir.glob(destination + '/triggers/*trigger').map {|c| c.match(/^.*\/(.*).trigger$/)[1] }

  remove_triggers = destination_triggers - master_triggers

  if output
    puts "ApexTriggers:" if not remove_triggers.empty?
    remove_triggers.each do |apextrigger|
      puts "  #{apextrigger}"
    end
  end

  remove_triggers

end
approvalprocess(master , destination, output = true) click to toggle source
# File lib/dcgen/plugins/approvalprocess.rb, line 3
def self.approvalprocess master , destination, output = true

  master_approvalprocess = Dir.glob(master + '/approvalProcesses/*approvalProcess').map {|c| c.match(/^.*\/(.*).approvalProcess$/)[1] }
  destination_approvalprocess = Dir.glob(destination + '/approvalProcesses/*approvalProcess').map {|c| c.match(/^.*\/(.*).approvalProcess$/)[1] }

  remove_approvalprocess = destination_approvalprocess - master_approvalprocess

  if output
    puts "ApprovalProcesses:" if not remove_approvalprocess.empty?
    remove_approvalprocess.each do |approvalprocess|
      puts "  #{approvalprocess}"
    end
  end

  remove_approvalprocess

end
customfield(master , destination, output = true) click to toggle source
# File lib/dcgen/plugins/customfield.rb, line 5
def self.customfield master , destination, output = true

  remove_customfields = []

  master_objects = Dir.glob(master + '/objects/*object').map {|c| c.match(/^.*\/(.*).object$/)[1] }

  master_objects.each do |obj|

    master_obj_file = File.join(master,'objects',obj + '.object')
    destination_obj_file = File.join(destination,'objects',obj + '.object')

    if File.exists? destination_obj_file

      master_obj_xml = File.open(master_obj_file).read
      destination_obj_xml = File.open(destination_obj_file).read

      master_doc = Nokogiri::XML(master_obj_xml).remove_namespaces!
      destination_doc = Nokogiri::XML(destination_obj_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('//fields/fullName').each do |field|
        remove_customfields << "#{obj}.#{field.text}" if master_doc.xpath("//fields[fullName=\"#{field.text}\"]").empty?
      end

    end

  end

  
  if output
    puts "CustomFields:" if not remove_customfields.empty?
    remove_customfields.each do |customfield|
      puts "  #{customfield}"
    end
  end

  remove_customfields

end
customobject(master , destination, output = true) click to toggle source
# File lib/dcgen/plugins/customobject.rb, line 3
def self.customobject master , destination, output = true

  master_customobject = Dir.glob(master + '/objects/*object').map {|c| c.match(/^.*\/(.*).object$/)[1] }
  destination_customobject = Dir.glob(destination + '/objects/*object').map {|c| c.match(/^.*\/(.*).object$/)[1] }

  remove_customobject = destination_customobject - master_customobject

  if output
    puts "CustomObjects:" if not remove_customobject.empty?
    remove_customobject.each do |customobject|
      puts "  #{customobject}"
    end
  end

  remove_customobject

end
group(master , destination, output = true) click to toggle source
# File lib/dcgen/plugins/group.rb, line 3
def self.group master , destination, output = true

  master_groups = Dir.glob(master + '/groups/*group').map {|c| c.match(/^.*\/(.*).group$/)[1] }
  destination_groups = Dir.glob(destination + '/groups/*group').map {|c| c.match(/^.*\/(.*).group$/)[1] }

  remove_groups = destination_groups - master_groups

  if output
    puts "Groups:" if not remove_groups.empty?
    remove_groups.each do |group|
      puts "  #{group}"
    end
  end

  remove_groups

end
label(master , destination, output = true) click to toggle source
# File lib/dcgen/plugins/label.rb, line 5
def self.label master , destination, output = true

  remove_labels = []

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

  master_labels.each do |label|

    master_labels_file = File.join(master,'labels',label + '.labels')
    destination_labels_file = File.join(destination,'labels',label + '.labels')

    if File.exists? destination_labels_file

      master_labels_xml = File.open(master_labels_file).read
      destination_labels_xml = File.open(destination_labels_file).read

      master_doc = Nokogiri::XML(master_labels_xml).remove_namespaces!
      destination_doc = Nokogiri::XML(destination_labels_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('//labels/fullName').each do |lb|
        remove_labels << "#{lb.text}" if master_doc.xpath("//labels[fullName=\"#{lb.text}\"]").empty?
      end

    end

  end

  
  if output
    puts "Labels:" if not remove_labels.empty?
    remove_labels.each do |label|
      puts "  #{label}"
    end
  end

  remove_labels

end
layout(master , destination, output = true) click to toggle source
# File lib/dcgen/plugins/layout.rb, line 3
def self.layout master , destination, output = true

  master_layout = Dir.glob(master + '/layouts/*layout').map {|c| c.match(/^.*\/(.*).layout$/)[1] }
  destination_layout = Dir.glob(destination + '/layouts/*layout').map {|c| c.match(/^.*\/(.*).layout$/)[1] }

  remove_layout = destination_layout - master_layout

  if output
    puts "Layouts:" if not remove_layout.empty?
    remove_layout.each do |layout|
      puts "  #{layout}"
    end
  end

  remove_layout

end
permissionset(master , destination, output = true) click to toggle source
# File lib/dcgen/plugins/permissionset.rb, line 3
def self.permissionset master , destination, output = true

  master_permissionset = Dir.glob(master + '/permissionsets/*permissionset').map {|c| c.match(/^.*\/(.*).permissionset$/)[1] }
  destination_permissionset = Dir.glob(destination + '/permissionsets/*permissionset').map {|c| c.match(/^.*\/(.*).permissionset$/)[1] }

  remove_permissionset = destination_permissionset - master_permissionset

  if output
    puts "PermissionSets:" if not remove_permissionset.empty?
    remove_permissionset.each do |permissionset|
      puts "  #{permissionset}"
    end
  end

  remove_permissionset

end
validationrule(master , destination, output = true) click to toggle source
# File lib/dcgen/plugins/validationrule.rb, line 5
def self.validationrule master , destination, output = true

  remove_validationrules = []

  master_obj = Dir.glob(master + '/objects/*object').map {|c| c.match(/^.*\/(.*).object$/)[1] }

  master_obj.each do |obj|

    master_obj_file = File.join(master,'objects',obj + '.object')
    destination_obj_file = File.join(destination,'objects',obj + '.object')

    if File.exists? destination_obj_file

      master_obj_xml = File.open(master_obj_file).read
      destination_obj_xml = File.open(destination_obj_file).read

      master_obj_xml = Nokogiri::XML(master_obj_xml).remove_namespaces!
      destination_obj_xml = Nokogiri::XML(destination_obj_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_obj_xml.xpath('//validationRules/fullName').each do |vr|
        remove_validationrules << "#{obj}.#{vr.text}" if master_obj_xml.xpath("//validationRules[fullName=\"#{vr.text}\"]").empty?
      end

    end

  end

  
  if output
    puts "ValidationRules:" if not remove_validationrules.empty?
    remove_validationrules.each do |obj|
      puts "  #{obj}"
    end
  end

  remove_validationrules

end
workflowfieldupdate(master , destination, output = true) click to toggle source
# File lib/dcgen/plugins/workflowfieldupdate.rb, line 5
def self.workflowfieldupdate master , destination, output = true

  remove_fieldupdates = []

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

  master_objects.each do |obj|

    master_obj_file = File.join(master,'workflows',obj + '.workflow')
    destination_obj_file = File.join(destination,'workflows',obj + '.workflow')

    if File.exists? destination_obj_file

      master_obj_xml = File.open(master_obj_file).read
      destination_obj_xml = File.open(destination_obj_file).read

      master_doc = Nokogiri::XML(master_obj_xml).remove_namespaces!
      destination_doc = Nokogiri::XML(destination_obj_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('//fieldUpdates/fullName').each do |field|
        remove_fieldupdates << "#{obj}.#{field.text}" if master_doc.xpath("//fieldUpdates[fullName=\"#{field.text}\"]").empty?
      end

    end

  end

  if output
    puts "FieldUpdates:" if not remove_fieldupdates.empty?
    remove_fieldupdates.each do |fieldupdate|
      puts "  #{fieldupdate}"
    end
  end

  remove_fieldupdates

end
workflowrule(master , destination, output = true) click to toggle source
# File lib/dcgen/plugins/workflowrule.rb, line 5
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