Class: WhatTheGem::Command

Inherits:
Object show all
Defined in:
lib/whatthegem/commands.rb

Direct Known Subclasses

Changes, Help, Info, Stats, Usage

Defined Under Namespace

Classes: Meta

Constant Summary collapse

HEADER_TEMPLATE =

FIXME: It was > **info.info | paragraphs:1 }** but it looks weird due to tty-markdown bug: github.com/piotrmurach/tty-markdown/issues/11

Template.parse(<<~HEADER)
  # {{info.name}}
  > {{info.info | paragraphs:1 | reflow }}
  > ({{uris | join:", "}})

  ## {{title}}


HEADER

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gem) ⇒ Command

Returns a new instance of Command.



51
52
53
# File 'lib/whatthegem/commands.rb', line 51

def initialize(gem)
  @gem = gem
end

Class Attribute Details

.metaObject (readonly)

Returns the value of attribute meta.



13
14
15
# File 'lib/whatthegem/commands.rb', line 13

def meta
  @meta
end

Instance Attribute Details

#gemObject (readonly)

Returns the value of attribute gem.



49
50
51
# File 'lib/whatthegem/commands.rb', line 49

def gem
  @gem
end

Class Method Details

.call(*args) ⇒ Object



28
29
30
# File 'lib/whatthegem/commands.rb', line 28

def call(*args)
  new(*args).call
end

.get(handle) ⇒ Object



24
25
26
# File 'lib/whatthegem/commands.rb', line 24

def get(handle)
  Command.registry[handle]
end

.register(title: name.split('::').last, handle: title.downcase, description:) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/whatthegem/commands.rb', line 15

def register(title: name.split('::').last, handle: title.downcase, description:)
  Command.registry[handle] = self
  @meta = Meta.new(
    handle: handle,
    title: title,
    description: description
  )
end

Instance Method Details

#callObject



59
60
61
# File 'lib/whatthegem/commands.rb', line 59

def call
  puts full_output
end

#metaObject



55
56
57
# File 'lib/whatthegem/commands.rb', line 55

def meta
  self.class.meta
end