Class: Gjp::Pom

Inherits:
Object
  • Object
show all
Defined in:
lib/gjp/pom.rb

Overview

encapsulates a pom.xml file

Instance Method Summary collapse

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_idObject



18
19
20
# File 'lib/gjp/pom.rb', line 18

def artifact_id
  @doc.xpath("project/artifactId").text || ""
end

#descriptionObject



30
31
32
# File 'lib/gjp/pom.rb', line 30

def description
  @doc.xpath("project/description").text || ""
end

#group_idObject



14
15
16
# File 'lib/gjp/pom.rb', line 14

def group_id
  @doc.xpath("project/groupId").text || ""
end

#license_nameObject



38
39
40
# File 'lib/gjp/pom.rb', line 38

def license_name
  @doc.xpath("project/licenses/license/name").text || ""
end

#nameObject



22
23
24
# File 'lib/gjp/pom.rb', line 22

def name
  @doc.xpath("project/name").text || ""
end

#runtime_dependency_idsObject



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_connectionObject



50
51
52
# File 'lib/gjp/pom.rb', line 50

def scm_connection
  @doc.xpath("project/scm/connection").text || ""
end

#scm_urlObject



54
55
56
# File 'lib/gjp/pom.rb', line 54

def scm_url
  @doc.xpath("project/scm/url").text || ""
end

#urlObject



34
35
36
# File 'lib/gjp/pom.rb', line 34

def url
  @doc.xpath("project/url").text || ""
end

#versionObject



26
27
28
# File 'lib/gjp/pom.rb', line 26

def version
  @doc.xpath("project/version").text || ""
end