class TT::I18nSync::FileGroup

Attributes

list[R]
mark[R]
st_locale[R]
standard[R]

Public Class Methods

new(st_locale, standard, list, mark) click to toggle source
# File lib/t_t/i18n_sync.rb, line 72
def initialize(st_locale, standard, list, mark)
  @st_locale = st_locale
  @standard = standard
  @list = list
  @mark = mark
end

Public Instance Methods

execute() click to toggle source
# File lib/t_t/i18n_sync.rb, line 79
def execute
  file_updated_at = File.mtime(standard)
  return if defined?(@prev_updated_at) && file_updated_at == @prev_updated_at

  st_source = Utils.load_file(standard, st_locale)
  list.each { |l, path| Utils.sync_file(path, l, st_source, mark) }

  @prev_updated_at = file_updated_at
end
missed() click to toggle source
# File lib/t_t/i18n_sync.rb, line 89
def missed
  flat_list = list.inject({}) { |r, (l, path)| r.merge!(l => Utils.flat_file(path, l)) }

  Utils.flat_file(standard, st_locale).inject([]) do |list, (k, st_v)|
    item = flat_list.inject({ st_locale => st_v }) { |r, (l, h)| r.merge!(l => h[k]) }

    if item.any? { |_, v| v.nil? || v.to_s.include?(mark) }
      item.each { |l, v| item[l] = nil if v.to_s.include?(mark) }
      list << item
    end

    list
  end
end