synvert-core 2.0.2 → 2.0.3

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: 666eb48f4d58bd41854a7f48e9aadf201321023f546b5682abe21e56ed80a204
4
- data.tar.gz: b6a555693e36b13806d156761a7003e06a6be8104c6102fd11ac5e920a687dd2
3
+ metadata.gz: fce0541de0c11b2a281d837c23669ea6fbe768f53b551549e1693119be907a1b
4
+ data.tar.gz: 413625544e125e8d9ec114e6dbe1021d2ca46969b319b56037a2fad4a5ba1c45
5
5
  SHA512:
6
- metadata.gz: 24b42ba9dd6ba2e16fc4218fbae4f333d8ac193fa4c58de8781836f4b3c7189a342a15088364071b52edf955365f0920bc4773d62f7d36e88c69b50e03f6df60
7
- data.tar.gz: '081411c60033db6c980fe7204e0e7dde12c7110a5839c545bb59943e3da3e881a0f505cc521284f6753e8f34d47319a9e1bc582126ea27cf82e4b696b170ce3f'
6
+ metadata.gz: 2695eb816b145e15644104da335f58d7038ed698f998348e35f23c0e42a0c3e119bc1feefc2cc12875d4dc26e3b9dbccd468c61e117f8e5dbd1efdebb2f95fea
7
+ data.tar.gz: fe5d4072638d277b8eedbf488540bd85632118721c2092f9c6117a41f7a761e70d21a9652a7f8fd007f260885ef9930dfd9000d295f6733dc3fda73925c29aee
@@ -1,5 +1,21 @@
1
1
  {
2
2
  "cSpell.words": [
3
- "synvert"
3
+ "asgn",
4
+ "autoindent",
5
+ "blockarg",
6
+ "casgn",
7
+ "csend",
8
+ "cvar",
9
+ "erange",
10
+ "fileutils",
11
+ "haml",
12
+ "ivar",
13
+ "lvar",
14
+ "mlhs",
15
+ "restarg",
16
+ "rvmrc",
17
+ "synvert",
18
+ "Yardoc",
19
+ "zsuper"
4
20
  ]
5
21
  }
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 2.0.3 (2024-06-16)
4
+
5
+ * Fix `gem_spec_spec` test failures
6
+ * Use `NodeMutation` to fetch file line
7
+
3
8
  ## 2.0.2 (2024-05-30)
4
9
 
5
10
  * Do not raise error for prism
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- synvert-core (2.0.2)
4
+ synvert-core (2.0.3)
5
5
  activesupport
6
6
  node_mutation (>= 1.24.4)
7
7
  node_query (>= 1.15.3)
@@ -17,7 +17,7 @@ PATH
17
17
  GEM
18
18
  remote: https://rubygems.org/
19
19
  specs:
20
- activesupport (7.1.3.3)
20
+ activesupport (7.1.3.4)
21
21
  base64
22
22
  bigdecimal
23
23
  concurrent-ruby (~> 1.0, >= 1.0.2)
@@ -31,7 +31,7 @@ GEM
31
31
  base64 (0.2.0)
32
32
  bigdecimal (3.1.8)
33
33
  coderay (1.1.3)
34
- concurrent-ruby (1.3.1)
34
+ concurrent-ruby (1.3.3)
35
35
  connection_pool (2.4.1)
36
36
  diff-lcs (1.5.1)
37
37
  drb (2.2.1)
@@ -68,14 +68,14 @@ GEM
68
68
  notiffany (0.1.3)
69
69
  nenv (~> 0.1)
70
70
  shellany (~> 0.0)
71
- parallel (1.24.0)
72
- parser (3.3.1.0)
71
+ parallel (1.25.1)
72
+ parser (3.3.3.0)
73
73
  ast (~> 2.4.1)
74
74
  racc
75
75
  parser_node_ext (1.3.2)
76
76
  parser
77
77
  prettier_print (1.2.1)
78
- prism (0.29.0)
78
+ prism (0.30.0)
79
79
  prism_ext (0.3.2)
80
80
  prism
81
81
  pry (0.14.2)
@@ -436,7 +436,8 @@ module Synvert::Core
436
436
  # end
437
437
  # @param message [String] warning message.
438
438
  def warn(message)
439
- @rewriter.add_warning Rewriter::Warning.new(self, message)
439
+ line = @current_mutation.adapter.get_start_loc(@current_node).line
440
+ @rewriter.add_warning Rewriter::Warning.new(@file_path, line, message)
440
441
  end
441
442
 
442
443
  # It adds a callback when visiting an ast node.
@@ -5,11 +5,12 @@ module Synvert::Core
5
5
  class Rewriter::Warning
6
6
  # Initialize a Warning.
7
7
  #
8
- # @param instance [Synvert::Core::Rewriter::Instance]
8
+ # @param file_path [String] file path.
9
+ # @param line [Integer] file line.
9
10
  # @param message [String] warning message.
10
- def initialize(instance, message)
11
- @file_path = instance.file_path
12
- @line = instance.current_node.loc.expression.line
11
+ def initialize(file_path, line, message)
12
+ @file_path = file_path
13
+ @line = line
13
14
  @message = message
14
15
  end
15
16
 
@@ -201,7 +201,7 @@ module Synvert::Core
201
201
  # @option strategy [String] 'allow_insert_at_same_position'
202
202
  def configure(options)
203
203
  @options = @options.merge(options)
204
- if options[:parser] && ![Synvert::PARSER_PARSER, Synvert::SYNTAX_TREE_PARSER, Synvert::PRISM_PARSER].include?(options[:parser])
204
+ if options[:parser] && !Synvert::ALL_PARSERS.include?(options[:parser])
205
205
  raise Errors::ParserNotSupported.new("Parser #{options[:parser]} not supported")
206
206
  end
207
207
  end
@@ -40,7 +40,7 @@ module Synvert::Core
40
40
  ignored_files = []
41
41
 
42
42
  if Configuration.respect_gitignore
43
- Open3.popen3('git check-ignore --stdin') do |stdin, stdout, stderr, wait_thr|
43
+ Open3.popen3('git check-ignore --stdin') do |stdin, stdout, _stderr, _wait_thr|
44
44
  stdin.puts(all_files.join("\n"))
45
45
  stdin.close
46
46
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Synvert
4
4
  module Core
5
- VERSION = '2.0.2'
5
+ VERSION = '2.0.3'
6
6
  end
7
7
  end
data/lib/synvert/core.rb CHANGED
@@ -77,4 +77,5 @@ module Synvert
77
77
  PARSER_PARSER = 'parser'
78
78
  SYNTAX_TREE_PARSER = 'syntax_tree'
79
79
  PRISM_PARSER = 'prism'
80
+ ALL_PARSERS = [PARSER_PARSER, SYNTAX_TREE_PARSER, PRISM_PARSER].freeze
80
81
  end
@@ -16,7 +16,17 @@ module Synvert::Core
16
16
  slop (3.4.7)
17
17
  EOS
18
18
  let(:lock_path) { File.absolute_path('./Gemfile.lock') }
19
- before { allow(File).to receive(:exist?).with(File.join(ENV['HOME'], '.gem/specs')).and_return(false) }
19
+
20
+ before do
21
+ Configuration.root_path = File.dirname(lock_path)
22
+ allow(File).to receive(:exist?).with(File.join(ENV['HOME'])).and_return(true)
23
+ allow(File).to receive(:exist?).with(File.join(ENV['HOME'], '.gem')).and_return(false)
24
+ allow(File).to receive(:exist?).with(File.join(ENV['HOME'], '.gem/specs')).and_return(false)
25
+ end
26
+
27
+ after do
28
+ Configuration.root_path = nil
29
+ end
20
30
 
21
31
  it 'returns true if version in Gemfile.lock is greater than definition' do
22
32
  expect(File).to receive(:exist?).with(lock_path).and_return(true)
@@ -260,7 +260,9 @@ module Synvert::Core
260
260
  end
261
261
 
262
262
  it 'parses warn' do
263
- expect(Rewriter::Warning).to receive(:new).with(instance, 'foobar')
263
+ instance.instance_variable_set(:@file_path, 'app/test.rb')
264
+ expect(@current_mutation).to receive_message_chain(:adapter, :get_start_loc, :line).and_return(2)
265
+ expect(Rewriter::Warning).to receive(:new).with('app/test.rb', 2, 'foobar')
264
266
  instance.warn 'foobar'
265
267
  end
266
268
 
@@ -549,10 +551,6 @@ module Synvert::Core
549
551
  = form_for @post do |f|
550
552
  = form_for @post do |f|
551
553
  EOS
552
- output = <<~EOS
553
- = form_for post do |f|
554
- = form_for post do |f|
555
- EOS
556
554
  allow(File).to receive(:read).with('./app/views/posts/_form.html.haml', encoding: 'UTF-8').and_return(input)
557
555
  result = instance.test
558
556
  expect(result.file_path).to eq 'app/views/posts/_form.html.haml'
@@ -578,10 +576,6 @@ module Synvert::Core
578
576
  = form_for @post do |f|
579
577
  = form_for @post do |f|
580
578
  EOS
581
- output = <<~EOS
582
- = form_for post do |f|
583
- = form_for post do |f|
584
- EOS
585
579
  allow(File).to receive(:read).with('./app/views/posts/_form.html.slim', encoding: 'UTF-8').and_return(input)
586
580
  result = instance.test
587
581
  expect(result.file_path).to eq 'app/views/posts/_form.html.slim'
@@ -5,10 +5,7 @@ require 'spec_helper'
5
5
  module Synvert::Core
6
6
  describe Rewriter::Warning do
7
7
  subject {
8
- source = "def test\n debugger\nend"
9
- send_node = Parser::CurrentRuby.parse(source).body.first
10
- instance = double(current_node: send_node, file_path: 'app/test.rb')
11
- Rewriter::Warning.new(instance, 'remove debugger')
8
+ Rewriter::Warning.new('app/test.rb', 2, 'remove debugger')
12
9
  }
13
10
 
14
11
  it 'gets message with filename and line number' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synvert-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-05-30 00:00:00.000000000 Z
11
+ date: 2024-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport