class I18n::Hygiene::RakeTask

Constants

CHECKS

Public Class Methods

new(task_name = :hygiene, &block) click to toggle source
# File lib/i18n/hygiene/rake_task.rb, line 22
def initialize(task_name = :hygiene, &block)
  config = Config.new

  if block
    block.call(config)

    # We always want to exclude the file that is configuring this rake task
    config.exclude_files = config.exclude_files + [relative_path_for(block.source_location)]
  end

  unless ::Rake.application.last_description
    desc %(Check i18n hygiene)
  end

  task(task_name => dependencies) do
    checks = configure_checks(config)

    checks.each do |check|
      check.run do |result|
        reporter.concat(result)
      end
    end

    reporter.report

    exit(1) unless reporter.passed?
  end
end

Private Instance Methods

configure_checks(config) click to toggle source
# File lib/i18n/hygiene/rake_task.rb, line 61
def configure_checks(config)
  CHECKS.map do |check|
    check.new(config)
  end
end
dependencies() click to toggle source
# File lib/i18n/hygiene/rake_task.rb, line 67
def dependencies
  [:environment] if defined?(Rails)
end
relative_path_for(source_location) click to toggle source
# File lib/i18n/hygiene/rake_task.rb, line 53
def relative_path_for(source_location)
  source_location[0].gsub("#{pwd}/", "")
end
reporter() click to toggle source
# File lib/i18n/hygiene/rake_task.rb, line 57
def reporter
  @reporter ||= Reporter.new
end