Sha256: 4fd6355e7a2ec64ec4842316c10771775dd9b9d7b3dae2af6075c5aa38ab80cc
Contents?: true
Size: 1.83 KB
Versions: 2
Compression:
Stored size: 1.83 KB
Contents
module Lhj class TraditionalCheckHelper def self.check(path, ignore_path, type = 'm,h,pch,xib') ignore_file = File.join(ignore_path, '.checkignore') ignore_list = [] ignore_list = File.readlines(ignore_file).map { |f| f.gsub(/\n/, '') } if File.exist?(ignore_file) check_ignore(path, type: type, ignore: ignore_list) end def self.check_ignore(path, type: 'm,h,pch,xib', ignore: []) result = {} all_files = Dir.glob("#{path}/**/*.{#{type}}").reject do |p| p =~ /Pods/ || ignore.include?(File.basename(p)) end all_files.each do |f| infos = handle_file(f) next unless infos.length.positive? result[File.basename(f)] = infos end notify(result) if result.keys.length.positive? end def self.show_result(result) result.each do |k, v| puts k v.each do |o| puts "第#{o[:idx]}行:" puts o[:cn] puts o[:hk] end end end def self.handle_file(file) result = [] File.open(file, 'r') do |f| f.readlines.each_with_index do |line, idx| next if line =~ %r{//} next unless line =~ /[\u4e00-\u9fa5]/ next unless Lhj::Trans::Helper.instance.contain_zh_hk(line) result << { idx: idx, cn: line.strip, hk: Lhj::Trans::Helper.instance.trans_zh_hk_str(line).strip } end end result end def self.robot_url 'https://oapi.dingtalk.com/robot/send?access_token=fe879fd3e7a3b5e59d5719b2384845b7884901919be5a78fe443cbf777869807' end def self.notify(result) temp = Lhj::ErbTemplateHelper.load('traditional_code_notify') temp_result = Lhj::ErbTemplateHelper.render(temp, { result: result }, '-') puts temp_result Lhj::Dingtalk.post_text_message_robot(robot_url, temp_result) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
lhj-tools-0.2.17 | lib/lhj/helper/traditional_check_helper.rb |
lhj-tools-0.2.16 | lib/lhj/helper/traditional_check_helper.rb |