Sha256: 655ce82147d25134455bc475c6fc7f7018e8867da1da5d3224a616e7781c0a51

Contents?: true

Size: 690 Bytes

Versions: 2

Compression:

Stored size: 690 Bytes

Contents

module Librarian
  module Puppet
    class Requirement
      attr_reader :requirement

      def initialize(requirement)
        @requirement = requirement
      end

      def gem_requirement
        if range_requirement?
          [@range_match[1], @range_match[2]]
        elsif pessimistic_requirement?
          "~> #{@pessimistic_match[1]}"
        else
          requirement
        end
      end

      private

      def range_requirement?
        @range_match ||= requirement.match(/(>=? ?\d+(?:\.\d+){0,2}) (<=? ?\d+(?:\.\d+){0,2})/)
      end

      def pessimistic_requirement?
        @pessimistic_match ||= requirement.match(/(\d+(?:\.\d+)?)\.x/)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
librarian-puppet-0.9.10 lib/librarian/puppet/requirement.rb
librarian-puppet-0.9.9 lib/librarian/puppet/requirement.rb