Class: PropertyHandler
- Inherits:
-
Object
- Object
- PropertyHandler
- Defined in:
- lib/mavenReactorService/PropertyHandler.rb
Constant Summary collapse
- @@basicInfoHandler =
BasicInfoHandler.new
- @@tempPath =
nil
- @@dependencyHandler =
DependencyHandler.new
Instance Method Summary collapse
-
#findPlaceHolderWithinProperties(tempPropertyMap, originalPropertyMap, parentPropertyMap, grandparentPropertyMap) ⇒ Object
This api takes decision to indentify the dependency where the place holder found.
-
#getgrandParentPropertyMap ⇒ Object
return the property map of parent-pom.
-
#getImidiateParentPropertyMap ⇒ Object
return the property map of parent-pom.
-
#getOriginalPropertyMap ⇒ Object
return the property map of child-pom.
-
#getTempPropertyMap ⇒ Object
return the property map of effetive-pom.
-
#handleProperties(project_directory_path) ⇒ Object
This api will handle properties #.
-
#replaceVersionIntempFile(propKey, propVal) ⇒ Object
This api replace version by place-holder #.
Instance Method Details
#findPlaceHolderWithinProperties(tempPropertyMap, originalPropertyMap, parentPropertyMap, grandparentPropertyMap) ⇒ Object
This api takes decision to indentify the dependency where the place holder found. #
85 86 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/PropertyHandler.rb', line 85 def findPlaceHolderWithinProperties(tempPropertyMap,originalPropertyMap,parentPropertyMap,grandparentPropertyMap) if (!tempPropertyMap.empty?) tempPropertyMap.each do |propKey,propVal| originalPropVal = nil parentPropVal = nil grandParentPropVal = nil if (!originalPropertyMap.empty?) originalPropVal = originalPropertyMap[propKey] end if (!parentPropertyMap.empty?) parentPropVal = parentPropertyMap[propKey] end if (!grandparentPropertyMap.empty?) grandParentPropVal = grandparentPropertyMap[propKey] end if (!originalPropVal.nil? and originalPropVal.include? "${") replaceVersionIntempFile(propKey,originalPropVal) elsif (!parentPropVal.nil? and parentPropVal.include? "${") replaceVersionIntempFile(propKey,parentPropVal) elsif (!grandParentPropVal.nil? and grandParentPropVal.include? "${") replaceVersionIntempFile(propKey,grandParentPropVal) end end end end |
#getgrandParentPropertyMap ⇒ Object
return the property map of parent-pom
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/mavenReactorService/PropertyHandler.rb', line 63 def getgrandParentPropertyMap() pom_document = @@basicInfoHandler.copyTagsFromOriginalPom(Dir.getwd) parent = pom_document.at("project/parent") propertyMap = Hash.new if !parent.nil? parent_pom_document = @@dependencyHandler.getParentPomDomObjFromUrl(pom_document) grandParent = parent_pom_document.at("project/parent") if !grandParent.nil? grand_parent_pom_document = @@dependencyHandler.getParentPomDomObjFromUrl(parent_pom_document) grand_parent_pom_document.css("project/properties").children.each do |eachproperty| tagName = eachproperty.name tagValue = eachproperty.text if tagName!='text' propertyMap[tagName] = tagValue end end end end return propertyMap end |
#getImidiateParentPropertyMap ⇒ Object
return the property map of parent-pom
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/mavenReactorService/PropertyHandler.rb', line 45 def getImidiateParentPropertyMap() pom_document = @@basicInfoHandler.copyTagsFromOriginalPom(Dir.getwd) parent = pom_document.at("project/parent") propertyMap = Hash.new if !parent.nil? parent_pom_document = @@dependencyHandler.getParentPomDomObjFromUrl(pom_document) parent_pom_document.css("project/properties").children.each do |eachproperty| tagName = eachproperty.name tagValue = eachproperty.text if tagName!='text' propertyMap[tagName] = tagValue end end end return propertyMap end |
#getOriginalPropertyMap ⇒ Object
return the property map of child-pom
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/mavenReactorService/PropertyHandler.rb', line 31 def getOriginalPropertyMap() pom_document = @@basicInfoHandler.copyTagsFromOriginalPom(Dir.getwd) propertyMap = Hash.new pom_document.css("project/properties").children.each do |eachproperty| tagName = eachproperty.name tagValue = eachproperty.text if tagName!='text' propertyMap[tagName] = tagValue end end return propertyMap end |
#getTempPropertyMap ⇒ Object
return the property map of effetive-pom
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/mavenReactorService/PropertyHandler.rb', line 17 def getTempPropertyMap() temp_pom_document = Nokogiri::XML(open("temp.xml")) propertyMap = Hash.new temp_pom_document.css("project/properties").children.each do |eachproperty| tagName = eachproperty.name tagValue = eachproperty.text if tagName!='text' propertyMap[tagName] = tagValue end end return propertyMap end |
#handleProperties(project_directory_path) ⇒ Object
This api will handle properties #
6 7 8 9 10 11 12 13 14 |
# File 'lib/mavenReactorService/PropertyHandler.rb', line 6 def handleProperties(project_directory_path) @@tempPath = "#{project_directory_path}/temp.xml" effective_pom_doc = @@basicInfoHandler.copyTagsFromEffectivePom(project_directory_path) properties = effective_pom_doc.at("project/properties") if (!properties.nil?) File.write(@@tempPath, properties, File.size(@@tempPath), mode: 'a') puts "::Prfoperties is added successfully::" end end |
#replaceVersionIntempFile(propKey, propVal) ⇒ Object
This api replace version by place-holder #
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/mavenReactorService/PropertyHandler.rb', line 112 def replaceVersionIntempFile(propKey,propVal) temp_pom_document = Nokogiri::XML(open("temp.xml")) nokObj = Nokogiri::XML::Node propertiesNode = temp_pom_document.at("project/properties") temp_pom_document.css("project/properties").children.each do |eachProperty| tagName = eachProperty.name if (tagName==propKey) eachProperty.remove propertyNode = nokObj.new(tagName,propertiesNode) propertyNode.content=propVal propertiesNode.add_child(propertyNode) end end formated_pom_doc = @@dependencyHandler.add_node_element("project",propertiesNode,temp_pom_document) File.write("temp.xml", formated_pom_doc.to_xml) end |