lib/lll.rb in lll-1.4.0 vs lib/lll.rb in lll-1.9.2

- old
+ new

@@ -14,11 +14,11 @@ output_string = " " expression_value = 0 if block output_string << msg + ': ' if msg expression_string = block.call - expression_value = eval(expression_string, block) + expression_value = eval(expression_string, block.binding) output_string << expression_string + ' = ' if enumerable? expression_value output_string << " \n" expression_value.each { |e| output_string << ' ' << e.inspect << " \n" } else @@ -27,11 +27,11 @@ else output_string << msg if msg output_string << " \n" end - Kernel.puts format(output_string, ENV['TERM'] != 'dumb') + $stderr.puts format(output_string, ENV['TERM'] != 'dumb') Rails.logger.debug(format(output_string)) if defined?(Rails) && Rails.logger expression_value end @@ -40,9 +40,12 @@ string = "\e[7m" + string + "\e[0m" if colorize string + "lll: #{caller[2].to_s} #{Time.now.strftime('%X')}" end def self.enumerable? value - value.respond_to?(:each) && !value.is_a?(String) && !value.is_a?(Nokogiri::HTML::Document) && - !value.is_a?(Nokogiri::XML::Element) + value.respond_to?(:each) && + !value.is_a?(String) && + (!defined? Nokogiri || + (!value.is_a?(Nokogiri::HTML::Document) && + !value.is_a?(Nokogiri::XML::Element))) end end