Class: ProspectusGems::Gemspec

Inherits:
Module
  • Object
show all
Defined in:
lib/prospectus_gems.rb

Overview

Helper for automatically adding dependency status check

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gemfile = nil, lockfile = nil) ⇒ Gemspec

Returns a new instance of Gemspec.



10
11
12
13
# File 'lib/prospectus_gems.rb', line 10

def initialize(gemfile = nil, lockfile = nil)
  @gemfile = gemfile
  @lockfile = lockfile
end

Class Method Details

.fetch_gem(name) ⇒ Object



78
79
80
81
82
83
# File 'lib/prospectus_gems.rb', line 78

def fetch_gem(name)
  # rubocop:disable Security/Open
  body = open("#{versions_base_uri}/#{name}/latest.json").read
  # rubocop:enable Security/Open
  JSON.parse(body)['version']
end

.lookup_gem(name) ⇒ Object



74
75
76
# File 'lib/prospectus_gems.rb', line 74

def lookup_gem(name)
  @gem_version_cache[name] ||= fetch_gem(name)
end

.versions_base_uriObject



85
86
87
# File 'lib/prospectus_gems.rb', line 85

def versions_base_uri
  @versions_base_uri ||= 'https://rubygems.org/api/v1/versions'
end

Instance Method Details

#extended(other) ⇒ Object

rubocop:disable Metrics/MethodLength



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/prospectus_gems.rb', line 15

def extended(other) # rubocop:disable Metrics/MethodLength
  gem_deps = parse_deps
  other.deps do
    gem_deps.each do |dep_name, current, latest|
      item do
        name 'gems::' + dep_name

        expected do
          static
          set latest
        end

        actual do
          static
          set current
        end
      end
    end
  end
end