synvert-core 0.55.0 → 0.56.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/synvert/core/node_ext.rb +1 -1
- data/lib/synvert/core/rewriter/action/delete_action.rb +6 -1
- data/lib/synvert/core/rewriter/instance.rb +1 -1
- data/lib/synvert/core/version.rb +1 -1
- data/spec/synvert/core/node_ext_spec.rb +15 -0
- data/spec/synvert/core/rewriter/action/delete_action_spec.rb +1 -1
- 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: 5d9026b58fc968fd19fb6bcfb02a7235ba90fa2dee89b74c4707191ddbe892e7
|
4
|
+
data.tar.gz: 80b9f33e6c34e9b575a1dfac6b89adc8e5362cca7506a0b64b86047e3e27afbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40638d3f2674232745f15810f9f5d12d7f2f5f9b99dc353f7fc568812cad747c24b502aec3c50b1952dfba14db034545719e8f14792658bdd44c7ec7db6e05be
|
7
|
+
data.tar.gz: 3d9dc8284d401ec5453c8023a23b0b5096c38d8d9581155dca7069f57c25999315f5a075c1d6eff4b802b8f4d2cc4d8a037ce0c0cf33cd8e2c225781e7790b00
|
data/CHANGELOG.md
CHANGED
@@ -9,7 +9,7 @@ module Parser::AST
|
|
9
9
|
# @raise [Synvert::Core::MethodNotSupported] if calls on other node.
|
10
10
|
def name
|
11
11
|
case type
|
12
|
-
when :class, :module, :def, :arg, :blockarg, :restarg
|
12
|
+
when :class, :module, :def, :arg, :blockarg, :restarg, :lvar, :ivar, :cvar
|
13
13
|
children[0]
|
14
14
|
when :defs, :const
|
15
15
|
children[1]
|
@@ -12,7 +12,12 @@ module Synvert::Core
|
|
12
12
|
#
|
13
13
|
# @return [Integer] begin position.
|
14
14
|
def begin_pos
|
15
|
-
@selectors.map { |selector| @node.child_node_range(selector) }.compact.map(&:begin_pos).min
|
15
|
+
pos = @selectors.map { |selector| @node.child_node_range(selector) }.compact.map(&:begin_pos).min
|
16
|
+
if @instance.file_source[pos - 1] == ' ' && @instance.file_source[end_pos] == ' '
|
17
|
+
pos - 1
|
18
|
+
else
|
19
|
+
pos
|
20
|
+
end
|
16
21
|
end
|
17
22
|
|
18
23
|
# End position of code to delete.
|
@@ -46,7 +46,7 @@ module Synvert::Core
|
|
46
46
|
# @param source [String] file source
|
47
47
|
def write_file(file_path, source)
|
48
48
|
source = Engine::ERB.decode(source) if /\.erb/.match?(file_path)
|
49
|
-
File.write
|
49
|
+
File.write(file_path, source.gsub(/ +\n/, "\n"))
|
50
50
|
@file_source[file_path] = nil
|
51
51
|
@file_ast[file_path] = nil
|
52
52
|
end
|
data/lib/synvert/core/version.rb
CHANGED
@@ -42,6 +42,21 @@ describe Parser::AST::Node do
|
|
42
42
|
expect(node.name).to eq :Synvert
|
43
43
|
end
|
44
44
|
|
45
|
+
it 'gets for lvar node' do
|
46
|
+
node = parse("foo = 'bar'\nfoo").children[1]
|
47
|
+
expect(node.name).to eq :foo
|
48
|
+
end
|
49
|
+
|
50
|
+
it 'gets for ivar node' do
|
51
|
+
node = parse("@foo = 'bar'\n@foo").children[1]
|
52
|
+
expect(node.name).to eq :@foo
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'gets for cvar node' do
|
56
|
+
node = parse("@@foo = 'bar'\n@@foo").children[1]
|
57
|
+
expect(node.name).to eq :@@foo
|
58
|
+
end
|
59
|
+
|
45
60
|
it 'gets for mlhs node' do
|
46
61
|
node = parse('var.each { |(param1, param2)| }')
|
47
62
|
expect(node.arguments.first.name).to eq node.arguments.first
|
@@ -7,7 +7,7 @@ module Synvert::Core
|
|
7
7
|
subject {
|
8
8
|
source = 'arr.map {}.flatten'
|
9
9
|
node = Parser::CurrentRuby.parse(source)
|
10
|
-
instance = double(current_node: node)
|
10
|
+
instance = double(current_node: node, file_source: source)
|
11
11
|
Rewriter::DeleteAction.new(instance, :dot, :message)
|
12
12
|
}
|
13
13
|
|
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: 0.
|
4
|
+
version: 0.56.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Huang
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-09-
|
11
|
+
date: 2021-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|