Class: YamlNormalizer::RakeTask

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/yaml_normalizer/rake_task.rb

Overview

Provides Rake task integration

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = 'yaml') {|_self| ... } ⇒ RakeTask

Add YAML Normalizer rake tasks to your project by adding the following line to your Rakefile:

YamlNormalizer::RakeTask.new

This gives you the following tasks (run rake -T)

rake yaml:check      # Check if configured YAML files are normalized
rake yaml:normalize  # Normalize configured YAML files

Examples:

Configure YAML Normalizer’s rake task

YamlNormalizer::RakeTask.new do |config|
  config.files = Dir[File.join(File.dirname(__FILE__), 'include.yml')]
end

Parameters:

  • name (String) (defaults to: 'yaml')

    name of the rake task

  • &block (Proc)

    optional, evaluated inside the task definition

Yields:

  • (_self)

Yield Parameters:



37
38
39
40
41
42
43
44
45
46
# File 'lib/yaml_normalizer/rake_task.rb', line 37

def initialize(name = 'yaml', &block)
  super()
  yield(self) if block

  desc 'Check if configured YAML files are normalized'
  task("#{name}:check") { abort(check_failed(name)) unless check }

  desc 'Normalize configured YAML files'
  task("#{name}:normalize") { normalize }
end

Instance Attribute Details

#filesArray<String>

The YAML files to process.

Examples:

YamlNormalizer::RakeTask.new do |task|
  task.files = ['config/locale/*.yml', 'config/*.yml']
end

Returns:

  • (Array<String>)

    a list of file globing Strings



21
22
23
# File 'lib/yaml_normalizer/rake_task.rb', line 21

def files
  @files
end

#nameString

The name of the rake task

Returns:

  • (String)

    name of the rake task



13
14
15
# File 'lib/yaml_normalizer/rake_task.rb', line 13

def name
  @name
end