Sha256: 561c08a09465102058a2f38db26ba548bffc22d7bb1afe7abd2b6a104cd8c5e1

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

# encoding: UTF-8

module Gjp
  # encapsulates a pom.xml file
  class Pom
    def initialize(filename)
      @doc = Nokogiri::XML(open(filename).read)
      @doc.remove_namespaces!
    end

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

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

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

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

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

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

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

    def runtime_dependency_ids
      @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

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

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gjp-0.39.0 lib/gjp/pom.rb