Sha256: 31c0ac599637679f6bd84daa9fbe8db4c917bc948b577ca7b49337b6bd5689c2
Contents?: true
Size: 1.19 KB
Versions: 9
Compression:
Stored size: 1.19 KB
Contents
require 'nokogiri' module Dcgen def self.label master , destination 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 puts "Labels:" if not remove_labels.empty? remove_labels.each do |label| puts " #{label}" end remove_labels end end
Version data entries
9 entries across 9 versions & 1 rubygems