class DeveloperAndContributors @@reactorHandler = ReactorHandler.new @@mergeRepository = MergeRepository.new @@dependencyHandler = DependencyHandler.new def findCommonDevelopers(project_directory_path,tagName) developerList = generateMasterDeveloperList(project_directory_path,tagName) commonList = commonDeveloperorContributors(project_directory_path,tagName,developerList) return commonList end def generateMasterDeveloperList(project_directory_path,tagName) childPomPathArr = @@reactorHandler.fetchGidArtifactIdAndVersionFromChildModule(project_directory_path,false) developerList = Array.new childPomPathArr.each do |eachChildModule| child_pom_document = Nokogiri::XML(open(eachChildModule)) child_pom_document.css("project/#{tagName}").each do |eachChildRepo| emailNode = eachChildRepo.at("email") email=nil if (!emailNode.nil? and !developerList.include?emailNode.text) developerList.push(emailNode.text) end end end return developerList end def commonDeveloperorContributors(project_directory_path,tagName,developerList) commonList = Array.new pomArr = @@reactorHandler.fetchGidArtifactIdAndVersionFromChildModule(project_directory_path,false) if !(pomArr.nil? || pomArr.empty?) developerList.each do |eachDeveloper| flag = true pomArr.each do |eachPomPath| if (flag) flag=false pom_document = @@reactorHandler.parse_xml_from_file(eachPomPath) pom_document.css("project/#{tagName}").each do |eachChildRepo| if (!eachChildRepo.at("email").nil?) email= eachChildRepo.at("email").text if (eachDeveloper==email) flag = true end end end if flag if (!commonList.include?eachDeveloper) commonList.push(eachDeveloper) end else commonList.delete(eachDeveloper) end end end end end return commonList end def mergeDeveloperAndContributors(project_directory_path,commontags,tagName) childPomPathArr = @@reactorHandler.fetchGidArtifactIdAndVersionFromChildModule(project_directory_path,false) developersAndContributorsList = Array.new emailList = Array.new childPomPathArr.each do |eachChildModule| child_pom_document = Nokogiri::XML(open(eachChildModule)) child_pom_document.css("project/#{tagName}").each do |eachChildRepo| emailNode = eachChildRepo.at("email") if !emailNode.nil? email = emailNode.text if (commontags.include?email and !emailList.include?email) emailList.push(email) developersAndContributorsList.push(eachChildRepo) end end end end return developersAndContributorsList end def addDeveloperAndContributersInReator(project_directory_path,commontags,tagName) if (!commontags.nil? and !commontags.empty?) @@mergeRepository.addRepoIntoReactorPom(project_directory_path,commontags,tagName) puts "Added developers and contributors" end end def removeCommonDevelopersAndContributorsFromChild(project_directory_path,commontags,tagName) childPomPathArr = @@reactorHandler.fetchGidArtifactIdAndVersionFromChildModule(project_directory_path,false) childPomPathArr.each do |eachChildModule| child_pom_document = Nokogiri::XML(open(eachChildModule)) tagArr = tagName.split("/") baseName = tagArr[0] lastTag = tagArr[1] baseNode = child_pom_document.at("project/#{baseName}") if (!baseNode.nil?) baseNode.css(lastTag).each do |eachChildRepo| emailNode = eachChildRepo.at("email") if !emailNode.nil? email = emailNode.text if (commontags.include?email) eachChildRepo.remove end end end pom_nokogiri = @@dependencyHandler.add_node_element('project', baseNode, child_pom_document) File.write(eachChildModule, pom_nokogiri) end end end def removeEmptyTags(project_directory_path,tagName) childPomPathArr = @@reactorHandler.fetchGidArtifactIdAndVersionFromChildModule(project_directory_path,false) childPomPathArr.each do |eachChildModule| child_pom_document = Nokogiri::XML(open(eachChildModule)) tagArr = tagName.split("/") baseName = tagArr[0] lastTag = tagArr[1] baseNode = child_pom_document.at("project/#{baseName}") if (!baseNode.nil?) lastNode = baseNode.at(lastTag) if (lastNode.nil?) baseNode.remove File.write(eachChildModule, child_pom_document) end end end puts "Removed Common #{tagName}" end end