Class: TT::I18nSync::FileGroup
- Inherits:
-
Object
- Object
- TT::I18nSync::FileGroup
- Defined in:
- lib/t_t/i18n_sync.rb
Instance Attribute Summary collapse
-
#list ⇒ Object
readonly
Returns the value of attribute list.
-
#mark ⇒ Object
readonly
Returns the value of attribute mark.
-
#st_locale ⇒ Object
readonly
Returns the value of attribute st_locale.
-
#standard ⇒ Object
readonly
Returns the value of attribute standard.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(st_locale, standard, list, mark) ⇒ FileGroup
constructor
A new instance of FileGroup.
- #missed ⇒ Object
Constructor Details
#initialize(st_locale, standard, list, mark) ⇒ FileGroup
Returns a new instance of FileGroup.
72 73 74 75 76 77 |
# 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 |
Instance Attribute Details
#list ⇒ Object (readonly)
Returns the value of attribute list.
70 71 72 |
# File 'lib/t_t/i18n_sync.rb', line 70 def list @list end |
#mark ⇒ Object (readonly)
Returns the value of attribute mark.
70 71 72 |
# File 'lib/t_t/i18n_sync.rb', line 70 def mark @mark end |
#st_locale ⇒ Object (readonly)
Returns the value of attribute st_locale.
70 71 72 |
# File 'lib/t_t/i18n_sync.rb', line 70 def st_locale @st_locale end |
#standard ⇒ Object (readonly)
Returns the value of attribute standard.
70 71 72 |
# File 'lib/t_t/i18n_sync.rb', line 70 def standard @standard end |
Instance Method Details
#execute ⇒ Object
79 80 81 82 83 84 85 86 87 |
# 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 ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# 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 |