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 +4 -4
- data/.vscode/settings.json +17 -1
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +6 -6
- data/lib/synvert/core/rewriter/instance.rb +2 -1
- data/lib/synvert/core/rewriter/warning.rb +5 -4
- data/lib/synvert/core/rewriter.rb +1 -1
- data/lib/synvert/core/utils.rb +1 -1
- data/lib/synvert/core/version.rb +1 -1
- data/lib/synvert/core.rb +1 -0
- data/spec/synvert/core/rewriter/gem_spec_spec.rb +11 -1
- data/spec/synvert/core/rewriter/instance_spec.rb +3 -9
- data/spec/synvert/core/rewriter/warning_spec.rb +1 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fce0541de0c11b2a281d837c23669ea6fbe768f53b551549e1693119be907a1b
|
4
|
+
data.tar.gz: 413625544e125e8d9ec114e6dbe1021d2ca46969b319b56037a2fad4a5ba1c45
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2695eb816b145e15644104da335f58d7038ed698f998348e35f23c0e42a0c3e119bc1feefc2cc12875d4dc26e3b9dbccd468c61e117f8e5dbd1efdebb2f95fea
|
7
|
+
data.tar.gz: fe5d4072638d277b8eedbf488540bd85632118721c2092f9c6117a41f7a761e70d21a9652a7f8fd007f260885ef9930dfd9000d295f6733dc3fda73925c29aee
|
data/.vscode/settings.json
CHANGED
@@ -1,5 +1,21 @@
|
|
1
1
|
{
|
2
2
|
"cSpell.words": [
|
3
|
-
"
|
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
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
synvert-core (2.0.
|
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.
|
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.
|
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.
|
72
|
-
parser (3.3.
|
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.
|
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
|
-
@
|
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
|
8
|
+
# @param file_path [String] file path.
|
9
|
+
# @param line [Integer] file line.
|
9
10
|
# @param message [String] warning message.
|
10
|
-
def initialize(
|
11
|
-
@file_path =
|
12
|
-
@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] && !
|
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
|
data/lib/synvert/core/utils.rb
CHANGED
@@ -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,
|
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
|
|
data/lib/synvert/core/version.rb
CHANGED
data/lib/synvert/core.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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.
|
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-
|
11
|
+
date: 2024-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|