lib/rib/api.rb in rib-1.1.3 vs lib/rib/api.rb in rib-1.1.4
- old
+ new
@@ -39,14 +39,14 @@
input, result, err = get_input, nil, nil
throw(:rib_exit, input) if config[:exit].include?(input)
result, err = eval_input(input)
if err
print_eval_error(err)
- elsif input.strip != ''
+ elsif input.strip != '' && !equal_rib_skip(result)
print_result(result)
else
- # print nothing for blank input
+ # print nothing for blank input or Rib::Skip
end
[result, err]
rescue Interrupt
handle_interrupt
end
@@ -77,11 +77,11 @@
eval_binding.eval(input, "(#{name})", line)
end
# Print result using #format_result
def print_result result
- puts(format_result(result)) if result != Rib::Skip
+ puts(format_result(result))
rescue StandardError, SyntaxError => e
Rib.warn("Error while printing result:\n #{format_error(e)}")
end
# Print evaluated error using #format_error
@@ -97,7 +97,14 @@
end
# Format error raised in #loop_eval
def format_error err
"#{err.class}: #{err.message}\n #{err.backtrace.join("\n ")}"
+ end
+
+ private
+ def equal_rib_skip result
+ result == Rib::Skip
+ rescue Exception
+ # do nothing, it cannot respond to == correctly, it can't be Rib::Skip
end
end