pry-moves 1.0.4 → 1.0.5

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: 311be09c5ffb0f48a6aae45f2cf138b4ac8f1c5b285335dd1b358ac5153ca6ab
4
- data.tar.gz: 66b1eb2eea22582332db51580159ff3ad470dcdd26c2952b5b8846db4928cfb8
3
+ metadata.gz: 301fded3cbdfbcafed7b5387b820b8c1366be09023f0462a8ab1a36a7bbcc563
4
+ data.tar.gz: bfb140a999ccc293ca3f81ab11b2ea456c48f21c5a62902c6a44e6c6453e2baa
5
5
  SHA512:
6
- metadata.gz: 55f69a03e9109a9f55c277242318475ef22cbf4776f885f4a2a3d8bab2ec66e83f6896ab305443dc7d5a6797db6bf7bc97644185e98ba18185792161d87dda8d
7
- data.tar.gz: ec9e017b99cd33292fd49c5458a9fbe5abb3391a8966032cc9d7aa40f69051fddd83bffbe12b24e1f2e4724458b01893bf8a193934babb3b02e26c1f816b8e3f
6
+ metadata.gz: 794091fb89ac6ab0b9b2de60dc960137dd72068368caafb6302e6b5731835c3d0d36db7526524c7d6b47104eaf1293aec779a9bb4bfcb45aa1a22a3dd71484c2
7
+ data.tar.gz: 816e6e90426305ea3b08ed9bfa1899106a3870b782a25cef59abfc3462d7ffa99fa081cae74acb0acfced7126267176c2b6af32fae6510b0e72a4217bd6bb95c
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- pry-moves (1.0.4)
4
+ pry-moves (1.0.5)
5
5
  awesome_print (>= 1.8.0)
6
6
  binding_of_caller (~> 0.7)
7
7
  colorize (~> 0.8)
@@ -4,6 +4,10 @@ class PryMoves::NextBreakpoint < PryMoves::TraceCommand
4
4
  end
5
5
 
6
6
  def trace(event, file, line, method, binding_)
7
+ # this command will stuck in tracing when no breakpoint met (usually)
8
+ PryMoves.messages << "⚠️ Command NextBreakpoint is not implemented"
9
+ return true
10
+
7
11
  if binding_.local_variable_defined?(:pry_breakpoint) and
8
12
  binding_.local_variable_get(:pry_breakpoint)
9
13
  binding_.local_variable_set :pry_breakpoint, nil # reset breakpoint at visited method instance
@@ -3,6 +3,7 @@ require 'fileutils'
3
3
  class PryMoves::Backtrace
4
4
 
5
5
  FILTERS = %w[/gems/ /rubygems/ /bin/ /lib/ruby/]
6
+ FILTERS << File.expand_path('..', __dir__)
6
7
  @@backtrace = nil
7
8
 
8
9
  class << self
@@ -113,17 +113,14 @@ module PryMoves
113
113
  end
114
114
 
115
115
  input = Pry.config.original_user_input || action.to_s
116
- return if input == 'next' # ruby keyword
117
- binding_value = target.eval(input) rescue nil
118
- # begin # for debug
119
- # binding_value = target.eval(input)
120
- # rescue => e
121
- # puts (e.backtrace.reverse + ["var_precedence exception:".red, "#{e}".red]).join "\n"
122
- # end
123
- unless binding_value.nil?
116
+ return if %w[next debug].include? input # next - ruby keyword
117
+ begin
118
+ binding_value = target.eval(input)
124
119
  puts "ℹ️️ Variable \"#{input}\" found. To execute command type its alias or \\#{input}"
125
120
  puts PryMoves::Painter.colorize binding_value
126
121
  true
122
+ rescue => e
123
+ # puts (e.backtrace.reverse + ["var_precedence exception:".red, "#{e}".red]).join "\n"
127
124
  end
128
125
  end
129
126
 
@@ -12,10 +12,20 @@ module PryMoves::Painter
12
12
 
13
13
  end
14
14
 
15
+ class ShortInspector
16
+ def initialize obj
17
+ @obj = obj
18
+ end
19
+ def inspect
20
+ @obj.short_inspect
21
+ end
22
+ end
23
+
15
24
  def self.colorize(obj)
16
25
  colored_str = Canvas.new
17
26
  i = obj.inspect
18
27
  obj = obj.class if i.is_a?(String) && i.start_with?("#<")
28
+ obj = ShortInspector.new(obj) if obj.respond_to?(:short_inspect)
19
29
  catch (:cut) do
20
30
  Pry::ColorPrinter.pp obj, colored_str
21
31
  end
@@ -86,6 +86,7 @@ Pry::Command::Whereami.class_eval do
86
86
 
87
87
  formatter = PryMoves::Formatter.new
88
88
  prefix = Thread.current[:pry_moves_debug] ? "👾 " : ""
89
+ # lines << "🍱 #{PryMoves.test_example}" if PryMoves.test_example
89
90
  lines << "🦆 step_in_everywhere" if PryMoves.step_in_everywhere
90
91
  lines << "#{prefix}#{formatter.shorten_path location}:#{@line} #{me}"
91
92
  lines << " ." + formatter.method_signature(target)
@@ -44,6 +44,7 @@ class PryWrapper
44
44
  nil # Nothing thrown == no navigational command
45
45
  end
46
46
 
47
+ ensure
47
48
  PryMoves.is_open = false
48
49
  Pry.config.marker = "=>"
49
50
  end
@@ -9,10 +9,9 @@ module PryMoves::Restartable
9
9
  context[:retry] ||= 0
10
10
  PryMoves.reloader&.reload if context[:retry] > 0
11
11
  yield context
12
- re_execution
12
+ re_execution # todo: maybe mark restart_request for thread? not globally?
13
13
  rescue PryMoves::Restart
14
14
  puts "🔄️ Restarting execution"
15
- self.restart_requested = false
16
15
  PryMoves.reset
17
16
  trigger :restart, context
18
17
  context[:retry] += 1
@@ -23,7 +22,10 @@ module PryMoves::Restartable
23
22
  end
24
23
 
25
24
  def re_execution
26
- raise PryMoves::Restart if restart_requested
25
+ if restart_requested
26
+ self.restart_requested = false
27
+ raise PryMoves::Restart
28
+ end
27
29
  raise PryMoves::Reload if reload_requested
28
30
  end
29
31
 
@@ -1,3 +1,3 @@
1
1
  module PryMoves
2
- VERSION = '1.0.4'
2
+ VERSION = '1.0.5'
3
3
  end
data/lib/pry-moves.rb CHANGED
@@ -7,14 +7,23 @@ module PryMoves
7
7
  extend PryMoves::Restartable
8
8
 
9
9
  attr_accessor :is_open, :trace, :stack_tips,
10
- :stop_on_breakpoints, :launched_specs_examples,
10
+ :stop_on_breakpoints,
11
+ :test_example, :launched_specs_examples,
11
12
  :debug_called_times, :step_in_everywhere
12
13
 
14
+ def loop
15
+ Kernel.loop do
16
+ result = yield
17
+ debug "⏸ execution loop complete\n#{result}"
18
+ PryMoves.reloader&.reload
19
+ end
20
+ end
21
+
13
22
  def init
14
23
  reset
15
24
  self.trace = true if ENV['TRACE_MOVES']
16
25
  self.reload_ruby_scripts = {
17
- monitor: %w(app spec),
26
+ monitor: %w(app test spec),
18
27
  except: %w(app/assets app/views)
19
28
  }
20
29
  self.reloader = CodeReloader.new unless ENV['PRY_MOVES_RELOADER'] == 'off'
@@ -23,14 +32,17 @@ module PryMoves
23
32
 
24
33
  def reset
25
34
  self.launched_specs_examples = 0
26
- self.stop_on_breakpoints = true unless ENV['PRY_MOVES'] == 'off' ||
27
- (defined?(Rails) and Rails.env.production?)
35
+ unless ENV['PRY_MOVES'] == 'off' ||
36
+ (defined?(Rails) and Rails.env.production?)
37
+ self.stop_on_breakpoints = STDIN.tty? && STDOUT.tty?
38
+ end
28
39
  self.debug_called_times = 0
29
40
  self.step_in_everywhere = false
30
41
  end
31
42
 
32
- def debug(message = nil, at: nil, from: nil, options: nil)
43
+ def debug(message = nil, data: nil, at: nil, from: nil, options: nil)
33
44
  pry_moves_stack_end = true
45
+ message ||= data
34
46
  PryMoves.re_execution
35
47
  if PryMoves.stop_on_breakpoints
36
48
  self.debug_called_times += 1
@@ -63,7 +75,7 @@ module PryMoves
63
75
  end
64
76
 
65
77
  def is_project_file?
66
- files = caller[2..3] # -2 steps upside: runtime_debug, debug sugar function
78
+ files = caller[2..4] # -2 steps upside: runtime_debug, debug sugar function
67
79
  files.any? do |file|
68
80
  !file.start_with?("/") || file.start_with?(ROOT_DIR)
69
81
  end
@@ -5,9 +5,7 @@ Object.class_eval do
5
5
  pry_cancel_debug = true
6
6
 
7
7
  debug_missing_method = (
8
- not ([:begin, :to_s, :to_str, :to_int, :to_ary, :to_io, :to_hash].include? method)
9
-
10
- # not ([:begin, :to_s, :to_str, :to_int, :to_ary, :to_io, :to_hash].include? method) and
8
+ not ([:begin, :to_s, :to_str, :to_int, :to_r, :to_ary, :to_io, :to_hash].include? method)
11
9
  # not caller[0].match PryMoves::Backtrace::filter
12
10
  )
13
11
 
@@ -1,5 +1,5 @@
1
1
  def debug *args
2
- return binding.pry_forced if args.first == :forced
2
+ return binding.pry_forced if [:force, :forced].include? args.first
3
3
  pry_moves_stack_end = true
4
4
  PryMoves.debug *args
5
5
  end
@@ -33,7 +33,7 @@ Object.class_eval do
33
33
 
34
34
  def required!
35
35
  pry_moves_stack_end = true
36
- error("required parameter is missing") if self.nil?
36
+ error("required parameter is missing", self) if self.nil?
37
37
  self
38
38
  end
39
39
 
@@ -69,7 +69,7 @@ Rake::Task.class_eval do
69
69
 
70
70
  def execute(args=nil)
71
71
  args ||= EMPTY_TASK_ARGS
72
- PryMoves.restartable(rake_args: args) do |context|
72
+ PryMoves.restartable(rake_args: args, name: self.name) do |context|
73
73
  reload_actions if PryMoves.reload_rake_tasks and context[:retry] > 0
74
74
  execute_origin_for_pry_moves args
75
75
  end
data/publish.sh CHANGED
@@ -1,6 +1,6 @@
1
1
  set -e
2
2
  set -o pipefail
3
3
 
4
- bundle exec rspec
4
+ #bundle exec rspec
5
5
  gem build pry-moves.gemspec
6
6
  gem push pry-moves-`ruby -e 'require "./lib/pry-moves/version.rb"; puts PryMoves::VERSION'`.gem
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
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - garmoshka-mo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-29 00:00:00.000000000 Z
11
+ date: 2023-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry