Sha256: 1e3bdb4a1ed26d10471d6389e46ae25391f8b61bcbc5d7350b8cba67a8a8a6fb

Contents?: true

Size: 1.29 KB

Versions: 2

Compression:

Stored size: 1.29 KB

Contents

require "uri"
require "net/http"
require "net/https"

module GemVersionCheck
  class Project

    def initialize(project, spec_names = [])
      @project = project
      @spec_names = spec_names
    end

    def name
      @project
    end

    def report
      @report ||= generate_report
    end

    def generate_report
      @check_failed = false
      result = []
      with_progress_bar(spec_names) do |spec_name|
        dependency = Dependency.new(spec_name)
        dependency.check(lock_file)
        result << dependency

        @check_failed = true unless dependency.valid?
      end
      result
    end

    def check_failed?
      @check_failed
    end

    def lock_file
      @lock_file ||= begin
        content = LockfileFetcher.new(@project).content
        Lockfile.new(content)
      end
    end

    private

    def with_progress_bar(elements)
      pb = ProgressBar.new("Fetch specs", lock_file.total) if display_status?
      elements.each do |el|
        yield el
        pb.inc if display_status?
      end
      pb.clear if display_status?
    end

    def display_status?
      GemVersionCheck.configuration.show_progress_bar
    end

    def spec_names
      @spec_names.any? ? @spec_names : all_spec_names
    end

    def all_spec_names
      lock_file.spec_names
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gem_version_check-0.0.10 lib/gem_version_check/project.rb
gem_version_check-0.0.9 lib/gem_version_check/project.rb