Class: Crystalball::Rails::MapGenerator::I18nStrategy

Inherits:
Object
  • Object
show all
Includes:
MapGenerator::BaseStrategy, MapGenerator::Helpers::PathFilter
Defined in:
lib/crystalball/rails/map_generator/i18n_strategy.rb,
lib/crystalball/rails/map_generator/i18n_strategy/simple_patch.rb

Overview

Map generator strategy to build map of locale files used by an example.

Defined Under Namespace

Modules: SimplePatch

Instance Attribute Summary

Attributes included from MapGenerator::Helpers::PathFilter

#root_path

Class Method Summary collapse

Instance Method Summary collapse

Methods included from MapGenerator::Helpers::PathFilter

#filter, #initialize

Methods included from MapGenerator::BaseStrategy

#after_start

Class Method Details

.locale_filesArray<String>

List of locale files affected by current example

Returns:

  • (Array<String>)


19
20
21
# File 'lib/crystalball/rails/map_generator/i18n_strategy.rb', line 19

def locale_files
  @locale_files ||= []
end

.reset_locale_filesObject

Reset cached list of locale files



24
25
26
# File 'lib/crystalball/rails/map_generator/i18n_strategy.rb', line 24

def reset_locale_files
  @locale_files = []
end

Instance Method Details

#after_registerObject



29
30
31
# File 'lib/crystalball/rails/map_generator/i18n_strategy.rb', line 29

def after_register
  SimplePatch.apply!
end

#before_finalizeObject



33
34
35
# File 'lib/crystalball/rails/map_generator/i18n_strategy.rb', line 33

def before_finalize
  SimplePatch.revert!
end

#call(example_group_map, _) {|example_group_map| ... } ⇒ Object

Adds to the example group map the locale files used by the example

Parameters:

Yields:

  • (example_group_map)


39
40
41
42
43
# File 'lib/crystalball/rails/map_generator/i18n_strategy.rb', line 39

def call(example_group_map, _)
  self.class.reset_locale_files
  yield example_group_map
  example_group_map.push(*filter(self.class.locale_files.compact))
end