Skip to content

Commit

Permalink
better regex comparison
Browse files Browse the repository at this point in the history
fixes:

warning: deprecated Object#=~ is called on TrueClass
warning: deprecated Object#=~ is called on FalseClass

also:

rubocop wanted some spacing for guard clauses
and wanted to use match instead of =~ and I obliged
  • Loading branch information
kbrock committed Jan 28, 2022
1 parent af549f8 commit 35c268b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/patches/ruport_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Formatter::SafeCSV < Formatter::CSV
def build_table_body
data.each do |row|
row_data = row.map do |column_value|
column_value.insert(0, "'") if column_value =~ /^\s*[@=+-]/ && column_value =~ /[(!\/]/
column_value.insert(0, "'") if column_value.kind_of?(String) && column_value.match?(/^\s*[@=+-]/) && column_value.match?(/[(!\/]/)
column_value
end

Expand Down
16 changes: 11 additions & 5 deletions lib/tasks/evm_settings.rake
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,22 @@ module EvmSettings
private_class_method :keyval_to_hash

def self.str_to_value(value)
return true if value =~ /true/i
return false if value =~ /false/i
return nil if value =~ /nil/
return value unless value.kind_of?(String)

dvalue = value.downcasex
return true if dvalue.include?("true")
return false if dvalue.include?("false")
return nil if value.include?("nil")

value
end
private_class_method :str_to_value

def self.value_to_str(value)
return "true" if value == true || value =~ /true/i
return "false" if value == false || value =~ /false/i
dvalue = value.downcase if value.kind_of?(String)
return "true" if value == true || dvalue&.include?("true")
return "false" if value == false || dvalue&.include?("false")

value
end
private_class_method :value_to_str
Expand Down

0 comments on commit 35c268b

Please sign in to comment.