Sha256: 1851876b9092e0bd4ac2fa40c58e76191e1386248ce0c854d7ffd7149fb7d812

Contents?: true

Size: 999 Bytes

Versions: 11

Compression:

Stored size: 999 Bytes

Contents

# frozen_string_literal: true

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

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 = {})
        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

      def spreadsheet_report
        @spreadsheet_report ||= I18n::Tasks::Reports::Spreadsheet.new(i18n)
      end

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
i18n-tasks-0.9.23 lib/i18n/tasks/command/commander.rb
i18n-tasks-0.9.22 lib/i18n/tasks/command/commander.rb
i18n-tasks-0.9.21 lib/i18n/tasks/command/commander.rb
i18n-tasks-0.9.20 lib/i18n/tasks/command/commander.rb
i18n-tasks-0.9.19 lib/i18n/tasks/command/commander.rb
i18n-tasks-0.9.18 lib/i18n/tasks/command/commander.rb
i18n-tasks-0.9.17 lib/i18n/tasks/command/commander.rb
i18n-tasks-0.9.16 lib/i18n/tasks/command/commander.rb
i18n-tasks-0.9.15 lib/i18n/tasks/command/commander.rb
i18n-tasks-0.9.14 lib/i18n/tasks/command/commander.rb
i18n-tasks-0.9.13 lib/i18n/tasks/command/commander.rb