class Bashly::Script::Dependency

Attributes

commands[R]
help[R]
label[R]

Public Class Methods

from_config(key, value) click to toggle source
# File lib/bashly/script/dependency.rb, line 11
def from_config(key, value)
  options = case value
  when nil
    { label: key, commands: key }
  when String
    { label: key, commands: key, help: value }
  when Hash
    { label: key, commands: value['command'], help: value['help'] }
  else
    {}
  end

  new(**options)
end
new(label: nil, commands: nil, help: nil) click to toggle source
# File lib/bashly/script/dependency.rb, line 27
def initialize(label: nil, commands: nil, help: nil)
  @label = label
  @commands = commands.is_a?(String) ? [commands] : commands
  @help = help&.empty? ? nil : help
end
option_keys() click to toggle source
# File lib/bashly/script/dependency.rb, line 7
def option_keys
  @option_keys ||= %i[command help]
end

Public Instance Methods

multi?() click to toggle source
# File lib/bashly/script/dependency.rb, line 33
def multi?
  @multi ||= commands.size > 1
end
name() click to toggle source
# File lib/bashly/script/dependency.rb, line 37
def name
  @name ||= multi? ? "#{label} (#{commands.join '/'})" : label
end