class WhatTheGem::Info

Constants

TEMPLATE

About info shortening: It is because minitest pastes their whole README there, including a quotations of how they are better than RSpec. (At the same time, RSpec's info reads “BDD for Ruby”.)

Public Instance Methods

locals() click to toggle source
# File lib/whatthegem/info.rb, line 28
def locals
  {
    info: gem.rubygems.info,
    age: age,
    prerelease: prerelease,
    specs: specs,
    current: specs.last,
    bundled: gem.bundled.to_h,
    commands: commands
  }
end

Private Instance Methods

age() click to toggle source
# File lib/whatthegem/info.rb, line 42
def age
  version = gem.rubygems.stable_versions.first or return
  version.dig(:created_at).then(&Time.method(:parse)).then(&I.method(:ago_text))
end
commands() click to toggle source
# File lib/whatthegem/info.rb, line 63
def commands
  Command.registry.values.-([self.class]).map(&:meta).map(&:to_h)
end
prerelease() click to toggle source
# File lib/whatthegem/info.rb, line 47
def prerelease
  gem.rubygems.versions.first
    &.then { |ver| ver if ver[:prerelease] }
    &.then { |ver| ver.merge(age: I.ago_text(Time.parse(ver[:created_at]))) }
end
specs() click to toggle source
# File lib/whatthegem/info.rb, line 53
def specs
  gem.specs.map { |spec|
    {
      name: spec.name,
      version: spec.version.to_s,
      dir: spec.gem_dir
    }
  }
end