pry-moves 1.0.11 → 1.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 055037ce750443ea5d107432df9127da420d404d5567d9f4ec1a4501a2452385
4
- data.tar.gz: a08f1bfca1142318f4028e09b640a1f587afd2de23449772588cb70ed826f94d
3
+ metadata.gz: e1b513a3d36e4051c2db1e270a86b70baaaa150e9f1c76046e0cc3af8d213704
4
+ data.tar.gz: 10e687ef4ce616be58d8fda903573118078c54a0425c7146b3cc64ff24b356c5
5
5
  SHA512:
6
- metadata.gz: 451a2f4c4807038fb862b14a4a00fcd6615b4e6350bd666a6fce81662963890d33139d5cf2358887de08b3f5feef1f5795f861b4166d2676d9f58802942b0539
7
- data.tar.gz: 61a04809ebf60788253fd40211a706f12bd4c425af71742a27a8368536e6c4a657c510134689cf66cb09bbd5c46e13a2b50cf6295a0bdf71c49d78711b61c621
6
+ metadata.gz: 0e4e758371c47cc09470c8460e191e728040b81fd4496c055cc83f2cee7a4a9d196ddf2e5bb384e9a3ce71b4cf46088651a2c338907c98115a0bb461a8ec4390
7
+ data.tar.gz: 2c2cc9896cd78dd420ff0dec84339f084c51e60eb95023d7a5be58cd362a84796d0c7d929862932c8d200cee3179cffae5c836b4c78fe5b6d1e657e56be47409
data/Gemfile.lock CHANGED
@@ -1,13 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pry-moves (1.0.10)
4
+ pry-moves (1.0.11)
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)
11
10
 
12
11
  GEM
13
12
  remote: https://rubygems.org/
@@ -17,8 +16,6 @@ GEM
17
16
  debug_inspector (>= 0.0.1)
18
17
  coderay (1.1.2)
19
18
  colorize (0.8.1)
20
- coolline (0.5.0)
21
- unicode_utils (~> 1.4)
22
19
  debug_inspector (1.1.0)
23
20
  diff-lcs (1.3)
24
21
  diffy (3.4.2)
@@ -26,8 +23,6 @@ GEM
26
23
  pry (0.11.3)
27
24
  coderay (~> 1.1.0)
28
25
  method_source (~> 0.9.0)
29
- pry-coolline (0.2.5)
30
- coolline (~> 0.5)
31
26
  pry-remote (0.1.8)
32
27
  pry (~> 0.9)
33
28
  slop (~> 3.0)
@@ -45,7 +40,6 @@ GEM
45
40
  rspec-support (~> 3.8.0)
46
41
  rspec-support (3.8.0)
47
42
  slop (3.6.0)
48
- unicode_utils (1.4.0)
49
43
 
50
44
  PLATFORMS
51
45
  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
+ * `profile` - profile most time-consuming code
41
42
  * `off` - Turn off debugging (don't stop on breakpoints)
42
43
  * `@` - restart and reload scripts (in app/ & spec/ by default), reload rake tasks. Configurable.
43
44
  * `#` - exit with code 3, can be wrapped in bash script to fully reload ruby scripts
@@ -0,0 +1,27 @@
1
+ class PryMoves::Profile < PryMoves::TraceCommand
2
+
3
+ def init(binding_)
4
+ @start_line = binding_.eval('__LINE__')
5
+ end
6
+
7
+ def trace(event, file, line, method, binding_)
8
+ return unless file.start_with? PryMoves.project_root
9
+
10
+ stop = false
11
+ place = "#{method} @ #{file}:#{line}"
12
+ if @last_place != place
13
+ if @last_start_at
14
+ took = Time.now - @last_start_at
15
+ if took > 0.1
16
+ PryMoves.messages << "#{@last_place} took #{took} seconds"
17
+ stop = true
18
+ end
19
+ end
20
+ @last_place = place
21
+ @last_start_at = Time.now
22
+ end
23
+
24
+ stop
25
+ end
26
+
27
+ end
@@ -81,6 +81,9 @@ class TraceCommand
81
81
  elsif event == "return" and traced_method?(file, line, method, binding_)
82
82
  @call_depth -= 1
83
83
  end
84
+ rescue => err
85
+ puts err.backtrace.reverse
86
+ puts "PryMoves Tracing error: #{err}".red
84
87
  end
85
88
 
86
89
  def traced_method?(file, line, method, binding_)
@@ -44,8 +44,12 @@ class CodeReloader
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}\//, ""
47
+ if defined?(Rails)
48
+ Rails.autoloaders.main.ignore.map do
49
+ _1.to_s.gsub /^#{Rails.root.to_s}\//, ""
50
+ end
51
+ else
52
+ []
49
53
  end
50
54
  rescue
51
55
  []
@@ -42,7 +42,7 @@ module PryMoves
42
42
  alias_command 'g', 'goto'
43
43
 
44
44
  block_command 'continue', 'Continue program execution and end the Pry session' do
45
- check_file_context
45
+ _check_file_context
46
46
  run 'exit-all'
47
47
  end
48
48
  alias_command 'c', 'continue'
@@ -66,6 +66,10 @@ module PryMoves
66
66
  breakout_navigation :debug, cmd
67
67
  end
68
68
 
69
+ block_command 'profile', '' do |param|
70
+ breakout_navigation :profile, param
71
+ end
72
+
69
73
  block_command 'off', '' do
70
74
  PryMoves.switch if PryMoves.stop_on_breakpoints?
71
75
  run 'continue'
@@ -103,7 +107,7 @@ module PryMoves
103
107
  def breakout_navigation(action, param)
104
108
  return if PryMoves::Vars.var_precedence action, target
105
109
 
106
- check_file_context
110
+ _check_file_context
107
111
  _pry_.binding_stack.clear # Clear the binding stack.
108
112
  throw :breakout_nav, { # Break out of the REPL loop and
109
113
  action: action, # signal the tracer.
@@ -113,7 +117,7 @@ module PryMoves
113
117
  end
114
118
 
115
119
  # Ensures that a command is executed in a local file context.
116
- def check_file_context
120
+ def _check_file_context
117
121
  unless PryMoves.check_file_context(target)
118
122
  raise Pry::CommandError, 'Cannot find local context. Did you use `binding.pry`?'
119
123
  end
@@ -1,10 +1,11 @@
1
1
  class PryMoves::ErrorWithData < StandardError
2
2
 
3
- attr_reader :metadata
3
+ attr_reader :data
4
+ alias metadata data
4
5
 
5
- def initialize(msg, metadata)
6
+ def initialize(msg, data)
6
7
  super msg
7
- @metadata = metadata
8
+ @data = data
8
9
  end
9
-
10
- end
10
+
11
+ end
@@ -57,12 +57,9 @@ class PryMoves::Formatter
57
57
  str.length > 50 ? "#{str.first 50}..." : str
58
58
  end
59
59
 
60
- def path_trash
61
- @path_trash ||= defined?(Rails) ? Rails.root.to_s : Dir.pwd
62
- end
63
-
64
60
  def shorten_path(path)
65
- path = path.gsub( /^#{path_trash}\//, '')
61
+ project_root = PryMoves.project_root
62
+ path = path.gsub( /^#{project_root}\//, '')
66
63
  PryMoves::Backtrace.trim_path ?
67
64
  File.basename(path, ".*") : path
68
65
  end
@@ -112,7 +112,7 @@ Pry::Command::Whereami.class_eval do
112
112
  end
113
113
 
114
114
  def location
115
- defined?(Rails) ? @file.gsub(Rails.root.to_s, '') : @file
115
+ @file
116
116
  end
117
117
  end
118
118
 
@@ -141,4 +141,4 @@ Pry::Output.class_eval do
141
141
  pry_moves_origin_for_puts *args
142
142
  end
143
143
 
144
- end if defined? Pry::Output
144
+ end if defined? Pry::Output
@@ -1,3 +1,3 @@
1
1
  module PryMoves
2
- VERSION = '1.0.11'
2
+ VERSION = '1.0.12'
3
3
  end
data/lib/pry-moves.rb CHANGED
@@ -199,6 +199,10 @@ module PryMoves
199
199
  triggers[trigger] << block
200
200
  end
201
201
 
202
+ def project_root
203
+ @project_root ||= defined?(Rails) ? Rails.root.to_s : Dir.pwd
204
+ end
205
+
202
206
  # Reference to currently running pry-remote server. Used by the tracer.
203
207
  attr_accessor :current_remote_server
204
208
  end
data/lib/requires.rb CHANGED
@@ -31,6 +31,7 @@ require 'commands/iterate'
31
31
  require 'commands/next'
32
32
  require 'commands/next_breakpoint'
33
33
  require 'commands/step'
34
+ require 'commands/profile'
34
35
 
35
36
  require 'pry-stack_explorer/pry-stack_explorer'
36
37
  require 'sugar/debug_sugar'
data/pry-moves.gemspec CHANGED
@@ -20,7 +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
+ # gem.add_runtime_dependency 'pry-coolline', '~> 0.2.5'
24
24
  gem.add_runtime_dependency 'binding_of_caller', '~> 0.7'
25
25
  gem.add_runtime_dependency 'colorize', '~> 0.8'
26
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.11
4
+ version: 1.0.12
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-15 00:00:00.000000000 Z
11
+ date: 2024-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -30,20 +30,6 @@ 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
47
33
  - !ruby/object:Gem::Dependency
48
34
  name: binding_of_caller
49
35
  requirement: !ruby/object:Gem::Requirement
@@ -136,6 +122,7 @@ files:
136
122
  - lib/commands/iterate.rb
137
123
  - lib/commands/next.rb
138
124
  - lib/commands/next_breakpoint.rb
125
+ - lib/commands/profile.rb
139
126
  - lib/commands/step.rb
140
127
  - lib/commands/trace_command.rb
141
128
  - lib/commands/trace_helpers.rb