Skip to content

Commit

Permalink
# This is a combination of 2 commits.
Browse files Browse the repository at this point in the history
# This is the 1st commit message:

Fix "unexpected end" detection on Ruby 2.7

I'm not sure why the tests didn't catch this:

```
  /Users/rschneeman/Documents/projects/work/minimal-ruby/spec/unit/toml_spec.rb:18: syntax error, unexpected end-of-input, expecting `end'
```
  • Loading branch information
schneems committed Nov 11, 2020
1 parent 33b7763 commit 4646188
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## HEAD (unreleased)

## 0.1.1

- Fix error message detection to fire on more rubies ()

## 0.1.0

- Initial release
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
syntax_search (0.1.0)
syntax_search (0.1.1)
parser

GEM
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,18 @@ And then execute:

$ bundle install

If your application is not calling `Bundler.require` then you must manually add a require:

```ruby
require "syntax_search/auto"
```

To get the CLI and manually search for syntax errors, install the gem:

$ gem install syntax_search

This gives you the CLI command `$ syntax_search` for more info run `$ syntax_search --help`.

## What does it do?

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.
Expand Down
2 changes: 1 addition & 1 deletion lib/syntax_search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Error < StandardError; end
SEARCH_SOURCE_ON_ERROR_DEFAULT = true

def self.handle_error(e, search_source_on_error: SEARCH_SOURCE_ON_ERROR_DEFAULT)
raise e if !e.message.include?("expecting end-of-input")
raise e if !e.message.include?("end-of-input")

filename = e.message.split(":").first

Expand Down
2 changes: 1 addition & 1 deletion lib/syntax_search/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module SyntaxErrorSearch
VERSION = "0.1.0"
VERSION = "0.1.1"
end

0 comments on commit 4646188

Please sign in to comment.