class WhatTheGem::Usage

TODO use Piotr's markdown formatter

friendly report of “usage instructions not found”

If gem not found locally – fetch from GitHub

Constants

README_NOT_FOUND
TEMPLATE

Public Instance Methods

locals() click to toggle source
# File lib/whatthegem/usage.rb, line 20
def locals
  {
    usage: readme.then(&Extractor).first(2).map(&:to_h)
  }
end

Private Instance Methods

github_readme() click to toggle source
# File lib/whatthegem/usage.rb, line 41
def github_readme
  gem.github&.readme
end
local_readme() click to toggle source
# File lib/whatthegem/usage.rb, line 37
def local_readme
  gem.specs.last&.gem_dir&.then(&Pathname.method(:new))&.glob('README{,.*}')&.first
end
output() click to toggle source
Calls superclass method WhatTheGem::Command#output
# File lib/whatthegem/usage.rb, line 28
def output
  return README_NOT_FOUND unless readme
  super
end
readme() click to toggle source
# File lib/whatthegem/usage.rb, line 33
        def readme
  local_readme || github_readme
end