syntax_suggest 1.0.1 → 1.0.2

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: 7f8b41fd2cbb19ed9ce0553b53e88f29de1a0ae46e7ffbd0de1d9bf1b881a9a5
4
- data.tar.gz: c0787c1da43c9e19ca97e8fd616360c188946e996c283aa8c0b4c187dd2a66ec
3
+ metadata.gz: f3c694e7b419ea1a715d2cccf55e706be86035c2563e2f4506769da76829a65a
4
+ data.tar.gz: a42f42ceb34fc29e0534072cc25e27e7b416c7a954ec6ccdc75c5748db491e22
5
5
  SHA512:
6
- metadata.gz: 9ed334240baa6233e259756bd4e532638fb7796e5fc3f671a3c31bb8c01a508d1418fe62380f3c5db9bb1568395b2686ab9fb56c4badcace009b91d92c2cbded
7
- data.tar.gz: 5fa487311079e5000a2bbfb8216e855983c816668657e7f4fbca4fe2e79370e6c00e1665d4230879ca59c2ec4c9476a387c2295aa1b13d259d41446ae84c8629
6
+ metadata.gz: 755b4e3e2a5bb86ae61b4f29417a0a4f6531dbe5866ce32d56e0cb2452496fb858469bbeb3aa369ca953814e475cb52e93c2273eb54ec203cff98520d10bac07
7
+ data.tar.gz: 178a7ecd8a04d8f53f1778a331400273a2980f42451942012c3e98d5171ab30c590e76eaf69b6c78d7c63274f8040cce2e4e4f85ad35601c34fe46149420aa44
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: 'github-actions'
4
+ directory: '/'
5
+ schedule:
6
+ interval: 'weekly'
@@ -13,7 +13,7 @@ jobs:
13
13
  !contains(github.event.pull_request.body, '[skip ci]') &&
14
14
  !contains(github.event.pull_request.labels.*.name, 'skip changelog')
15
15
  steps:
16
- - uses: actions/checkout@v2.3.5
16
+ - uses: actions/checkout@v3.2.0
17
17
  - name: Check that CHANGELOG is touched
18
18
  run: |
19
19
  git fetch origin ${{ github.base_ref }} --depth 1 && \
@@ -9,7 +9,7 @@ jobs:
9
9
  runs-on: ubuntu-latest
10
10
  steps:
11
11
  - name: Checkout code
12
- uses: actions/checkout@v3
12
+ uses: actions/checkout@v3.2.0
13
13
  - name: Set up Ruby
14
14
  uses: ruby/setup-ruby@v1
15
15
  with:
@@ -29,11 +29,11 @@ jobs:
29
29
  - 2.7
30
30
  - '3.0'
31
31
  - 3.1
32
- - "3.2.0-preview1"
32
+ - "3.2.0-rc1"
33
33
  - head
34
34
  steps:
35
35
  - name: Checkout code
36
- uses: actions/checkout@v3
36
+ uses: actions/checkout@v3.2.0
37
37
  - name: Set up Ruby
38
38
  uses: ruby/setup-ruby@v1
39
39
  with:
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  ## HEAD (unreleased)
2
2
 
3
+ ## 1.0.2
4
+
5
+ - Drop support or Ruby 3.2.0 preview, now that 3.2.0-rc1 is available (https://github.com/ruby/syntax_suggest/pull/165)
6
+ - Native support of `SyntaxError#path`, support 3.2.0-preview3 will be dropped with the release of 3.2.0-preview4 (https://github.com/ruby/syntax_suggest/pull/164)
7
+ - Added dependabot for GitHub Actions (https://github.com/ruby/syntax_suggest/pull/160)
8
+
3
9
  ## 1.0.1
4
10
 
5
11
  - Replace `❯` with `>` in error output for compatability with more fonts (https://github.com/ruby/syntax_suggest/pull/161)
@@ -3,6 +3,10 @@
3
3
  # Ruby 3.2+ has a cleaner way to hook into Ruby that doesn't use `require`
4
4
  if SyntaxError.method_defined?(:detailed_message)
5
5
  module SyntaxSuggest
6
+ # Mini String IO [Private]
7
+ #
8
+ # Acts like a StringIO with reduced API, but without having to require that
9
+ # class.
6
10
  class MiniStringIO
7
11
  def initialize(isatty: $stderr.isatty)
8
12
  @string = +""
@@ -16,46 +20,49 @@ if SyntaxError.method_defined?(:detailed_message)
16
20
 
17
21
  attr_reader :string
18
22
  end
19
- end
20
-
21
- SyntaxError.prepend Module.new {
22
- def detailed_message(highlight: true, syntax_suggest: true, **kwargs)
23
- return super unless syntax_suggest
24
-
25
- require "syntax_suggest/api" unless defined?(SyntaxSuggest::DEFAULT_VALUE)
26
-
27
- message = super
28
- file = if highlight
29
- SyntaxSuggest::PathnameFromMessage.new(super(highlight: false, **kwargs)).call.name
30
- else
31
- SyntaxSuggest::PathnameFromMessage.new(message).call.name
32
- end
33
-
34
- io = SyntaxSuggest::MiniStringIO.new
35
23
 
36
- if file
37
- SyntaxSuggest.call(
38
- io: io,
39
- source: file.read,
40
- filename: file,
41
- terminal: highlight
42
- )
43
- annotation = io.string
44
-
45
- annotation + message
46
- else
47
- message
48
- end
49
- rescue => e
50
- if ENV["SYNTAX_SUGGEST_DEBUG"]
51
- $stderr.warn(e.message)
52
- $stderr.warn(e.backtrace)
53
- end
54
-
55
- # Ignore internal errors
56
- message
24
+ # SyntaxSuggest.record_dir [Private]
25
+ #
26
+ # Used to monkeypatch SyntaxError via Module.prepend
27
+ def self.module_for_detailed_message
28
+ Module.new {
29
+ def detailed_message(highlight: true, syntax_suggest: true, **kwargs)
30
+ return super unless syntax_suggest
31
+
32
+ require "syntax_suggest/api" unless defined?(SyntaxSuggest::DEFAULT_VALUE)
33
+
34
+ message = super
35
+
36
+ if path
37
+ file = Pathname.new(path)
38
+ io = SyntaxSuggest::MiniStringIO.new
39
+
40
+ SyntaxSuggest.call(
41
+ io: io,
42
+ source: file.read,
43
+ filename: file,
44
+ terminal: highlight
45
+ )
46
+ annotation = io.string
47
+
48
+ annotation + message
49
+ else
50
+ message
51
+ end
52
+ rescue => e
53
+ if ENV["SYNTAX_SUGGEST_DEBUG"]
54
+ $stderr.warn(e.message)
55
+ $stderr.warn(e.backtrace)
56
+ end
57
+
58
+ # Ignore internal errors
59
+ message
60
+ end
61
+ }
57
62
  end
58
- }
63
+ end
64
+
65
+ SyntaxError.prepend(SyntaxSuggest.module_for_detailed_message)
59
66
  else
60
67
  autoload :Pathname, "pathname"
61
68
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SyntaxSuggest
4
- VERSION = "1.0.1"
4
+ VERSION = "1.0.2"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syntax_suggest
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - schneems
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-11-29 00:00:00.000000000 Z
11
+ date: 2022-12-20 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
@@ -19,6 +19,7 @@ executables:
19
19
  extensions: []
20
20
  extra_rdoc_files: []
21
21
  files:
22
+ - ".github/dependabot.yml"
22
23
  - ".github/workflows/check_changelog.yml"
23
24
  - ".github/workflows/ci.yml"
24
25
  - ".gitignore"
@@ -81,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
82
  - !ruby/object:Gem::Version
82
83
  version: '0'
83
84
  requirements: []
84
- rubygems_version: 3.3.7
85
+ rubygems_version: 3.4.0.dev
85
86
  signing_key:
86
87
  specification_version: 4
87
88
  summary: Find syntax errors in your source in a snap