lib/rbbt/tsv/change_id.rb in rbbt-util-5.14.35 vs lib/rbbt/tsv/change_id.rb in rbbt-util-5.14.36
- old
+ new
@@ -87,11 +87,11 @@
end
def self.translation_index(files, target = nil, source = nil, options = {})
return nil if source == target
options = Misc.add_defaults options.dup, :persist => true
- fields = source ? [source] : nil
+ fields = (source and not source.empty?) ? [source] : nil
files.each do |file|
if TSV === file
all_fields = file.all_fields
target = file.fields.first if target.nil?
if (source.nil? or all_fields.include? source) and all_fields.include? target
@@ -115,10 +115,10 @@
other_all_fields = TSV === other_file ? other_file.all_fields : TSV.parse_header(other_file).all_fields
common_field = (all_fields & other_all_fields).first
- if common_field and (source.nil? or all_fields.include? source) and other_all_fields.include? target
+ if common_field and (source.nil? or source.empty? or all_fields.include? source) and other_all_fields.include? target
index = Persist.persist_tsv(nil, Misc.fingerprint(files), {:files => files, :source => source, :target => target}, :prefix => "Translation index", :persist => options[:persist]) do |data|
index = TSV === file ?
file.index(options.merge(:target => common_field, :fields => fields)) :