syntax_search 0.1.0 → 0.1.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +1 -1
- data/README.md +30 -24
- data/lib/syntax_search.rb +1 -1
- 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: 64d391c1ee60a9784b3b53ec9c404739b06dd390d263793795110cdc555bdfb0
|
4
|
+
data.tar.gz: 70cbe011308ad0c94c88240e5aadf4e7e024b0f83ff65377b99fe82550779ebc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 119be89600a50534968502162df65d972a4fe1ecd93a70378e843cbe22effbe0d3f4a7fb12761740efa95152d81bf3a30abc79401cfbff4ba8ad89e9b9390a47
|
7
|
+
data.tar.gz: aa93927ba70886754499d263087c89a546d2791b8de3911175e365d7aa111b1d8d659dd3ae015e8297b75b62b9c4e4958c8e9f6c08ac9a4d444f18ccdc7ad8fb
|
data/CHANGELOG.md
ADDED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -10,34 +10,32 @@ What happened? Likely you forgot a `def`, `do`, or maybe you deleted some code a
|
|
10
10
|
|
11
11
|
What if I told you, that there was a library that helped find your missing `def`s and missing `do`s. What if instead of searching through hundreds of lines of source for the cause of your syntax error, there was a way to highlight just code in the file that contained syntax errors.
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
```
|
34
|
-
```
|
13
|
+
$ syntax_search <path/to/file.rb>
|
14
|
+
|
15
|
+
SyntaxErrorSearch: A syntax error was detected
|
16
|
+
|
17
|
+
This code has an unmatched `end` this is caused by either
|
18
|
+
missing a syntax keyword (`def`, `do`, etc.) or inclusion
|
19
|
+
of an extra `end` line
|
20
|
+
|
21
|
+
file: path/to/file.rb
|
22
|
+
simplified:
|
23
|
+
|
24
|
+
```
|
25
|
+
1 require 'animals'
|
26
|
+
2
|
27
|
+
❯ 10 defdog
|
28
|
+
❯ 15 end
|
29
|
+
❯ 16
|
30
|
+
20 def cat
|
31
|
+
22 end
|
32
|
+
```
|
35
33
|
|
36
34
|
How much would you pay for such a library? A million, a billion, a trillion? Well friends, today is your lucky day because you can use this library today for free!
|
37
35
|
|
38
36
|
## Installation
|
39
37
|
|
40
|
-
|
38
|
+
To automatically search syntax errors when they happen, add this to your Gemfile:
|
41
39
|
|
42
40
|
```ruby
|
43
41
|
gem 'syntax_search', require: "syntax_search/auto"
|
@@ -47,10 +45,18 @@ And then execute:
|
|
47
45
|
|
48
46
|
$ bundle install
|
49
47
|
|
50
|
-
|
48
|
+
If your application is not calling `Bundler.require` then you must manually add a require:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
require "syntax_search/auto"
|
52
|
+
```
|
53
|
+
|
54
|
+
To get the CLI and manually search for syntax errors, install the gem:
|
51
55
|
|
52
56
|
$ gem install syntax_search
|
53
57
|
|
58
|
+
This gives you the CLI command `$ syntax_search` for more info run `$ syntax_search --help`.
|
59
|
+
|
54
60
|
## What does it do?
|
55
61
|
|
56
62
|
When your code triggers a SyntaxError due to an "unexpected `end'" in a file, this library fires to narrow down your search to the most likely offending locations.
|
data/lib/syntax_search.rb
CHANGED
@@ -12,7 +12,7 @@ module SyntaxErrorSearch
|
|
12
12
|
SEARCH_SOURCE_ON_ERROR_DEFAULT = true
|
13
13
|
|
14
14
|
def self.handle_error(e, search_source_on_error: SEARCH_SOURCE_ON_ERROR_DEFAULT)
|
15
|
-
raise e if !e.message.include?("
|
15
|
+
raise e if !e.message.include?("end-of-input")
|
16
16
|
|
17
17
|
filename = e.message.split(":").first
|
18
18
|
|
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.1
|
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-
|
11
|
+
date: 2020-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -37,6 +37,7 @@ files:
|
|
37
37
|
- ".gitignore"
|
38
38
|
- ".rspec"
|
39
39
|
- ".travis.yml"
|
40
|
+
- CHANGELOG.md
|
40
41
|
- CODE_OF_CONDUCT.md
|
41
42
|
- Gemfile
|
42
43
|
- Gemfile.lock
|
@@ -77,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
78
|
- !ruby/object:Gem::Version
|
78
79
|
version: '0'
|
79
80
|
requirements: []
|
80
|
-
rubygems_version: 3.
|
81
|
+
rubygems_version: 3.1.4
|
81
82
|
signing_key:
|
82
83
|
specification_version: 4
|
83
84
|
summary: Find syntax errors in your source in a snap
|