Sha256: c687b57e8b5b5cf7c39eda07b625290b39c7ca230726b80a1a10c98d54156e51

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

require 'nokogiri'

module Dcgen

  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
end

Version data entries

3 entries across 3 versions & 1 rubygems

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