class Mysh::GlsCommand
The mysh gls (gem ls) command.
Public Class Methods
new(*args)
click to toggle source
Set up this command.
Calls superclass method
Mysh::Action::new
# File lib/mysh/internal/gls.rb, line 10 def initialize(*args) super @report = @mask = @specs = nil end
Public Instance Methods
process_command(input)
click to toggle source
Execute the gls command.
# File lib/mysh/internal/gls.rb, line 16 def process_command(input) process_args(input.args) gather_gems send(@report) end
Private Instance Methods
gather_gems()
click to toggle source
Determine which of the loaded gem specs are of interest.
# File lib/mysh/internal/gls.rb, line 39 def gather_gems @specs = Gem.loaded_specs .values .select {|spec| spec.name[@mask]} .sort {|first, second| first.name <=> second.name} end
info(spec)
click to toggle source
Get detailed information on a gem specification. Endemic Code Smells :reek:UtilityFunction
# File lib/mysh/internal/gls.rb, line 62 def info(spec) [["name", spec.name], ["version", spec.version], ["date", spec.date], ["summary", spec.summary], ["description", spec.description], ["executables", spec.executables], ["authors", spec.authors], ["email", spec.email], ["homepage", spec.homepage], ["", ""]] end
long_report()
click to toggle source
The long-winded gem list report.
# File lib/mysh/internal/gls.rb, line 52 def long_report report = @specs.inject([]) do |buffer, spec| buffer.concat(info(spec)) end report.puts_format_output_bullets end
process_args(args)
click to toggle source
Process the gls command's arguments.
# File lib/mysh/internal/gls.rb, line 25 def process_args (args) @report, @mask = :short_report, /./ args.each do |arg| if arg == '-l' @report = :long_report else @mask = arg end end end
short_report()
click to toggle source
The brief gem list report.
# File lib/mysh/internal/gls.rb, line 47 def short_report puts @specs.map {|spec| spec.name}.format_output_columns, "" end