lib/lite/ruby/kernel.rb in lite-ruby-1.0.14 vs lib/lite/ruby/kernel.rb in lite-ruby-1.0.15

- old
+ new

@@ -1,29 +1,31 @@ # frozen_string_literal: true -module Kernel +if Lite::Ruby.configuration.monkey_patches.include?('kernel') + module Kernel - # rubocop:disable Lint/RescueException, Security/Eval - def safe_eval - eval(self) - rescue Exception - self - end + # rubocop:disable Lint/RescueException, Security/Eval + def safe_eval + eval(self) + rescue Exception + self + end - def try_eval - val = /\[\d*,?\d*,?\d*\]/.match(to_s).to_s - return val if val.nil? + def try_eval + val = /\[\d*,?\d*,?\d*\]/.match(to_s).to_s + return val if val.nil? - eval(val) - end - # rubocop:enable Lint/RescueException, Security/Eval + eval(val) + end + # rubocop:enable Lint/RescueException, Security/Eval - private + private - def caller_name(depth = 0) - val = caller[depth][/`([^']*)'/, 1] - return val if depth.zero? || !val.include?('<top (required)>') + def caller_name(depth = 0) + val = caller[depth][/`([^']*)'/, 1] + return val if depth.zero? || !val.include?('<top (required)>') - caller[depth - 1][/`([^']*)'/, 1] - end + caller[depth - 1][/`([^']*)'/, 1] + end + end end