Class: I18n::Tasks::Command::Commander

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/i18n/tasks/command/commander.rb

Direct Known Subclasses

I18n::Tasks::Commands

Constant Summary

Constants included from Logging

Logging::MUTEX, Logging::PROGRAM_NAME

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

log_error, log_stderr, log_verbose, log_warn, program_name, warn_deprecated

Constructor Details

#initialize(i18n) ⇒ Commander

Returns a new instance of Commander.

Parameters:



14
15
16
# File 'lib/i18n/tasks/command/commander.rb', line 14

def initialize(i18n)
  @i18n = i18n
end

Instance Attribute Details

#i18nObject (readonly)

Returns the value of attribute i18n.



11
12
13
# File 'lib/i18n/tasks/command/commander.rb', line 11

def i18n
  @i18n
end

Instance Method Details

#run(name, opts = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/i18n/tasks/command/commander.rb', line 18

def run(name, opts = {})
  log_stderr "#{Rainbow('#StandWith').bg(:blue)}#{Rainbow('Ukraine').bg(:yellow)}"
  name = name.to_sym
  public_name = name.to_s.tr '_', '-'
  log_verbose "task: #{public_name}(#{opts.map { |k, v| "#{k}: #{v.inspect}" } * ', '})"
  if opts.empty? || method(name).arity.zero?
    send name
  else
    send name, **opts
  end
end