Sha256: eed0527b677a500872af27be0976008276f0c87cd03866a4bbe96e649071cb99

Contents?: true

Size: 933 Bytes

Versions: 15

Compression:

Stored size: 933 Bytes

Contents

# frozen_string_literal: true

require 'i18n/tasks/cli'
require 'i18n/tasks/reports/terminal'

module I18n::Tasks
  module Command
    class Commander
      include ::I18n::Tasks::Logging

      attr_reader :i18n

      # @param [I18n::Tasks::BaseTask] i18n
      def initialize(i18n)
        @i18n = i18n
      end

      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

      protected

      def terminal_report
        @terminal_report ||= I18n::Tasks::Reports::Terminal.new(i18n)
      end

      delegate :base_locale, :locales, :t, to: :i18n
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/i18n-tasks-1.0.14/lib/i18n/tasks/command/commander.rb
i18n-tasks-1.0.13 lib/i18n/tasks/command/commander.rb
i18n-tasks-1.0.12 lib/i18n/tasks/command/commander.rb
i18n-tasks-1.0.11 lib/i18n/tasks/command/commander.rb
i18n-tasks-1.0.10 lib/i18n/tasks/command/commander.rb
i18n-tasks-1.0.9 lib/i18n/tasks/command/commander.rb
i18n-tasks-1.0.8 lib/i18n/tasks/command/commander.rb
i18n-tasks-1.0.7 lib/i18n/tasks/command/commander.rb
i18n-tasks-1.0.6 lib/i18n/tasks/command/commander.rb
i18n-tasks-1.0.5 lib/i18n/tasks/command/commander.rb
i18n-tasks-1.0.4 lib/i18n/tasks/command/commander.rb
i18n-tasks-1.0.3 lib/i18n/tasks/command/commander.rb
i18n-tasks-1.0.2 lib/i18n/tasks/command/commander.rb
i18n-tasks-1.0.1 lib/i18n/tasks/command/commander.rb
i18n-tasks-1.0.0 lib/i18n/tasks/command/commander.rb