class ProspectusGems::Gemspec
Helper for automatically adding dependency status check
Public Class Methods
new(gemfile = nil, lockfile = nil)
click to toggle source
# File lib/prospectus_gems.rb, line 10 def initialize(gemfile = nil, lockfile = nil) @gemfile = gemfile @lockfile = lockfile end
Private Class Methods
fetch_gem(name)
click to toggle source
# 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)
click to toggle source
# File lib/prospectus_gems.rb, line 74 def lookup_gem(name) @gem_version_cache[name] ||= fetch_gem(name) end
versions_base_uri()
click to toggle source
# File lib/prospectus_gems.rb, line 85 def versions_base_uri @versions_base_uri ||= 'https://rubygems.org/api/v1/versions' end
Public Instance Methods
extended(other)
click to toggle source
# 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
Private Instance Methods
bundle()
click to toggle source
# File lib/prospectus_gems.rb, line 58 def bundle return @bundle if @bundle @bundle = Bundler::Definition.build(gemfile, lockfile, nil) @bundle.resolve_remotely! @bundle end
dep_obj()
click to toggle source
# File lib/prospectus_gems.rb, line 50 def dep_obj @dep_obj ||= if gemfile.read =~ /^gemspec$/ bundle.specs[bundle.dependencies.first.name].first else bundle end end
dependencies()
click to toggle source
# File lib/prospectus_gems.rb, line 46 def dependencies @dependencies ||= dep_obj.dependencies end
gemfile()
click to toggle source
# File lib/prospectus_gems.rb, line 65 def gemfile @gemfile ||= Bundler::SharedHelpers.default_gemfile end
lockfile()
click to toggle source
# File lib/prospectus_gems.rb, line 69 def lockfile @lockfile ||= Bundler::SharedHelpers.default_lockfile end
parse_deps()
click to toggle source
# File lib/prospectus_gems.rb, line 38 def parse_deps dependencies.map do |x| latest = Gemspec.lookup_gem(x.name) current = x.match?(x.name, latest) ? latest : x.requirements_list [x.name, current, latest] end end