Sha256: bad3dfbce2b39b04141e8cc3d14465a46b8a2b5e92d03d4cd0805a61ea52539f

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

class 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

4 entries across 4 versions & 1 rubygems

Version Path
naether-0.10.1-java lib/naether/notation.rb
naether-0.10.1 lib/naether/notation.rb
naether-0.10.0-java lib/naether/notation.rb
naether-0.10.0 lib/naether/notation.rb