Sha256: 6f4d1d554ea24a702b74c95a54f55feeec81ebacd551fab26c2ac1213bd4d89d

Contents?: true

Size: 1.25 KB

Versions: 4

Compression:

Stored size: 1.25 KB

Contents

# encoding: UTF-8

module Tetra
  # encapsulates a pom.xml file
  class Pom
    def initialize(filename)
      content = open(filename).read if filename && File.file?(filename)
      @doc = Nokogiri::XML(content)
      @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

4 entries across 4 versions & 1 rubygems

Version Path
tetra-0.53.0 lib/tetra/pom.rb
tetra-0.52.0 lib/tetra/pom.rb
tetra-0.51.0 lib/tetra/pom.rb
tetra-0.50.0 lib/tetra/pom.rb