Sha256: 4c2a5c2db65aa9b29f1032689e03949e3295f0946927306b6ee2b7f7b4cce57f

Contents?: true

Size: 958 Bytes

Versions: 7

Compression:

Stored size: 958 Bytes

Contents

  # encoding: UTF-8

require "nokogiri"
require "open-uri"

module Gjp
  # encapsulates a pom.xml file
  class Pom
    def initialize(filename)
      @doc = Nokogiri::XML(open(filename).read)
      @doc.remove_namespaces!
    end
    
    def connection_address
      connection_nodes = @doc.xpath("//scm/connection/text()")    
      if connection_nodes.any?
        connection_nodes.first.to_s.sub(/^scm:/, "")
      end
    end
    
    def group_id
      @doc.xpath("project/groupId/text()").to_s
    end
    
    def artifact_id
      @doc.xpath("project/artifactId/text()").to_s
    end
    
    def version
      @doc.xpath("project/version/text()").to_s
    end

    def parent_group_id
      @doc.xpath("project/parent/groupId/text()").to_s
    end
    
    def parent_artifact_id
      @doc.xpath("project/parent/artifactId/text()").to_s
    end
    
    def parent_version
      @doc.xpath("project/parent/version/text()").to_s
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
gjp-0.14.1 lib/gjp/pom.rb
gjp-0.13.1 lib/gjp/pom.rb
gjp-0.11.2 lib/gjp/pom.rb
gjp-0.11.1 lib/gjp/pom.rb
gjp-0.10.0 lib/gjp/pom.rb
gjp-0.9.0 lib/gjp/pom.rb
gjp-0.8.0 lib/gjp/pom.rb