Class: TT::I18nSync
- Inherits:
-
Object
- Object
- TT::I18nSync
- Defined in:
- lib/t_t/i18n_sync.rb
Defined Under Namespace
Modules: Utils Classes: FileGroup
Instance Attribute Summary collapse
-
#checker ⇒ Object
readonly
Returns the value of attribute checker.
-
#groups ⇒ Object
readonly
Returns the value of attribute groups.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(st_locale, files, mark) ⇒ I18nSync
constructor
A new instance of I18nSync.
- #missed ⇒ Object
Constructor Details
#initialize(st_locale, files, mark) ⇒ I18nSync
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/t_t/i18n_sync.rb', line 107 def initialize(st_locale, files, mark) @groups = [] files.inject({}) do |r, file| parts = file.split('.') k = parts[0...-2].join('.') l = File.basename(parts[-2]) r[k] ||= {} r[k][l] = file r end.each_value do |group| locales = group.keys next unless locales.include?(st_locale) && locales.size > 1 list = group.reject { |l, v| l == st_locale } groups << FileGroup.new(st_locale, group[st_locale], list, mark) end @checker = ActiveSupport::FileUpdateChecker.new(groups.map(&:standard)) { execute } end |
Instance Attribute Details
#checker ⇒ Object (readonly)
Returns the value of attribute checker.
105 106 107 |
# File 'lib/t_t/i18n_sync.rb', line 105 def checker @checker end |
#groups ⇒ Object (readonly)
Returns the value of attribute groups.
105 106 107 |
# File 'lib/t_t/i18n_sync.rb', line 105 def groups @groups end |
Instance Method Details
#execute ⇒ Object
127 128 129 |
# File 'lib/t_t/i18n_sync.rb', line 127 def execute groups.each(&:execute) end |
#missed ⇒ Object
131 132 133 134 135 136 137 138 139 140 |
# File 'lib/t_t/i18n_sync.rb', line 131 def missed groups.inject({}) do |r, group| unless (list = group.missed).empty? base_path = group.standard.split(group.st_locale)[0] key = "#{ base_path }(*).yml" r[key] = list end r end end |