class FindStrKey::GenReport
Constants
- DEFAULT_TXT
- DEFAULT_XLSX
Attributes
main_result[RW]
path[RW]
proj_path[RW]
second_result[RW]
Public Class Methods
new(proj_path, path, main_result, second_result)
click to toggle source
# File lib/applocale/Core/FindStrKey/find_str_key_result.rb, line 14 def initialize(proj_path, path, main_result, second_result) self.proj_path = proj_path self.path = path self.main_result = main_result self.second_result = second_result end
Public Instance Methods
gen_txt()
click to toggle source
# File lib/applocale/Core/FindStrKey/find_str_key_result.rb, line 49 def gen_txt txt_path = File.join(self.path, DEFAULT_TXT) File.delete(txt_path) if File.exist? txt_path self.write_to_txt(txt_path) end
gen_xlsx()
click to toggle source
# File lib/applocale/Core/FindStrKey/find_str_key_result.rb, line 21 def gen_xlsx xlsx_path = File.join(self.path, DEFAULT_XLSX) File.delete(xlsx_path) if File.exist? xlsx_path self.write_to_xlsx(xlsx_path) end
write_to_txt(txt_path)
click to toggle source
# File lib/applocale/Core/FindStrKey/find_str_key_result.rb, line 55 def write_to_txt(txt_path) puts "Start write to file: \"#{txt_path}\" ...".green target = open(txt_path, 'w') self.main_result.each do |arrs| key = arrs.first.value target.puts("#{key} : ") arrs.each do |obj| rpath = Pathname.new(obj.file).relative_path_from(Pathname.new(self.proj_path)).to_s target.puts(" line-#{obj.line}:\t#{rpath}") end target.puts('') end target.close end
write_to_xlsx(xlsx_path)
click to toggle source
# File lib/applocale/Core/FindStrKey/find_str_key_result.rb, line 27 def write_to_xlsx(xlsx_path) puts "Start write to file: \"#{xlsx_path}\" ...".green workbook = RubyXL::Workbook.new worksheet = workbook.worksheets[0] rowno = 0 keycolno = 0 self.main_result.each do |arrs| key = arrs.first.value worksheet.add_cell(rowno, keycolno, key) rowno += 1 end worksheet.add_cell(rowno, 0, '') worksheet.change_row_fill(rowno, 'fffacd') rowno += 1 self.second_result.each do |arrs| key = arrs.first.value worksheet.add_cell(rowno, keycolno, key) rowno += 1 end workbook.write(xlsx_path) end