dead_end 1.1.0 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b372fd8bb6cb9f7b3a601fcb32a539ae361fa19e3f64471d6c446564532750c
4
- data.tar.gz: fc78d6a4ff9f86663af64dc6acf1bf2a0bced8fded065a2e0b52210e19766496
3
+ metadata.gz: 8e2b1b2c93acbc5dde38ac7da8fc9dee057389e676bde9eb95683395b6b78ad8
4
+ data.tar.gz: 0ef003bc94de8db02a1a0573bc77a0045b63207c6dd24557ec8f7b9dc76383f0
5
5
  SHA512:
6
- metadata.gz: 5ee131a4f8574bec7a8e9054b4085524cf49692afeb40387144f9461f34323b533944b1c9683b0772c43858ed348fb6eb889ae89ecfb765b0c26b805e93dee4c
7
- data.tar.gz: bffe41e67a11e342ad5db8a36b7faa81c1ea24eab2a37bb67c77762cd0be470f12cc55b8baf9e9696e2ed321943eed348328b637220102d2e9e1678c17ef3d18
6
+ metadata.gz: 8a6f4849d79629110326aba138ab290ca0bdc9eedf427b13b21ed1cbae084be28d017bf20644684552dbb660bd9547b514951eb909cc894304d25db8b020310b
7
+ data.tar.gz: 8f1056255fa656d206e1e2b4160b903b6d88d60043f150e1fbf943a852901488e52e0819fd29bb059109ff015e01a7167688010733d49b81057bb62d2d000bd0
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.5
4
+
5
+ - Source code with multiple syntax errors will be indentified by their first syntax error (https://github.com/zombocom/dead_end/pull/57)
6
+
7
+ ## 1.1.4
8
+
9
+ - Avoid including demo gif in built gem (https://github.com/zombocom/dead_end/pull/53)
10
+
11
+ ## 1.1.3
12
+
13
+ - Add compatibility with zeitwerk (https://github.com/zombocom/dead_end/pull/52)
14
+
15
+ ## 1.1.2
16
+
17
+ - Namespace Kernel method aliases (https://github.com/zombocom/dead_end/pull/51)
18
+
19
+ ## 1.1.1
20
+
21
+ - Safer NoMethodError annotation (https://github.com/zombocom/dead_end/pull/48)
22
+
3
23
  ## 1.1.0
4
24
 
5
25
  - Annotate NoMethodError in non-production environments (https://github.com/zombocom/dead_end/pull/46)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dead_end (1.1.0)
4
+ dead_end (1.1.5)
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.1.4
36
+ 2.2.9
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,6 +64,8 @@ end
62
64
  # we can attempt to disable this behavior in a production context.
63
65
  if !DeadEnd::IsProduction.call
64
66
  class NoMethodError
67
+ alias :dead_end_original_to_s :to_s
68
+
65
69
  def to_s
66
70
  return super if DeadEnd::IsProduction.call
67
71
 
@@ -91,8 +95,9 @@ if !DeadEnd::IsProduction.call
91
95
  message << $/
92
96
  message
93
97
  rescue => e
94
- puts "DeadEnd Internal error: #{e.message}"
95
- puts "DeadEnd Internal backtrace: #{e.backtrace}"
98
+ puts "DeadEnd Internal error: #{e.dead_end_original_to_s}"
99
+ puts "DeadEnd Internal backtrace:"
100
+ puts backtrace.map {|l| " " + l }.join($/)
96
101
  super
97
102
  end
98
103
  end
@@ -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.0"
4
+ VERSION = "1.1.5"
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/)
53
+ when /expecting end-of-input/
51
54
  @error_symbol = :unmatched_syntax
52
55
  @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
- @error_symbol = :unmatched_syntax
56
+ when /unexpected `end'/, # Ruby 2.7 and 3.0
57
+ /unexpected end/, # Ruby 2.6
58
+ /unexpected keyword_end/i # Ruby 2.5
58
59
 
59
60
  match = @error.match(/expecting '(?<unmatched_symbol>.*)'/)
60
61
  @unmatched_symbol = match[:unmatched_symbol].to_sym if match
62
+
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.0
4
+ version: 1.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-12-29 00:00:00.000000000 Z
11
+ date: 2021-02-11 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
@@ -76,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
75
  - !ruby/object:Gem::Version
77
76
  version: '0'
78
77
  requirements: []
79
- rubygems_version: 3.1.4
78
+ rubygems_version: 3.2.3
80
79
  signing_key:
81
80
  specification_version: 4
82
81
  summary: Find syntax errors in your source in a snap
Binary file