pry-moves 1.0.12 → 1.0.13
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 +2 -2
- data/README.md +9 -2
- data/lib/commands/profile.rb +7 -0
- data/lib/pry-moves/add_suffix.rb +2 -0
- data/lib/pry-moves/pry_wrapper.rb +2 -1
- data/lib/pry-moves/version.rb +1 -1
- data/lib/pry-moves.rb +26 -5
- data/lib/sugar/debug_sugar.rb +1 -1
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 54b617db559dc0394f447095883171d67be49bbddd46bffb6d65206efd6a7d4b
         | 
| 4 | 
            +
              data.tar.gz: aff84108e38f6be7e651ac0363f83046af91b287856773a8e5944b1d45e218f1
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 97c48fd3a44a337062e934de38faa1bce273f29ef81d6e7d3a957f38318deb1c512bc816ba1d12ab0b2c24893fd3c61453b4cf7b0f718b0bd198ff1e304f55bb
         | 
| 7 | 
            +
              data.tar.gz: 2de12cf6e43a8f6e488acec5db74b8745b2b7ef27c6c3b526e6835ea5b89c2f013a1f180202056c401ac147878038d103ea62d81b0fbb3b4a0d3c85486c9db46
         | 
    
        data/Gemfile.lock
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            PATH
         | 
| 2 2 | 
             
              remote: .
         | 
| 3 3 | 
             
              specs:
         | 
| 4 | 
            -
                pry-moves (1.0. | 
| 4 | 
            +
                pry-moves (1.0.12)
         | 
| 5 5 | 
             
                  awesome_print (>= 1.8.0)
         | 
| 6 6 | 
             
                  binding_of_caller (~> 0.7)
         | 
| 7 7 | 
             
                  colorize (~> 0.8)
         | 
| @@ -16,7 +16,7 @@ GEM | |
| 16 16 | 
             
                  debug_inspector (>= 0.0.1)
         | 
| 17 17 | 
             
                coderay (1.1.2)
         | 
| 18 18 | 
             
                colorize (0.8.1)
         | 
| 19 | 
            -
                debug_inspector (1. | 
| 19 | 
            +
                debug_inspector (1.2.0)
         | 
| 20 20 | 
             
                diff-lcs (1.3)
         | 
| 21 21 | 
             
                diffy (3.4.2)
         | 
| 22 22 | 
             
                method_source (0.9.0)
         | 
    
        data/README.md
    CHANGED
    
    | @@ -38,14 +38,21 @@ 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 | 
            -
            * `profile` - profile  | 
| 41 | 
            +
            * `profile [timeout]` - profile time-consuming code and infinite loops/recursion
         | 
| 42 42 | 
             
            * `off` - Turn off debugging (don't stop on breakpoints)
         | 
| 43 43 | 
             
            * `@` - restart and reload scripts (in app/ & spec/ by default), reload rake tasks. Configurable.
         | 
| 44 44 | 
             
            * `#` - exit with code 3, can be wrapped in bash script to fully reload ruby scripts
         | 
| 45 45 | 
             
            * `!` - exit
         | 
| 46 46 |  | 
| 47 47 | 
             
            Variable & methods names takes precedence over commands. 
         | 
| 48 | 
            -
            So if you have variable named `step`, to execute command `step` type `cmd step` or command's alias, e.g. `s` | 
| 48 | 
            +
            So if you have variable named `step`, to execute command `step` type `cmd step` or command's alias, e.g. `s`
         | 
| 49 | 
            +
             | 
| 50 | 
            +
            Custom commands:
         | 
| 51 | 
            +
            ```ruby
         | 
| 52 | 
            +
            PryMoves.custom_command "say" do |args, output|
         | 
| 53 | 
            +
              output.puts "Pry says: #{args}"
         | 
| 54 | 
            +
            end
         | 
| 55 | 
            +
            ```
         | 
| 49 56 |  | 
| 50 57 | 
             
            ## Examples
         | 
| 51 58 |  | 
    
        data/lib/commands/profile.rb
    CHANGED
    
    | @@ -2,11 +2,18 @@ class PryMoves::Profile < PryMoves::TraceCommand | |
| 2 2 |  | 
| 3 3 | 
             
              def init(binding_)
         | 
| 4 4 | 
             
                @start_line = binding_.eval('__LINE__')
         | 
| 5 | 
            +
                @profiling_start_at = Time.now
         | 
| 6 | 
            +
                @timeout = (@command[:param]&.to_i || 3).seconds
         | 
| 5 7 | 
             
              end
         | 
| 6 8 |  | 
| 7 9 | 
             
              def trace(event, file, line, method, binding_)
         | 
| 8 10 | 
             
                return unless file.start_with? PryMoves.project_root
         | 
| 9 11 |  | 
| 12 | 
            +
                if Time.now - @profiling_start_at > @timeout
         | 
| 13 | 
            +
                  PryMoves.messages << "Profiling timeout: #{@timeout} seconds"
         | 
| 14 | 
            +
                  return true
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
             | 
| 10 17 | 
             
                stop = false
         | 
| 11 18 | 
             
                place = "#{method} @ #{file}:#{line}"
         | 
| 12 19 | 
             
                if @last_place != place
         | 
    
        data/lib/pry-moves/add_suffix.rb
    CHANGED
    
    
    
        data/lib/pry-moves/version.rb
    CHANGED
    
    
    
        data/lib/pry-moves.rb
    CHANGED
    
    | @@ -93,7 +93,7 @@ module PryMoves | |
| 93 93 | 
             
                  return if at and self.debug_called_times != at
         | 
| 94 94 | 
             
                  return if from and self.debug_called_times < from
         | 
| 95 95 | 
             
                  if message
         | 
| 96 | 
            -
                    PryMoves.messages << (message | 
| 96 | 
            +
                    PryMoves.messages << format_debug_object(message)
         | 
| 97 97 | 
             
                  end
         | 
| 98 98 | 
             
                  binding.pry options
         | 
| 99 99 | 
             
                  PryMoves.re_execution
         | 
| @@ -127,9 +127,16 @@ module PryMoves | |
| 127 127 |  | 
| 128 128 | 
             
              MAX_MESSAGE_CHARS = 520
         | 
| 129 129 | 
             
              def format_debug_object obj
         | 
| 130 | 
            -
                 | 
| 131 | 
            -
                 | 
| 132 | 
            -
                   | 
| 130 | 
            +
                result = case obj
         | 
| 131 | 
            +
                when String
         | 
| 132 | 
            +
                  obj
         | 
| 133 | 
            +
                when Hash
         | 
| 134 | 
            +
                  result = obj.map {"#{_1}:#{_2}"}.join " "
         | 
| 135 | 
            +
                  result if result.length < 100
         | 
| 136 | 
            +
                end
         | 
| 137 | 
            +
                result ||= obj.ai rescue "#{obj.class} #{obj}"
         | 
| 138 | 
            +
                result.length > MAX_MESSAGE_CHARS ?
         | 
| 139 | 
            +
                  result[0 .. MAX_MESSAGE_CHARS] + "... (cut)" : result
         | 
| 133 140 | 
             
              end
         | 
| 134 141 |  | 
| 135 142 | 
             
              def debug_error(message, debug_object=nil)
         | 
| @@ -159,6 +166,18 @@ module PryMoves | |
| 159 166 | 
             
                Pry.commands.block_command command, "", &block
         | 
| 160 167 | 
             
              end
         | 
| 161 168 |  | 
| 169 | 
            +
              def custom_command command, &block
         | 
| 170 | 
            +
                cls = Pry::Commands.create_command command, "", :shellwords => false do; end
         | 
| 171 | 
            +
                cls.define_method(:process_block) do |args, output|
         | 
| 172 | 
            +
                  block.call args, output
         | 
| 173 | 
            +
                end
         | 
| 174 | 
            +
                cls.class_eval do
         | 
| 175 | 
            +
                  def process
         | 
| 176 | 
            +
                    process_block args, output
         | 
| 177 | 
            +
                  end
         | 
| 178 | 
            +
                end
         | 
| 179 | 
            +
              end
         | 
| 180 | 
            +
             | 
| 162 181 | 
             
              def locked?
         | 
| 163 182 | 
             
                semaphore.locked?
         | 
| 164 183 | 
             
              end
         | 
| @@ -185,6 +204,8 @@ module PryMoves | |
| 185 204 |  | 
| 186 205 | 
             
              def trigger(event, context)
         | 
| 187 206 | 
             
                triggers[event].each {|t| t.call context}
         | 
| 207 | 
            +
              rescue => err
         | 
| 208 | 
            +
                puts "PryMoves :#{event} Trigger error: #{err}".red
         | 
| 188 209 | 
             
              end
         | 
| 189 210 |  | 
| 190 211 | 
             
              def triggers
         | 
| @@ -193,7 +214,7 @@ module PryMoves | |
| 193 214 | 
             
                end
         | 
| 194 215 | 
             
              end
         | 
| 195 216 |  | 
| 196 | 
            -
              TRIGGERS = [:each_new_run, :restart]
         | 
| 217 | 
            +
              TRIGGERS = [:each_new_run, :restart, :after_debug]
         | 
| 197 218 | 
             
              def on(trigger, &block)
         | 
| 198 219 | 
             
                error "Invalid trigger, possible triggers: #{TRIGGERS}", trigger unless TRIGGERS.include? trigger
         | 
| 199 220 | 
             
                triggers[trigger] << block
         | 
    
        data/lib/sugar/debug_sugar.rb
    CHANGED
    
    | @@ -26,7 +26,7 @@ def shit!(err = 'Oh, shit!', debug_object = nil) | |
| 26 26 | 
             
              message = "💩  #{err.is_a?(String) ? err : err.message}"
         | 
| 27 27 | 
             
              raise err unless PryMoves.stop_on_breakpoints?
         | 
| 28 28 | 
             
              lines = [message.red]
         | 
| 29 | 
            -
              lines.prepend debug_object | 
| 29 | 
            +
              lines.prepend PryMoves.format_debug_object(debug_object) if debug_object
         | 
| 30 30 | 
             
              PryMoves.debug_error lines.join("\n")
         | 
| 31 31 | 
             
              nil
         | 
| 32 32 | 
             
            end
         | 
    
        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.13
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - garmoshka-mo
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2025-01-09 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: pry
         |