pry-moves 1.0.8 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +7 -1
- data/README.md +7 -0
- data/lib/pry-moves/code_reloader.rb +10 -2
- data/lib/pry-moves/commands.rb +6 -0
- data/lib/pry-moves/formatter.rb +5 -3
- data/lib/pry-moves/restartable.rb +3 -0
- data/lib/pry-moves/version.rb +1 -1
- data/lib/pry-moves.rb +47 -3
- data/lib/sugar/debug_sugar.rb +4 -4
- data/pry-moves.gemspec +1 -0
- metadata +16 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: fdcb724770eaac3cde8ec275035e6505ee7db05e96cd0dc01fe2166772a8befb
         | 
| 4 | 
            +
              data.tar.gz: 94105e306cff0c70a6831b91bdc6c4eb461540b166edeacdb03738fde4d1dd7f
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 2b64ffcc6fc35e76c864ee77311c0007d0542c8a094b88d888a550e099932176c06ae388421ba17e6d94ca2ebb48f7c120d736ee8d93ebf8b7c71bfb3c29c9e3
         | 
| 7 | 
            +
              data.tar.gz: 1d80af8ebbaa72f5719e882526124b43d118e140da7aec7cccdd5e56cd78fa69518ea33583ca737a72d88e3eb5bdb52fcf26bfb520f11551262357065857ec9f
         | 
    
        data/Gemfile.lock
    CHANGED
    
    | @@ -1,12 +1,13 @@ | |
| 1 1 | 
             
            PATH
         | 
| 2 2 | 
             
              remote: .
         | 
| 3 3 | 
             
              specs:
         | 
| 4 | 
            -
                pry-moves (1.0. | 
| 4 | 
            +
                pry-moves (1.0.9)
         | 
| 5 5 | 
             
                  awesome_print (>= 1.8.0)
         | 
| 6 6 | 
             
                  binding_of_caller (~> 0.7)
         | 
| 7 7 | 
             
                  colorize (~> 0.8)
         | 
| 8 8 | 
             
                  diffy (~> 3.4.0)
         | 
| 9 9 | 
             
                  pry (>= 0.10.4, < 0.13)
         | 
| 10 | 
            +
                  pry-coolline (~> 0.2.5)
         | 
| 10 11 |  | 
| 11 12 | 
             
            GEM
         | 
| 12 13 | 
             
              remote: https://rubygems.org/
         | 
| @@ -16,6 +17,8 @@ GEM | |
| 16 17 | 
             
                  debug_inspector (>= 0.0.1)
         | 
| 17 18 | 
             
                coderay (1.1.2)
         | 
| 18 19 | 
             
                colorize (0.8.1)
         | 
| 20 | 
            +
                coolline (0.5.0)
         | 
| 21 | 
            +
                  unicode_utils (~> 1.4)
         | 
| 19 22 | 
             
                debug_inspector (1.1.0)
         | 
| 20 23 | 
             
                diff-lcs (1.3)
         | 
| 21 24 | 
             
                diffy (3.4.2)
         | 
| @@ -23,6 +26,8 @@ GEM | |
| 23 26 | 
             
                pry (0.11.3)
         | 
| 24 27 | 
             
                  coderay (~> 1.1.0)
         | 
| 25 28 | 
             
                  method_source (~> 0.9.0)
         | 
| 29 | 
            +
                pry-coolline (0.2.5)
         | 
| 30 | 
            +
                  coolline (~> 0.5)
         | 
| 26 31 | 
             
                pry-remote (0.1.8)
         | 
| 27 32 | 
             
                  pry (~> 0.9)
         | 
| 28 33 | 
             
                  slop (~> 3.0)
         | 
| @@ -40,6 +45,7 @@ GEM | |
| 40 45 | 
             
                  rspec-support (~> 3.8.0)
         | 
| 41 46 | 
             
                rspec-support (3.8.0)
         | 
| 42 47 | 
             
                slop (3.6.0)
         | 
| 48 | 
            +
                unicode_utils (1.4.0)
         | 
| 43 49 |  | 
| 44 50 | 
             
            PLATFORMS
         | 
| 45 51 | 
             
              ruby
         | 
    
        data/README.md
    CHANGED
    
    | @@ -38,6 +38,7 @@ Documentation for latest version. For [v0.1.12 see documentation here](https://g | |
| 38 38 | 
             
            * `.method` or `123` or `:hash_key` - Continue traversing of last object in history. E.g. `orders` will list array, then `3` will enter `orders[3]`, then `.price` will enter `orders[3].price`
         | 
| 39 39 | 
             
            * `watch variable` - display variable's value on each step
         | 
| 40 40 | 
             
            * `diff expression` - display difference between saved expression (on first run) and expression 2
         | 
| 41 | 
            +
            * `off` - Turn off debugging (don't stop on breakpoints)
         | 
| 41 42 | 
             
            * `@` - restart and reload scripts (in app/ & spec/ by default), reload rake tasks. Configurable.
         | 
| 42 43 | 
             
            * `#` - exit with code 3, can be wrapped in bash script to fully reload ruby scripts
         | 
| 43 44 | 
             
            * `!` - exit
         | 
| @@ -98,6 +99,12 @@ PRY_MOVES_DEBUG_MISSING=off | |
| 98 99 | 
             
            PRY_MOVES_RELOADER=off
         | 
| 99 100 | 
             
            ```
         | 
| 100 101 |  | 
| 102 | 
            +
            Debug:
         | 
| 103 | 
            +
            ```bash
         | 
| 104 | 
            +
            TRACE_MOVES=on
         | 
| 105 | 
            +
            ```
         | 
| 106 | 
            +
             | 
| 107 | 
            +
             | 
| 101 108 | 
             
            ## Threads, helpers
         | 
| 102 109 |  | 
| 103 110 | 
             
            To allow traveling to parent thread, use:
         | 
| @@ -31,7 +31,7 @@ class CodeReloader | |
| 31 31 |  | 
| 32 32 | 
             
              def traverse_files
         | 
| 33 33 | 
             
                paths = PryMoves.reload_ruby_scripts[:monitor]
         | 
| 34 | 
            -
                except = PryMoves.reload_ruby_scripts[:except]
         | 
| 34 | 
            +
                except = PryMoves.reload_ruby_scripts[:except] + rails_path_exceptions
         | 
| 35 35 | 
             
                paths.each do |root|
         | 
| 36 36 | 
             
                  files = Dir.glob("#{root}/**/*")
         | 
| 37 37 | 
             
                  files.each do |path|
         | 
| @@ -43,4 +43,12 @@ class CodeReloader | |
| 43 43 | 
             
                end
         | 
| 44 44 | 
             
              end
         | 
| 45 45 |  | 
| 46 | 
            -
             | 
| 46 | 
            +
              def rails_path_exceptions
         | 
| 47 | 
            +
                Rails.autoloaders.main.ignore.map do
         | 
| 48 | 
            +
                  _1.to_s.gsub /^#{Rails.root.to_s}\//, ""
         | 
| 49 | 
            +
                end
         | 
| 50 | 
            +
              rescue
         | 
| 51 | 
            +
                []
         | 
| 52 | 
            +
              end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
            end
         | 
    
        data/lib/pry-moves/commands.rb
    CHANGED
    
    | @@ -52,6 +52,7 @@ module PryMoves | |
| 52 52 | 
             
                end
         | 
| 53 53 |  | 
| 54 54 | 
             
                block_command 'diff', 'Display difference' do
         | 
| 55 | 
            +
                  next if PryMoves::Vars.var_precedence :diff, target
         | 
| 55 56 | 
             
                  cmd = arg_string.gsub(/^diff/, '').strip
         | 
| 56 57 | 
             
                  PryMoves::Diff.new(_pry_, target).run_command cmd
         | 
| 57 58 | 
             
                end
         | 
| @@ -65,6 +66,11 @@ module PryMoves | |
| 65 66 | 
             
                  breakout_navigation :debug, cmd
         | 
| 66 67 | 
             
                end
         | 
| 67 68 |  | 
| 69 | 
            +
                block_command 'off', '' do
         | 
| 70 | 
            +
                  PryMoves.switch if PryMoves.stop_on_breakpoints?
         | 
| 71 | 
            +
                  run 'continue'
         | 
| 72 | 
            +
                end
         | 
| 73 | 
            +
             | 
| 68 74 | 
             
                block_command :restart, '' do
         | 
| 69 75 | 
             
                  PryMoves.restart_requested = true
         | 
| 70 76 | 
             
                  run 'continue'
         | 
    
        data/lib/pry-moves/formatter.rb
    CHANGED
    
    | @@ -57,10 +57,12 @@ class PryMoves::Formatter | |
| 57 57 | 
             
                str.length > 50 ? "#{str.first 50}..." : str
         | 
| 58 58 | 
             
              end
         | 
| 59 59 |  | 
| 60 | 
            -
               | 
| 60 | 
            +
              def path_trash
         | 
| 61 | 
            +
                @path_trash ||= defined?(Rails) ? Rails.root.to_s : Dir.pwd
         | 
| 62 | 
            +
              end
         | 
| 61 63 |  | 
| 62 64 | 
             
              def shorten_path(path)
         | 
| 63 | 
            -
                path = path.gsub( /^#{ | 
| 65 | 
            +
                path = path.gsub( /^#{path_trash}\//, '')
         | 
| 64 66 | 
             
                PryMoves::Backtrace.trim_path ?
         | 
| 65 67 | 
             
                  File.basename(path, ".*") : path
         | 
| 66 68 | 
             
              end
         | 
| @@ -82,4 +84,4 @@ class PryMoves::Formatter | |
| 82 84 | 
             
                end
         | 
| 83 85 | 
             
              end
         | 
| 84 86 |  | 
| 85 | 
            -
            end
         | 
| 87 | 
            +
            end
         | 
    
        data/lib/pry-moves/version.rb
    CHANGED
    
    
    
        data/lib/pry-moves.rb
    CHANGED
    
    | @@ -15,7 +15,51 @@ module PryMoves | |
| 15 15 | 
             
                Kernel.loop do
         | 
| 16 16 | 
             
                  result = yield
         | 
| 17 17 | 
             
                  debug "⏸  execution loop complete\n#{result}"
         | 
| 18 | 
            -
                  PryMoves. | 
| 18 | 
            +
                  PryMoves.reload_sources
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              def stop_on_breakpoints?
         | 
| 23 | 
            +
                stop_on_breakpoints
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
              def switch
         | 
| 27 | 
            +
                self.stop_on_breakpoints = !self.stop_on_breakpoints
         | 
| 28 | 
            +
                if self.stop_on_breakpoints
         | 
| 29 | 
            +
                  puts '🪲  Debugging is turned on'
         | 
| 30 | 
            +
                else
         | 
| 31 | 
            +
                  puts '🐞 Debugging is turned off'
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              def listen_signal_to_switch use_signals = %w[INFO QUIT]
         | 
| 36 | 
            +
                # signals list in bash: stty -a
         | 
| 37 | 
            +
                signal = use_signals.find {Signal.list[_1]}
         | 
| 38 | 
            +
                unless signal
         | 
| 39 | 
            +
                  puts "No signals supported for PryMoves switch: #{use_signals}"
         | 
| 40 | 
            +
                  return
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                puts "🚥 Overriding #{signal} signal for PryMoves debug switch"
         | 
| 44 | 
            +
                Signal.trap 'INFO' do
         | 
| 45 | 
            +
                  PryMoves.switch
         | 
| 46 | 
            +
                end
         | 
| 47 | 
            +
              end
         | 
| 48 | 
            +
             | 
| 49 | 
            +
              def debug_window_attached?
         | 
| 50 | 
            +
                if !@last_attachment_check or Time.now - @last_attachment_check > 2
         | 
| 51 | 
            +
                  @is_debug_window_attached = begin
         | 
| 52 | 
            +
                    @last_attachment_check = Time.now
         | 
| 53 | 
            +
                    if `echo $STY` # is in screen
         | 
| 54 | 
            +
                      my_window = `echo $WINDOW`.strip
         | 
| 55 | 
            +
                      windows_list = `screen -Q windows`
         | 
| 56 | 
            +
                      windows_list.include? " #{my_window}*" # process is in currently active window
         | 
| 57 | 
            +
                    else
         | 
| 58 | 
            +
                      true
         | 
| 59 | 
            +
                    end
         | 
| 60 | 
            +
                  end
         | 
| 61 | 
            +
                else
         | 
| 62 | 
            +
                  @is_debug_window_attached
         | 
| 19 63 | 
             
                end
         | 
| 20 64 | 
             
              end
         | 
| 21 65 |  | 
| @@ -44,7 +88,7 @@ module PryMoves | |
| 44 88 | 
             
                pry_moves_stack_end = true
         | 
| 45 89 | 
             
                message ||= data
         | 
| 46 90 | 
             
                PryMoves.re_execution
         | 
| 47 | 
            -
                if PryMoves.stop_on_breakpoints
         | 
| 91 | 
            +
                if PryMoves.stop_on_breakpoints?
         | 
| 48 92 | 
             
                  self.debug_called_times += 1
         | 
| 49 93 | 
             
                  return if at and self.debug_called_times != at
         | 
| 50 94 | 
             
                  return if from and self.debug_called_times < from
         | 
| @@ -60,7 +104,7 @@ module PryMoves | |
| 60 104 |  | 
| 61 105 | 
             
              def runtime_debug(instance, external: false)
         | 
| 62 106 | 
             
                do_debug = (
         | 
| 63 | 
            -
                  stop_on_breakpoints and
         | 
| 107 | 
            +
                  stop_on_breakpoints? and
         | 
| 64 108 | 
             
                    not open? and
         | 
| 65 109 | 
             
                    (external or is_project_file?) and
         | 
| 66 110 | 
             
                    not [RubyVM::InstructionSequence].include?(instance)
         | 
    
        data/lib/sugar/debug_sugar.rb
    CHANGED
    
    | @@ -9,7 +9,7 @@ def error(err = "Error", debug_object = nil) | |
| 9 9 | 
             
              message = "😱  #{err}"
         | 
| 10 10 | 
             
              debug_object ||= err.metadata if err.respond_to? :metadata
         | 
| 11 11 | 
             
              unless PryMoves.open? or err.is_a? PryMoves::Restart
         | 
| 12 | 
            -
                if PryMoves.stop_on_breakpoints
         | 
| 12 | 
            +
                if PryMoves.stop_on_breakpoints?
         | 
| 13 13 | 
             
                  PryMoves.debug_error message.red, debug_object
         | 
| 14 14 | 
             
                elsif !PryMoves.dont_print_errors
         | 
| 15 15 | 
             
                  STDERR.puts PryMoves.format_debug_object(debug_object) if debug_object
         | 
| @@ -24,7 +24,7 @@ def shit!(err = 'Oh, shit!', debug_object = nil) | |
| 24 24 | 
             
              return if ENV['NO_SHIT']
         | 
| 25 25 | 
             
              pry_moves_stack_end = true
         | 
| 26 26 | 
             
              message = "💩  #{err.is_a?(String) ? err : err.message}"
         | 
| 27 | 
            -
              raise err unless PryMoves.stop_on_breakpoints
         | 
| 27 | 
            +
              raise err unless PryMoves.stop_on_breakpoints?
         | 
| 28 28 | 
             
              lines = [message.red]
         | 
| 29 29 | 
             
              lines.prepend debug_object.ai if debug_object
         | 
| 30 30 | 
             
              PryMoves.debug_error lines.join("\n")
         | 
| @@ -33,9 +33,9 @@ end | |
| 33 33 |  | 
| 34 34 | 
             
            Object.class_eval do
         | 
| 35 35 |  | 
| 36 | 
            -
              def required!
         | 
| 36 | 
            +
              def required! param = nil
         | 
| 37 37 | 
             
                pry_moves_stack_end = true
         | 
| 38 | 
            -
                error("required parameter is missing",  | 
| 38 | 
            +
                error("required parameter is missing", param) if self.nil?
         | 
| 39 39 | 
             
                self
         | 
| 40 40 | 
             
              end
         | 
| 41 41 |  | 
    
        data/pry-moves.gemspec
    CHANGED
    
    | @@ -20,6 +20,7 @@ Gem::Specification.new do |gem| | |
| 20 20 | 
             
              # Dependencies
         | 
| 21 21 | 
             
              gem.required_ruby_version = '>= 1.8.7', '< 3'
         | 
| 22 22 | 
             
              gem.add_runtime_dependency 'pry', '>= 0.10.4', '< 0.13'
         | 
| 23 | 
            +
              gem.add_runtime_dependency 'pry-coolline', '~> 0.2.5'
         | 
| 23 24 | 
             
              gem.add_runtime_dependency 'binding_of_caller', '~> 0.7'
         | 
| 24 25 | 
             
              gem.add_runtime_dependency 'colorize', '~> 0.8'
         | 
| 25 26 | 
             
              gem.add_runtime_dependency 'awesome_print', '>= 1.8.0'
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: pry-moves
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.0. | 
| 4 | 
            +
              version: 1.0.10
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - garmoshka-mo
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2023- | 
| 11 | 
            +
            date: 2023-11-15 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: pry
         | 
| @@ -30,6 +30,20 @@ dependencies: | |
| 30 30 | 
             
                - - "<"
         | 
| 31 31 | 
             
                  - !ruby/object:Gem::Version
         | 
| 32 32 | 
             
                    version: '0.13'
         | 
| 33 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 34 | 
            +
              name: pry-coolline
         | 
| 35 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 36 | 
            +
                requirements:
         | 
| 37 | 
            +
                - - "~>"
         | 
| 38 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 39 | 
            +
                    version: 0.2.5
         | 
| 40 | 
            +
              type: :runtime
         | 
| 41 | 
            +
              prerelease: false
         | 
| 42 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 43 | 
            +
                requirements:
         | 
| 44 | 
            +
                - - "~>"
         | 
| 45 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 46 | 
            +
                    version: 0.2.5
         | 
| 33 47 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 34 48 | 
             
              name: binding_of_caller
         | 
| 35 49 | 
             
              requirement: !ruby/object:Gem::Requirement
         |