52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
# File 'lib/apstrings/strings_validator.rb', line 52
def self.validate(file,masterFile)
@result = ValidateResult.new(file,masterFile);
@file = file
@master = nil
puts "-----------------------------------------\n\n"
puts "-----------------------------------------"
puts "apstrings: start validate strings file : #{@file} ..."
if nil == masterFile
Log::warn("No master file provided, validating file format only ...")
else
@master = Validator::paredFile(masterFile)
end
valid_master, valid_file , no_missing_key = true,true,true
begin
@string_file = Validator::paredFile(file);
rescue Exception => e
Log::error(e)
@result.valid_file_format = false
@result.file_format_errors << e
return false,@result.to_hash
end
valid_file = Validator::validate_format(@string_file)
if masterFile != nil
valid_master = Validator::validate_format(@master)
no_missing_key = Validator::validate_missing(@string_file,@master)
end
if valid_master && valid_file && no_missing_key
return true,@result.to_hash
else if valid_master && valid_file && !no_missing_key
return true,@result.to_hash
else
return false,@result.to_hash
end
end
end
|