Class: DeveloperAndContributors

Inherits:
Object
  • Object
show all
Defined in:
lib/mavenReactorService/DeveloperAndContributors.rb

Constant Summary collapse

@@reactorHandler =
ReactorHandler.new
@@mergeRepository =
MergeRepository.new
@@dependencyHandler =
DependencyHandler.new

Instance Method Summary collapse

Instance Method Details

#addDeveloperAndContributersInReator(project_directory_path, commontags, tagName) ⇒ Object



79
80
81
82
83
84
85
# File 'lib/mavenReactorService/DeveloperAndContributors.rb', line 79

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

#commonDeveloperorContributors(project_directory_path, tagName, developerList) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/mavenReactorService/DeveloperAndContributors.rb', line 27

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

#findCommonDevelopers(project_directory_path, tagName) ⇒ Object



5
6
7
8
9
# File 'lib/mavenReactorService/DeveloperAndContributors.rb', line 5

def findCommonDevelopers(project_directory_path,tagName)
  developerList =  generateMasterDeveloperList(project_directory_path,tagName)
  commonList = commonDeveloperorContributors(project_directory_path,tagName,developerList)
  return commonList
end

#generateMasterDeveloperList(project_directory_path, tagName) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/mavenReactorService/DeveloperAndContributors.rb', line 11

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

#mergeDeveloperAndContributors(project_directory_path, commontags, tagName) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/mavenReactorService/DeveloperAndContributors.rb', line 59

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

#removeCommonDevelopersAndContributorsFromChild(project_directory_path, commontags, tagName) ⇒ Object



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/mavenReactorService/DeveloperAndContributors.rb', line 87

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

#removeEmptyTags(project_directory_path, tagName) ⇒ Object



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/mavenReactorService/DeveloperAndContributors.rb', line 111

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