Sha256: fa535d64f61f01fb4a6523a8c86c47648042e7d6c350ec2a59e1837a944f9954
Contents?: true
Size: 1.07 KB
Versions: 7
Compression:
Stored size: 1.07 KB
Contents
require 'nokogiri' module Dcgen def self.customfield master , destination remove_fields = [] 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_fields << "#{obj}.#{field.text}" if master_doc.xpath("//fields[fullName=\"#{field.text}\"]").empty? end end end remove_fields end end
Version data entries
7 entries across 7 versions & 1 rubygems