dead_end 1.1.1 → 1.1.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4690f965eeee0b3f75ce6d3f27360a73639a3cb918ee77fafb77c559e278a035
4
- data.tar.gz: 95ea085f4a5cf1f8b5882b717fe5f6c08fac7ab97568c9c3022632a52988351e
3
+ metadata.gz: ac6f2a5183bb09317d83211f3b1f7049154011ae0fbd73f08152864303a763bd
4
+ data.tar.gz: b6ea7a79863ffcc8664f3b693fabe49635f17fa48ed8e4529eeb48de9808b9c2
5
5
  SHA512:
6
- metadata.gz: be19b5b8999599b226de6f0c511d91ce091867b67b30c8e9c5e56b0c3c06ac78c229b1c08823921c0fc461977e2e08d4fb6c2a8d4a796c47d0410ee84ac82da0
7
- data.tar.gz: 3c5254b82d3f6e17cbd3012f4b82c2f9ae0df533f521c41eeea08e14ff5e8b8c6fdd17a6aa4b40b655437510d10f9f059df611b8c4496558230741cec7812f15
6
+ metadata.gz: a5b1524a4a5844d932dfdbd7874b81c43fbe4a98ac30ee4258e8eaefbf33a98d470a96721ce7ee0ec8e61e5f3ce525dabecde40b3900f5e5b8964b71676d49df
7
+ data.tar.gz: f9c2bf9a500f3428627a4de15af3e7d75ce0446e2042f68b39ab27a97da0c60171b7449241a60b358c8d5045c46f65a3bab3ed1d11cd4881eb5c8da06414d5ba
data/.circleci/config.yml CHANGED
@@ -32,6 +32,14 @@ jobs:
32
32
  - ruby/install-deps
33
33
  - <<: *unit
34
34
 
35
+ "ruby-3-0":
36
+ docker:
37
+ - image: circleci/ruby:3.0
38
+ steps:
39
+ - checkout
40
+ - ruby/install-deps
41
+ - <<: *unit
42
+
35
43
  workflows:
36
44
  version: 2
37
45
  build:
@@ -39,3 +47,4 @@ workflows:
39
47
  - "ruby-2-5"
40
48
  - "ruby-2-6"
41
49
  - "ruby-2-7"
50
+ - "ruby-3-0"
data/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  ## HEAD (unreleased)
2
2
 
3
+ ## 1.1.6
4
+
5
+ - Consider if syntax error caused an unexpected variable instead of end (https://github.com/zombocom/dead_end/pull/58)
6
+
7
+ ## 1.1.5
8
+
9
+ - Parse error once and not twice if there's more than one available (https://github.com/zombocom/dead_end/pull/57)
10
+
11
+ ## 1.1.4
12
+
13
+ - Avoid including demo gif in built gem (https://github.com/zombocom/dead_end/pull/53)
14
+
15
+ ## 1.1.3
16
+
17
+ - Add compatibility with zeitwerk (https://github.com/zombocom/dead_end/pull/52)
18
+
19
+ ## 1.1.2
20
+
21
+ - Namespace Kernel method aliases (https://github.com/zombocom/dead_end/pull/51)
22
+
3
23
  ## 1.1.1
4
24
 
5
25
  - Safer NoMethodError annotation (https://github.com/zombocom/dead_end/pull/48)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dead_end (1.1.1)
4
+ dead_end (1.1.6)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -33,4 +33,4 @@ DEPENDENCIES
33
33
  stackprof
34
34
 
35
35
  BUNDLED WITH
36
- 2.2.3
36
+ 2.2.11
data/dead_end.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  # Specify which files should be added to the gem when it is released.
21
21
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
22
  spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
23
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|assets)/}) }
24
24
  end
25
25
  spec.bindir = "exe"
26
26
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
data/lib/dead_end/auto.rb CHANGED
@@ -5,27 +5,29 @@ require_relative "../dead_end/internals"
5
5
  # Monkey patch kernel to ensure that all `require` calls call the same
6
6
  # method
7
7
  module Kernel
8
- alias_method :original_require, :require
9
- alias_method :original_require_relative, :require_relative
10
- alias_method :original_load, :load
8
+ module_function
9
+
10
+ alias_method :dead_end_original_require, :require
11
+ alias_method :dead_end_original_require_relative, :require_relative
12
+ alias_method :dead_end_original_load, :load
11
13
 
12
14
  def load(file, wrap = false)
13
- original_load(file)
15
+ dead_end_original_load(file)
14
16
  rescue SyntaxError => e
15
17
  DeadEnd.handle_error(e)
16
18
  end
17
19
 
18
20
  def require(file)
19
- original_require(file)
21
+ dead_end_original_require(file)
20
22
  rescue SyntaxError => e
21
23
  DeadEnd.handle_error(e)
22
24
  end
23
25
 
24
26
  def require_relative(file)
25
27
  if Pathname.new(file).absolute?
26
- original_require file
28
+ dead_end_original_require file
27
29
  else
28
- original_require File.expand_path("../#{file}", caller_locations(1, 1)[0].absolute_path)
30
+ dead_end_original_require File.expand_path("../#{file}", caller_locations(1, 1)[0].absolute_path)
29
31
  end
30
32
  rescue SyntaxError => e
31
33
  DeadEnd.handle_error(e)
@@ -62,7 +64,7 @@ end
62
64
  # we can attempt to disable this behavior in a production context.
63
65
  if !DeadEnd::IsProduction.call
64
66
  class NoMethodError
65
- alias :original_to_s :to_s
67
+ alias :dead_end_original_to_s :to_s
66
68
 
67
69
  def to_s
68
70
  return super if DeadEnd::IsProduction.call
@@ -93,7 +95,7 @@ if !DeadEnd::IsProduction.call
93
95
  message << $/
94
96
  message
95
97
  rescue => e
96
- puts "DeadEnd Internal error: #{e.original_to_s}"
98
+ puts "DeadEnd Internal error: #{e.dead_end_original_to_s}"
97
99
  puts "DeadEnd Internal backtrace:"
98
100
  puts backtrace.map {|l| " " + l }.join($/)
99
101
  super
@@ -82,7 +82,7 @@ module DeadEnd
82
82
  closed: `{ }`.
83
83
  EOM
84
84
  else
85
- "DeadEnd: Unmatched #{@invalid_obj.unmatched_symbol}` detected"
85
+ "DeadEnd: Unmatched `#{@invalid_obj.unmatched_symbol}` detected"
86
86
  end
87
87
  end
88
88
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DeadEnd
4
- VERSION = "1.1.1"
4
+ VERSION = "1.1.6"
5
5
  end
@@ -42,22 +42,25 @@ module DeadEnd
42
42
  end
43
43
 
44
44
  def on_parse_error(msg)
45
+ return if @error_symbol && @unmatched_symbol
46
+
45
47
  @error = msg
46
48
  @unmatched_symbol = :unknown
47
49
 
48
- if @error.match?(/unexpected end-of-input/)
50
+ case @error
51
+ when /unexpected end-of-input/
49
52
  @error_symbol = :missing_end
50
- elsif @error.match?(/expecting end-of-input/)
51
- @error_symbol = :unmatched_syntax
53
+ when /expecting end-of-input/
52
54
  @unmatched_symbol = :end
53
- elsif @error.match?(/unexpected `end'/) || # Ruby 2.7 & 3.0
54
- @error.match?(/unexpected end,/) || # Ruby 2.6
55
- @error.match?(/unexpected keyword_end/) # Ruby 2.5
56
-
57
55
  @error_symbol = :unmatched_syntax
56
+ when /unexpected .* expecting '(?<unmatched_symbol>.*)'/
57
+ @unmatched_symbol = $1.to_sym if $1
58
+ @error_symbol = :unmatched_syntax
59
+ when /unexpected `end'/, # Ruby 2.7 and 3.0
60
+ /unexpected end/, # Ruby 2.6
61
+ /unexpected keyword_end/i # Ruby 2.5
58
62
 
59
- match = @error.match(/expecting '(?<unmatched_symbol>.*)'/)
60
- @unmatched_symbol = match[:unmatched_symbol].to_sym if match
63
+ @error_symbol = :unmatched_syntax
61
64
  else
62
65
  @error_symbol = :unknown
63
66
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dead_end
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - schneems
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-30 00:00:00.000000000 Z
11
+ date: 2021-02-25 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
@@ -31,7 +31,6 @@ files:
31
31
  - LICENSE.txt
32
32
  - README.md
33
33
  - Rakefile
34
- - assets/syntax_search.gif
35
34
  - bin/console
36
35
  - bin/setup
37
36
  - dead_end.gemspec
Binary file