Class: Gjp::Pom
- Inherits:
-
Object
- Object
- Gjp::Pom
- Defined in:
- lib/gjp/pom.rb
Overview
encapsulates a pom.xml file
Instance Method Summary collapse
- #artifact_id ⇒ Object
- #description ⇒ Object
- #group_id ⇒ Object
-
#initialize(filename) ⇒ Pom
constructor
A new instance of Pom.
- #license_name ⇒ Object
- #name ⇒ Object
- #runtime_dependency_ids ⇒ Object
- #scm_connection ⇒ Object
- #scm_url ⇒ Object
- #url ⇒ Object
- #version ⇒ Object
Constructor Details
#initialize(filename) ⇒ Pom
Returns a new instance of Pom.
9 10 11 12 |
# File 'lib/gjp/pom.rb', line 9 def initialize(filename) @doc = Nokogiri::XML(open(filename).read) @doc.remove_namespaces! end |
Instance Method Details
#artifact_id ⇒ Object
18 19 20 |
# File 'lib/gjp/pom.rb', line 18 def artifact_id @doc.xpath("project/artifactId").text || "" end |
#description ⇒ Object
30 31 32 |
# File 'lib/gjp/pom.rb', line 30 def description @doc.xpath("project/description").text || "" end |
#group_id ⇒ Object
14 15 16 |
# File 'lib/gjp/pom.rb', line 14 def group_id @doc.xpath("project/groupId").text || "" end |
#license_name ⇒ Object
38 39 40 |
# File 'lib/gjp/pom.rb', line 38 def license_name @doc.xpath("project/licenses/license/name").text || "" end |
#name ⇒ Object
22 23 24 |
# File 'lib/gjp/pom.rb', line 22 def name @doc.xpath("project/name").text || "" end |
#runtime_dependency_ids ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/gjp/pom.rb', line 42 def runtime_dependency_ids result = @doc.xpath("project/dependencies/dependency[\ not(optional='true') and not(scope='provided') and not(scope='test') and not(scope='system')\ ]").map do |element| [element.xpath("groupId").text, element.xpath("artifactId").text, element.xpath("version").text] end end |
#scm_connection ⇒ Object
50 51 52 |
# File 'lib/gjp/pom.rb', line 50 def scm_connection @doc.xpath("project/scm/connection").text || "" end |
#scm_url ⇒ Object
54 55 56 |
# File 'lib/gjp/pom.rb', line 54 def scm_url @doc.xpath("project/scm/url").text || "" end |
#url ⇒ Object
34 35 36 |
# File 'lib/gjp/pom.rb', line 34 def url @doc.xpath("project/url").text || "" end |
#version ⇒ Object
26 27 28 |
# File 'lib/gjp/pom.rb', line 26 def version @doc.xpath("project/version").text || "" end |