dead_end 1.2.0 → 2.0.0

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.
@@ -1,53 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module DeadEnd
4
- # Handles code that contains trailing slashes
5
- # by turning multiple lines with trailing slash(es) into
6
- # a single code line
7
- #
8
- # expect(code_lines.join).to eq(<<~EOM)
9
- # it "trailing \
10
- # "slash" do
11
- # end
12
- # EOM
13
- #
14
- # lines = TrailngSlashJoin(code_lines: code_lines).call
15
- # expect(lines.first.to_s).to eq(<<~EOM)
16
- # it "trailing \
17
- # "slash" do
18
- # EOM
19
- #
20
- class TrailingSlashJoin
21
- def initialize(code_lines:)
22
- @code_lines = code_lines
23
- @code_lines_dup = code_lines.dup
24
- end
25
-
26
- def call
27
- @trailing_lines = []
28
- @code_lines.select(&:trailing_slash?).each do |trailing|
29
- stop_next = false
30
- lines = @code_lines[trailing.index..].take_while do |line|
31
- next false if stop_next
32
-
33
- if !line.trailing_slash?
34
- stop_next = true
35
- end
36
-
37
- true
38
- end
39
-
40
- joined_line = CodeLine.new(line: lines.map(&:original_line).join, index: trailing.index)
41
-
42
- @code_lines_dup[trailing.index] = joined_line
43
-
44
- @trailing_lines << joined_line
45
-
46
- lines.shift # Don't hide first trailing slash line
47
- lines.each(&:mark_invisible)
48
- end
49
-
50
- @code_lines_dup
51
- end
52
- end
53
- end