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.
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
# File 'lib/lokale/agent.rb', line 285 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.
272 273 274 |
# File 'lib/lokale/agent.rb', line 272 def lang @lang end |
#missing_strings ⇒ Object (readonly)
Returns the value of attribute missing_strings.
272 273 274 |
# File 'lib/lokale/agent.rb', line 272 def missing_strings @missing_strings end |
Class Method Details
.find(files, main_lang) ⇒ Object
274 275 276 277 278 279 280 281 282 283 |
# File 'lib/lokale/agent.rb', line 274 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
303 304 305 |
# File 'lib/lokale/agent.rb', line 303 def empty? @missing_strings.empty? || @missing_strings.all? { |file_name, strings| strings.empty? } end |