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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0afc5cb58f822a56343dfba1c4f2c762e52db5d4eefb3d88eb1b72788a97a8b3
4
- data.tar.gz: 56c67dd89f69ba0dd90a91818740c0f70b18d3fe4887e50fed37c7eea736b18f
3
+ metadata.gz: 5d9026b58fc968fd19fb6bcfb02a7235ba90fa2dee89b74c4707191ddbe892e7
4
+ data.tar.gz: 80b9f33e6c34e9b575a1dfac6b89adc8e5362cca7506a0b64b86047e3e27afbf
5
5
  SHA512:
6
- metadata.gz: 6e9270a5518350d8bdab54a9548047cb678e72eeb5702be9857852522a796d70573ce958fca00f75df776b707bd021ea3f4c7b7720f69755f6b862c4fc70d32f
7
- data.tar.gz: 57a6ac61ee0724c2c6a10524192b4911d65c3cb977104720a1a2da6e5fcd2d967030aaddf8df1605037343620ef1ec9878943fc23935a2a656f7a0cc0672a173
6
+ metadata.gz: 40638d3f2674232745f15810f9f5d12d7f2f5f9b99dc353f7fc568812cad747c24b502aec3c50b1952dfba14db034545719e8f14792658bdd44c7ec7db6e05be
7
+ data.tar.gz: 3d9dc8284d401ec5453c8023a23b0b5096c38d8d9581155dca7069f57c25999315f5a075c1d6eff4b802b8f4d2cc4d8a037ce0c0cf33cd8e2c225781e7790b00
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.56.0 (2021-09-14)
4
+
5
+ * Support `name` for `:lvar`, `:ivar`, `:cvar`
6
+ * Delete one more space if two spaces left
7
+
3
8
  ## 0.55.0 (2021-09-11)
4
9
 
5
10
  * Add `Configuration.show_run_process`
@@ -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 file_path, source.gsub(/ +\n/, "\n")
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Synvert
4
4
  module Core
5
- VERSION = '0.55.0'
5
+ VERSION = '0.56.0'
6
6
  end
7
7
  end
@@ -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.55.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 00:00:00.000000000 Z
11
+ date: 2021-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport