syntax_search 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/syntax_search.rb +1 -0
- data/lib/syntax_search/code_block.rb +4 -0
- data/lib/syntax_search/code_search.rb +14 -2
- data/lib/syntax_search/display_invalid_blocks.rb +1 -1
- data/lib/syntax_search/heredoc_block_parse.rb +30 -0
- data/lib/syntax_search/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 77f054eda8b4e25dcaf0306818ae17bb1ff3da9c52f2d606141ff44cd343c51d
|
4
|
+
data.tar.gz: 44f4347d5078d0250286e78a08ff730b02094aeb05897c9088963381a95e9071
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ccc7e2ed620689614bdfae8943b8c15b81b4567d3b42e2c734ac7974699ed231272ce52929eff9d49eb25edd843ae3f7fa2398d0552b77665be779a4412461f
|
7
|
+
data.tar.gz: 1e866b4aaafb534f946da5e00efb50536a4d20bf0e1527f8641fb298cca5cc6b7d0e1f744f63da443b9920500d7d4ddf0113ffa8bde2b4689cd6793538a12b6e
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/syntax_search.rb
CHANGED
@@ -28,13 +28,14 @@ module SyntaxErrorSearch
|
|
28
28
|
private; attr_reader :frontier; public
|
29
29
|
public; attr_reader :invalid_blocks, :record_dir, :code_lines
|
30
30
|
|
31
|
-
def initialize(
|
31
|
+
def initialize(source, record_dir: ENV["SYNTAX_SEARCH_RECORD_DIR"])
|
32
|
+
@source = source
|
32
33
|
if record_dir
|
33
34
|
@time = Time.now.strftime('%Y-%m-%d-%H-%M-%s-%N')
|
34
35
|
@record_dir = Pathname(record_dir).join(@time).tap {|p| p.mkpath }
|
35
36
|
@write_count = 0
|
36
37
|
end
|
37
|
-
@code_lines =
|
38
|
+
@code_lines = source.lines.map.with_index do |line, i|
|
38
39
|
CodeLine.new(line: line, index: i)
|
39
40
|
end
|
40
41
|
@frontier = CodeFrontier.new(code_lines: @code_lines)
|
@@ -107,8 +108,19 @@ module SyntaxErrorSearch
|
|
107
108
|
push(block, name: "expand")
|
108
109
|
end
|
109
110
|
|
111
|
+
|
112
|
+
def sweep_heredocs
|
113
|
+
HeredocBlockParse.new(
|
114
|
+
source: @source,
|
115
|
+
code_lines: @code_lines
|
116
|
+
).call.each do |block|
|
117
|
+
push(block, name: "heredoc")
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
110
121
|
# Main search loop
|
111
122
|
def call
|
123
|
+
sweep_heredocs
|
112
124
|
until frontier.holds_all_syntax_errors?
|
113
125
|
@tick += 1
|
114
126
|
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module SyntaxErrorSearch
|
4
|
+
# Takes in a source, and returns blocks containing each heredoc
|
5
|
+
class HeredocBlockParse
|
6
|
+
private; attr_reader :code_lines, :lex; public
|
7
|
+
|
8
|
+
def initialize(source:, code_lines: )
|
9
|
+
@code_lines = code_lines
|
10
|
+
@lex = Ripper.lex(source)
|
11
|
+
end
|
12
|
+
|
13
|
+
def call
|
14
|
+
blocks = []
|
15
|
+
beginning = []
|
16
|
+
@lex.each do |(line, col), event, *_|
|
17
|
+
case event
|
18
|
+
when :on_heredoc_beg
|
19
|
+
beginning << line
|
20
|
+
when :on_heredoc_end
|
21
|
+
start_index = beginning.pop - 1
|
22
|
+
end_index = line - 1
|
23
|
+
blocks << CodeBlock.new(lines: code_lines[start_index..end_index])
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
blocks
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: syntax_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- schneems
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: When you get an "unexpected end" in your syntax this gem helps you find
|
14
14
|
it
|
@@ -45,6 +45,7 @@ files:
|
|
45
45
|
- lib/syntax_search/code_search.rb
|
46
46
|
- lib/syntax_search/display_invalid_blocks.rb
|
47
47
|
- lib/syntax_search/fyi.rb
|
48
|
+
- lib/syntax_search/heredoc_block_parse.rb
|
48
49
|
- lib/syntax_search/parse_blocks_from_indent_line.rb
|
49
50
|
- lib/syntax_search/version.rb
|
50
51
|
- lib/syntax_search/who_dis_syntax_error.rb
|
@@ -70,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
71
|
- !ruby/object:Gem::Version
|
71
72
|
version: '0'
|
72
73
|
requirements: []
|
73
|
-
rubygems_version: 3.
|
74
|
+
rubygems_version: 3.1.4
|
74
75
|
signing_key:
|
75
76
|
specification_version: 4
|
76
77
|
summary: Find syntax errors in your source in a snap
|