Sha256: 45f13251d8d104be8bfbc3200e3158ebc19d4205f64265df56aae0ee6662e5bf

Contents?: true

Size: 911 Bytes

Versions: 8

Compression:

Stored size: 911 Bytes

Contents

module GitCompound
  module Repository
    # GitVersion represents tagged version inside Git repository
    #
    class GitVersion
      attr_reader :tag, :sha, :version

      def initialize(tag, sha)
        @tag = tag
        @sha = sha
        @version = tag.sub(/^v/, '')
      end

      def to_gem_version
        Gem::Version.new(@version)
      end

      def valid?
        @tag.match(/^v?#{Gem::Version::VERSION_PATTERN}$/)
      end

      def matches?(requirement)
        dependency = Gem::Dependency.new('component', requirement)
        dependency.match?('component', to_gem_version, true)
      end

      def <=>(other)
        to_gem_version <=> other.to_gem_version
      end

      def ==(other)
        case other
        when String
          version == other
        when GitVersion
          version == other.version
        else
          false
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
git_compound-0.2.2 lib/git_compound/repository/git_version.rb
git_compound-0.2.1 lib/git_compound/repository/git_version.rb
git_compound-0.2.0 lib/git_compound/repository/git_version.rb
git_compound-0.1.2 lib/git_compound/repository/git_version.rb
git_compound-0.1.1 lib/git_compound/repository/git_version.rb
git_compound-0.1.0 lib/git_compound/repository/git_version.rb
git_compound-0.0.10 lib/git_compound/repository/git_version.rb
git_compound-0.0.9 lib/git_compound/repository/git_version.rb