Sha256: 1442214194c4895429fb5749de6ac3ceaf77ed470c9910779449175b7b405e73

Contents?: true

Size: 886 Bytes

Versions: 3

Compression:

Stored size: 886 Bytes

Contents

# frozen_string_literal: true

module NeetoCompliance
  class GemVersionVerifier
    attr_reader :gem_name, :repo_name, :latest_version

    def initialize(gem_name, repo_name, latest_version)
      @gem_name = gem_name
      @repo_name = repo_name
      @latest_version = latest_version
    end

    def current_version
      bundler_specs.find { |s| s.name == gem_name }.extension_dir.split("-").last rescue nil
    end

    def bundler_specs
      Bundler.definition.specs
    end

    # def latest_version
    #   uri = "https://api.github.com/repos/#{repo_name}/commits/master"
    #   GithubAccess.latest_commit_sha(uri)
    # end

    def gem_installed?
      !current_version.nil?
    end

    def latest_version_installed?
      current_version.to_s[0..6] == latest_version.to_s[0..6]
    end

    def valid?
      gem_installed? && latest_version_installed?
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
neetob-0.1.2 neeto_compliance/lib/neeto_compliance/verifiers/gem_version_verifier.rb
neetob-0.1.1 /Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/gem_version_verifier.rb
neetob-0.1.0 /Users/chiragshah/Workspace/bigbinary/neeto/neetob/neeto_compliance/lib/neeto_compliance/verifiers/gem_version_verifier.rb