lib/irb/command/measure.rb in irb-1.12.0 vs lib/irb/command/measure.rb in irb-1.13.0
- old
+ new
@@ -1,25 +1,31 @@
module IRB
# :stopdoc:
module Command
class Measure < Base
+ include RubyArgsExtractor
+
category "Misc"
description "`measure` enables the mode to measure processing time. `measure :off` disables it."
def initialize(*args)
super(*args)
end
- def execute(type = nil, arg = nil)
- # Please check IRB.init_config in lib/irb/init.rb that sets
- # IRB.conf[:MEASURE_PROC] to register default "measure" methods,
- # "measure :time" (abbreviated as "measure") and "measure :stackprof".
-
- if block_given?
+ def execute(arg)
+ if arg&.match?(/^do$|^do[^\w]|^\{/)
warn 'Configure IRB.conf[:MEASURE_PROC] to add custom measure methods.'
return
end
+ args, kwargs = ruby_args(arg)
+ execute_internal(*args, **kwargs)
+ end
+
+ def execute_internal(type = nil, arg = nil)
+ # Please check IRB.init_config in lib/irb/init.rb that sets
+ # IRB.conf[:MEASURE_PROC] to register default "measure" methods,
+ # "measure :time" (abbreviated as "measure") and "measure :stackprof".
case type
when :off
IRB.unset_measure_callback(arg)
when :list