class WhatTheGem::Gem
Constants
- GITHUB_URI_PATTERN
- NoGem
Attributes
name[R]
Public Class Methods
fetch(name)
click to toggle source
# File lib/whatthegem/gem.rb, line 15 def self.fetch(name) new(name).tap { |gem| gem.rubygems.info } # This will fail with Gems::NotFound if it is nonexisting rescue Gems::NotFound NoGem.new(name) end
new(name)
click to toggle source
# File lib/whatthegem/gem.rb, line 23 def initialize(name) @name = name end
Public Instance Methods
bundled()
click to toggle source
# File lib/whatthegem/gem.rb, line 45 def bundled Bundled.fetch(name) end
exists?()
click to toggle source
# File lib/whatthegem/gem.rb, line 27 def exists? true end
github()
click to toggle source
# File lib/whatthegem/gem.rb, line 35 def github rubygems.info.to_h.values_at(:source_code_uri, :homepage_uri) .then(&method(:detect_repo_id)) &.then(&GitHub.method(:new)) end
rubygems()
click to toggle source
# File lib/whatthegem/gem.rb, line 31 def rubygems RubyGems.new(name) end
specs()
click to toggle source
# File lib/whatthegem/gem.rb, line 41 def specs ::Gem::Specification.select { |s| s.name == name }.sort_by(&:version) end
Private Instance Methods
detect_repo_id(urls)
click to toggle source
FIXME: active_record's actual path is github.com/rails/rails/tree/v5.2.1/activerecord
# File lib/whatthegem/gem.rb, line 52 def detect_repo_id(urls) # Octokit can't correctly guess repo slug from https://github.com/bitaxis/annotate_models.git urls.grep(GITHUB_URI_PATTERN).first &.sub(/\.git$/, '') &.then(&Octokit::Repository.method(:from_url)) &.slug end