Sha256: 5c26754274d69848bee57db4d9281d7464a7eb126f586338d85b34d90503d1a6

Contents?: true

Size: 793 Bytes

Versions: 2

Compression:

Stored size: 793 Bytes

Contents

require 'nokogiri'

module Maestro
  module Plugin
    module RakeTasks
      class Pom

        def initialize(pom_path = "pom.xml")
          pom = File.open(pom_path)
          @doc = Nokogiri::XML(pom.read)
          pom.close
        end

        def [](id)
          xpath(@doc, id)
        end

        def artifact_id
          @artifact_id ||= self[:artifactId]
        end

        def version
          @version ||= self[:version]
        end

        def description
          @description ||= self[:description]
        end

        def url
          @url ||= self[:url]
        end

        private

        def xpath(doc, attribute)
          item = doc.at_xpath("/xmlns:project/xmlns:#{attribute}")
          item.nil? ? nil : item.text
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
maestro-plugin-rake-tasks-1.0.11 lib/maestro/plugin/rake_tasks/pom.rb
maestro-plugin-rake-tasks-1.0.10 lib/maestro/plugin/rake_tasks/pom.rb