Sha256: d95b89364bab4578c8f7fec85e789fad8954357c44b065c5d52e4765815d948f

Contents?: true

Size: 923 Bytes

Versions: 39

Compression:

Stored size: 923 Bytes

Contents

class Pry
  class Command::WatchExpression
    class Expression
      attr_reader :target, :source, :value, :previous_value, :_pry_

      def initialize(_pry_, target, source)
        @_pry_ = _pry_
        @target = target
        @source = Code.new(source).strip
      end

      def eval!
        @previous_value = value
        @value = Pry::ColorPrinter.pp(target_eval(target, source), "")
      end

      def to_s
        "#{Code.new(source).highlighted.strip} => #{value}"
      end

      # Has the value of the expression changed?
      #
      # We use the pretty-printed string represenation to detect differences
      # as this avoids problems with dup (causes too many differences) and == (causes too few)
      def changed?
        (value != previous_value)
      end

      private

      def target_eval(target, source)
        target.eval(source)
      rescue => e
        e
      end
    end
  end
end

Version data entries

39 entries across 39 versions & 14 rubygems

Version Path
argon-1.3.1 vendor/bundle/ruby/2.7.0/gems/pry-0.12.2/lib/pry/commands/watch_expression/expression.rb
symbolic_enum-1.1.5 vendor/bundle/ruby/2.7.0/gems/pry-0.12.2/lib/pry/commands/watch_expression/expression.rb
honeybadger-4.5.3 vendor/bundle/ruby/2.6.0/gems/pry-0.12.2/lib/pry/commands/watch_expression/expression.rb
chatops-rpc-0.0.2 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/pry-0.12.2/lib/pry/commands/watch_expression/expression.rb
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/pry-0.12.2/lib/pry/commands/watch_expression/expression.rb
dadapush_client-1.0.1 vendor/bundle/ruby/2.3.0/gems/pry-0.11.3/lib/pry/commands/watch_expression/expression.rb
chess_engine-0.0.2 vendor/bundle/gems/pry-0.12.2/lib/pry/commands/watch_expression/expression.rb
chess_engine-0.0.1 vendor/bundle/gems/pry-0.12.2/lib/pry/commands/watch_expression/expression.rb
xaiml-0.1.3 vendor/bundle/ruby/2.5.0/gems/pry-0.11.3/lib/pry/commands/watch_expression/expression.rb
alimentos-alu0100945645-0.1.0 vendor/bundle/ruby/2.3.0/gems/pry-0.12.2/lib/pry/commands/watch_expression/expression.rb
alimentos-alu0100945645-1.0.0 vendor/bundle/ruby/2.3.0/gems/pry-0.12.2/lib/pry/commands/watch_expression/expression.rb
xaiml-0.1.2 vendor/bundle/ruby/2.5.0/gems/pry-0.11.3/lib/pry/commands/watch_expression/expression.rb
pry-0.12.2-java lib/pry/commands/watch_expression/expression.rb
pry-0.12.2 lib/pry/commands/watch_expression/expression.rb
pry-0.12.1 lib/pry/commands/watch_expression/expression.rb
pry-0.12.1-java lib/pry/commands/watch_expression/expression.rb
pry-0.12.0 lib/pry/commands/watch_expression/expression.rb
pry-0.12.0-java lib/pry/commands/watch_expression/expression.rb
xaiml-0.1.1 vendor/bundle/ruby/2.5.0/gems/pry-0.11.3/lib/pry/commands/watch_expression/expression.rb
xaiml-0.1.0 vendor/bundle/ruby/2.5.0/gems/pry-0.11.3/lib/pry/commands/watch_expression/expression.rb