Sha256: 32c6bd77e39520b562079cf982f5d177894b65778af7d1eacf1d10d110011b75

Contents?: true

Size: 1.17 KB

Versions: 31

Compression:

Stored size: 1.17 KB

Contents

module Naether
  
  #
  # Helper for handling Maven notations, supports notations:
  #  * artifactId:groupId:version
  #  * artifactId:groupId:type:version 
  #  * artifactId:groupId:type:classifier:version 
  #
  class Notation
    attr_reader :group, :artifact, :version, :classifier, :type
    
    PATTERN = Regexp.compile( '^(.+?):(.+?):(.+?)(:(.+?)(:(.+))?)?$' )
    
    def initialize(notation)
      if notation =~ PATTERN
        @group = Regexp.last_match(1) 
        @artifact = Regexp.last_match(2)
        
        # artifactId:groupId:type:classifier:version 
        if Regexp.last_match(7)
          @type = Regexp.last_match(3)
          @classifier = Regexp.last_match(5)
          @version = Regexp.last_match(7)
          
        # artifactId:groupId:type:version 
        elsif Regexp.last_match(5)
          @type = Regexp.last_match(3)
          @version = Regexp.last_match(5)
        # artifactId:groupId:version -
        else
          @type = 'jar'
          @version = Regexp.last_match(3)
        end
          
      end
      
      def to_notation
        "#{group}:#{artifact}:#{type}#{":#{classifier}" if classifier}:#{version}"
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
naether-0.14.1-java lib/naether/notation.rb
naether-0.14.1 lib/naether/notation.rb
naether-0.14.0-java lib/naether/notation.rb
naether-0.14.0 lib/naether/notation.rb
naether-0.13.8 lib/naether/notation.rb
naether-0.13.8-java lib/naether/notation.rb
naether-0.13.7 lib/naether/notation.rb
naether-0.13.7-java lib/naether/notation.rb
naether-0.13.6-java lib/naether/notation.rb
naether-0.13.6 lib/naether/notation.rb
naether-0.13.5-java lib/naether/notation.rb
naether-0.13.5 lib/naether/notation.rb
naether-0.13.4 lib/naether/notation.rb
naether-0.13.4-java lib/naether/notation.rb
naether-0.13.3-java lib/naether/notation.rb
naether-0.13.3 lib/naether/notation.rb
naether-0.13.2-java lib/naether/notation.rb
naether-0.13.1 lib/naether/notation.rb
naether-0.13.1-java lib/naether/notation.rb
naether-0.13.0-java lib/naether/notation.rb