byebug-skipper 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/byebug/skipper.rb +8 -1
- data/lib/byebug/skipper/comment_line_above.rb +31 -0
- data/lib/byebug/skipper/pry.rb +40 -15
- data/lib/byebug/skipper/skip_bang_command.rb +20 -0
- data/lib/byebug/skipper/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 360120962b1a0dc04e8f98ab79c32e4d1c1f590a2382ff4da51dd475f2d8420b
|
4
|
+
data.tar.gz: 58b99f37beab966329e3ac9d2e2d4440d2bbf013b349640b55abf06b41fa24e2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de210ab93f2b9af685874b06997946b023a4713451443a32562876e7c629f38aa4df17c2b82f708a11526ca17a495a4223c9cea13fab11d548ea62be270e1aab
|
7
|
+
data.tar.gz: 20fba508092216fdbd868353bc6b406aa0fbc3e2a15241cc9391e7ef14265df4be221c0be3b3ad4ef1c0f400a6bfe424e618f0b8a962c8517d1ce9e621a16cf6
|
data/lib/byebug/skipper.rb
CHANGED
@@ -20,13 +20,19 @@ module Byebug::Skipper
|
|
20
20
|
end
|
21
21
|
|
22
22
|
require 'delegate'
|
23
|
+
require 'tempfile'
|
24
|
+
|
23
25
|
require 'byebug'
|
24
|
-
require 'byebug/command'
|
25
26
|
require 'byebug/helpers/frame'
|
27
|
+
require 'byebug/command'
|
28
|
+
require 'byebug/commands/skip'
|
29
|
+
|
26
30
|
require_relative 'skipper/ups_command'
|
27
31
|
require_relative 'skipper/downs_command'
|
28
32
|
require_relative 'skipper/finishs_command'
|
29
33
|
require_relative 'skipper/steps_command'
|
34
|
+
require_relative 'skipper/comment_line_above'
|
35
|
+
require_relative 'skipper/skip_bang_command'
|
30
36
|
|
31
37
|
# Command classes need to be in the Byebug module or else they don't get picked
|
32
38
|
# up. Cool, bruh.
|
@@ -35,6 +41,7 @@ require_relative 'skipper/steps_command'
|
|
35
41
|
Byebug::Skipper::DownsCommand,
|
36
42
|
Byebug::Skipper::FinishsCommand,
|
37
43
|
Byebug::Skipper::StepsCommand,
|
44
|
+
Byebug::Skipper::SkipBangCommand,
|
38
45
|
].each do |command_class|
|
39
46
|
Byebug.const_set(
|
40
47
|
command_class.name.split('::').last,
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Byebug::Skipper
|
4
|
+
module CommentLineAbove
|
5
|
+
extend self
|
6
|
+
|
7
|
+
def call(location)
|
8
|
+
path, _, line_no = location.rpartition(':')
|
9
|
+
lines = File.readlines(path)
|
10
|
+
|
11
|
+
idx = Integer(line_no) - 2
|
12
|
+
while ignore_line?(lines[idx])
|
13
|
+
idx -= 1
|
14
|
+
return if idx < 0 # tried to go above the first line of the file, so abort
|
15
|
+
end
|
16
|
+
|
17
|
+
lines[idx] = comment_out(lines.fetch(idx))
|
18
|
+
File.write(path, lines.join)
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def comment_out(line)
|
24
|
+
line.sub(/\A\s*/, '\0# ')
|
25
|
+
end
|
26
|
+
|
27
|
+
def ignore_line?(line)
|
28
|
+
line.strip.empty? || line.strip.start_with?('#')
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/byebug/skipper/pry.rb
CHANGED
@@ -2,18 +2,44 @@ require_relative '../skipper'
|
|
2
2
|
require 'pry-byebug'
|
3
3
|
|
4
4
|
module Byebug::Skipper::Pry
|
5
|
-
|
6
|
-
|
5
|
+
COMMANDS = [
|
6
|
+
{
|
7
|
+
cmd: 'ups',
|
8
|
+
const_name: 'Ups',
|
9
|
+
continues?: false,
|
10
|
+
},
|
11
|
+
{
|
12
|
+
cmd: 'downs',
|
13
|
+
const_name: 'Downs',
|
14
|
+
continues?: false,
|
15
|
+
},
|
16
|
+
{
|
17
|
+
cmd: 'steps',
|
18
|
+
const_name: 'Steps',
|
19
|
+
continues?: true,
|
20
|
+
},
|
21
|
+
{
|
22
|
+
cmd: 'finishs',
|
23
|
+
const_name: 'Finishs',
|
24
|
+
continues?: true,
|
25
|
+
},
|
26
|
+
{
|
27
|
+
cmd: 'skip!',
|
28
|
+
const_name: 'SkipBang',
|
29
|
+
continues?: true,
|
30
|
+
},
|
31
|
+
].freeze
|
7
32
|
end
|
8
33
|
|
9
34
|
# All the Pry command classes are implemented the same
|
10
|
-
Byebug::Skipper::Pry::
|
11
|
-
|
35
|
+
Byebug::Skipper::Pry::COMMANDS.each do |command|
|
36
|
+
byebug_command_class = Byebug::Skipper.const_get("#{command.fetch(:const_name)}Command")
|
37
|
+
pry_command_class = Class.new(Pry::ClassCommand) do
|
12
38
|
include ::PryByebug::Helpers::Navigation
|
13
39
|
|
14
|
-
match
|
40
|
+
match command.fetch(:cmd)
|
15
41
|
group "Byebug Skipper"
|
16
|
-
description
|
42
|
+
description byebug_command_class.short_description
|
17
43
|
|
18
44
|
def process
|
19
45
|
PryByebug.check_file_context(target)
|
@@ -23,8 +49,8 @@ Byebug::Skipper::Pry::COMMAND_NAMES.each do |command_name|
|
|
23
49
|
end
|
24
50
|
end
|
25
51
|
|
26
|
-
Byebug::Skipper::Pry.const_set("#{
|
27
|
-
Pry::Commands.add_command(
|
52
|
+
Byebug::Skipper::Pry.const_set("#{command.fetch(:const_name)}Command", pry_command_class)
|
53
|
+
Pry::Commands.add_command(pry_command_class)
|
28
54
|
end
|
29
55
|
|
30
56
|
# This is a monkey patch for Byebug::PryProcessor in order to add extra Byebug
|
@@ -34,18 +60,17 @@ module Byebug::Skipper::Pry::ProcessorHacks
|
|
34
60
|
def perform(action, options = {})
|
35
61
|
# If it's not one of our commands, short circuit and use the typical
|
36
62
|
# behaviour.
|
37
|
-
|
63
|
+
command = Byebug::Skipper::Pry::COMMANDS.find { _1.fetch(:cmd) == action.to_s }
|
64
|
+
return super unless command
|
38
65
|
|
39
66
|
# Call the Byebug command objects directly. This seems kind of fragile to
|
40
67
|
# me, but I don't see any better options.
|
41
|
-
Byebug::Skipper.const_get("#{
|
42
|
-
.new(self,
|
68
|
+
Byebug::Skipper.const_get("#{command.fetch(:const_name)}Command")
|
69
|
+
.new(self, action.to_s)
|
43
70
|
.execute
|
44
71
|
|
45
|
-
|
46
|
-
|
47
|
-
resume_pry
|
48
|
-
end
|
72
|
+
# This shows the REPL again, preventing execution from continuing.
|
73
|
+
resume_pry unless command.fetch(:continues?)
|
49
74
|
end
|
50
75
|
end
|
51
76
|
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Byebug::Skipper
|
2
|
+
class SkipBangCommand < Byebug::SkipCommand
|
3
|
+
def self.regexp
|
4
|
+
/^ \s* skip! \s* $/x
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.short_description
|
8
|
+
"Same as `skip` but also comments out the line before the current one (where `byebug` or `binding.pry` usually is)"
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.description
|
12
|
+
short_description
|
13
|
+
end
|
14
|
+
|
15
|
+
def execute
|
16
|
+
CommentLineAbove.(context.location)
|
17
|
+
super
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: byebug-skipper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tom Dalling
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-06-
|
11
|
+
date: 2021-06-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: byebug
|
@@ -73,9 +73,11 @@ extensions: []
|
|
73
73
|
extra_rdoc_files: []
|
74
74
|
files:
|
75
75
|
- lib/byebug/skipper.rb
|
76
|
+
- lib/byebug/skipper/comment_line_above.rb
|
76
77
|
- lib/byebug/skipper/downs_command.rb
|
77
78
|
- lib/byebug/skipper/finishs_command.rb
|
78
79
|
- lib/byebug/skipper/pry.rb
|
80
|
+
- lib/byebug/skipper/skip_bang_command.rb
|
79
81
|
- lib/byebug/skipper/steps_command.rb
|
80
82
|
- lib/byebug/skipper/ups_command.rb
|
81
83
|
- lib/byebug/skipper/version.rb
|