class TYUtil::TYPuts
Constants
- ERROR_KEYS
Public Class Methods
filter(target, keys)
click to toggle source
# File lib/tuya/cli/odm/util/puts_util.rb, line 82 def self.filter(target, keys) # filter_color(target, keys, 'yellow', '[!tuya-cli suggested]') filter_content(target, keys, '「tuya-cli」 Maybe the reason for the error is :') end
filter_color(target, keys, color, pre)
click to toggle source
# File lib/tuya/cli/odm/util/puts_util.rb, line 18 def self.filter_color(target, keys, color, pre) target.each_line do |s| # p 111 # p s eval_command = "" keys.each do |key| temp = "" if eval_command.length > 0 temp = " || " end eval_command = "#{eval_command}#{temp}s.include?('#{key}')" end # p eval_command if eval_command.length > 0 && (eval eval_command) # p 11111 # p pre # p 222 out = "#{pre} #{s}" if out.include?("''") out.gsub!("'","") end # p "#{pre} #{s}" # p 33 # p out # puts "puts '#{out}'.#{color}" # eval "puts '#{out}'.#{color}" end end end
filter_content(target, keys, pre)
click to toggle source
# File lib/tuya/cli/odm/util/puts_util.rb, line 54 def self.filter_content(target, keys, pre) regular_temp = "" is_put_pre = false keys.each do |key| temp = "" if regular_temp.length > 0 temp = "|" end regular_temp = "#{regular_temp}#{temp}(.*)#{key}(.*)" end regular = "^(#{regular_temp})$" target.gsub(/#{regular}/) do |matched| if !is_put_pre is_put_pre = true puts pre.yellow puts "\n" end if matched.length < 2000 puts matched.magenta puts "\n" end end end