syntax_search 0.2.0 → 0.2.1

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,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SyntaxErrorSearch
4
- VERSION = "0.2.0"
5
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module SyntaxErrorSearch
4
- # Determines what type of syntax error is in the source
5
- #
6
- # Example:
7
- #
8
- # puts WhoDisSyntaxError.new("def foo;").call.error_symbol
9
- # # => :missing_end
10
- class WhoDisSyntaxError < Ripper
11
- attr_reader :error, :run_once, :error_symbol
12
-
13
- def call
14
- @run_once ||= begin
15
- parse
16
- true
17
- end
18
- self
19
- end
20
-
21
- def on_parse_error(msg)
22
- @error = msg
23
- if @error.match?(/unexpected end-of-input/)
24
- @error_symbol = :missing_end
25
- elsif @error.match?(/unexpected `end'/) || @error.match?(/expecting end-of-input/)
26
- @error_symbol = :unmatched_end
27
- else
28
- @error_symbol = :nope
29
- end
30
- end
31
- end
32
- end