Class: Lokale::Exporter::Diff
- Inherits:
-
Object
- Object
- Lokale::Exporter::Diff
- Defined in:
- lib/lokale/agent.rb
Instance Attribute Summary collapse
-
#lang ⇒ Object
readonly
Returns the value of attribute lang.
-
#missing_strings ⇒ Object
readonly
Returns the value of attribute missing_strings.
Class Method Summary collapse
Instance Method Summary collapse
- #empty? ⇒ Boolean
-
#initialize(main_files, lfiles, lang) ⇒ Diff
constructor
A new instance of Diff.
Constructor Details
#initialize(main_files, lfiles, lang) ⇒ Diff
Returns a new instance of Diff.
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/lokale/agent.rb', line 196 def initialize(main_files, lfiles, lang) @lang = lang @missing_strings = Hash.new { |h, k| h[k] = [] } lfiles.each do |lf| next unless lf.strings_file? counterpart = main_files.select { |m| m.full_name == lf.full_name }.sample next if counterpart.nil? missing_keys = counterpart.keys - lf.keys next if missing_keys.empty? counterpart.parsed.each do |lstr| next unless missing_keys.include? lstr.key @missing_strings[lf.full_name] << lstr.for_export(lang) end end end |
Instance Attribute Details
#lang ⇒ Object (readonly)
Returns the value of attribute lang.
183 184 185 |
# File 'lib/lokale/agent.rb', line 183 def lang @lang end |
#missing_strings ⇒ Object (readonly)
Returns the value of attribute missing_strings.
183 184 185 |
# File 'lib/lokale/agent.rb', line 183 def missing_strings @missing_strings end |
Class Method Details
.find(files, main_lang) ⇒ Object
185 186 187 188 189 190 191 192 193 194 |
# File 'lib/lokale/agent.rb', line 185 def self.find(files, main_lang) groups = files.group_by { |lf| lf.lang } main_files = groups[main_lang] diffs = [] groups.each do |lang, files| next if lang == main_lang diffs << Diff.new(main_files, files, lang) end diffs.delete_if { |d| d.empty? } end |
Instance Method Details
#empty? ⇒ Boolean
214 215 216 |
# File 'lib/lokale/agent.rb', line 214 def empty? @missing_strings.empty? || @missing_strings.all? { |file_name, strings| strings.empty? } end |