synvert-core 1.20.0 → 1.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d0e41ca1ed27bdc4a8e85f022cab4f220970746e950507c51ca5634dcb0c2f5c
4
- data.tar.gz: bc61e33e6bf1282befa1f6b67944e372d7ba309c4f47b907b6f64fd5fb677a94
3
+ metadata.gz: df27af331a60def04866041f84ae64b9fe15555996ec2289015eb2c97d965f68
4
+ data.tar.gz: '092e9456741b2b43516146756ba738f6997a5252ba03dff226bde042333b4bf4'
5
5
  SHA512:
6
- metadata.gz: a1dd19db1a689441e0443c524deb067d8bd6454ae0226f3163180b74fa4633bafb27b97d48c1c7506ff114c96fb40ae94beea6d7ed65740d6eeafaef1bd65cc4
7
- data.tar.gz: bffc0742e22250091392cf453c71e1901920f5f4d8df3cf8d71ae373c351e41c620a2bf62ec3a72f0aac8d6d6f96ef043c81b577f201244c51f52b9cf66de051
6
+ metadata.gz: 05aea1fff55d3a96596dc54de49db457ffe4fac87677bc9dada1d8af4ec6f45397b586207a0e8214fbbedbeed42f58a4fe92934a6095a610c834332632c1901a
7
+ data.tar.gz: ed6ab4c13e2aa0f406de8f4eff041f4fdb39ba37430902284994eb7ed303352bb4a1b459416a73fd049196646eed95bd332721a7f9b9f6da8dcf6a119fdb25e2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.21.0 (2023-02-08)
4
+
5
+ * Add `Configuration#tab_width`
6
+ * Add `Instance#add_leading_spaces`
7
+
3
8
  ## 1.20.0 (2023-02-08)
4
9
 
5
10
  * Add `Configuration#single_quote`
data/Gemfile.lock CHANGED
@@ -1,10 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- synvert-core (1.20.0)
4
+ synvert-core (1.21.0)
5
5
  activesupport (< 7.0.0)
6
6
  erubis
7
- node_mutation (>= 1.8.2)
7
+ node_mutation (>= 1.9.0)
8
8
  node_query (>= 1.12.0)
9
9
  parallel
10
10
  parser
@@ -50,7 +50,7 @@ GEM
50
50
  method_source (1.0.0)
51
51
  minitest (5.17.0)
52
52
  nenv (0.3.0)
53
- node_mutation (1.8.2)
53
+ node_mutation (1.9.0)
54
54
  erubis
55
55
  node_query (1.12.0)
56
56
  notiffany (0.1.3)
data/README.md CHANGED
@@ -104,6 +104,7 @@ Actions:
104
104
  Others:
105
105
 
106
106
  * [wrap_with_quotes](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#wrap_with_quotes-instance_method) - wrap string code with single or doulbe quotes
107
+ * [add_leading_spaces](https://xinminlabs.github.io/synvert-core-ruby/Synvert/Core/Rewriter/Instance.html#add_leading_spaces-instance_method) - add leading spaces before the string code
107
108
 
108
109
 
109
110
  Attributes:
@@ -10,7 +10,8 @@ module Synvert::Core
10
10
  # @!attribute [w] show_run_process
11
11
  # @!attribute [w] number_of_workers
12
12
  # @!attribute [w] single_quote
13
- attr_writer :root_path, :skip_paths, :only_paths, :show_run_process, :number_of_workers, :single_quote
13
+ # @!attribute [w] tab_width
14
+ attr_writer :root_path, :skip_paths, :only_paths, :show_run_process, :number_of_workers, :single_quote, :tab_width
14
15
 
15
16
  # Get the path.
16
17
  #
@@ -53,6 +54,10 @@ module Synvert::Core
53
54
  def single_quote
54
55
  @single_quote.nil? ? true : @single_quote
55
56
  end
57
+
58
+ def tab_width
59
+ @tab_width || 2
60
+ end
56
61
  end
57
62
  end
58
63
  end
@@ -22,7 +22,7 @@ module Synvert::Core
22
22
  if rewriter.options[:strategy] == Strategy::ALLOW_INSERT_AT_SAME_POSITION
23
23
  strategy |= NodeMutation::Strategy::ALLOW_INSERT_AT_SAME_POSITION
24
24
  end
25
- NodeMutation.configure({ strategy: strategy })
25
+ NodeMutation.configure({ strategy: strategy, tab_width: Configuration.tab_width })
26
26
  rewriter.helpers.each { |helper| singleton_class.send(:define_method, helper[:name], &helper[:block]) }
27
27
  end
28
28
 
@@ -423,6 +423,13 @@ module Synvert::Core
423
423
  quote + escaped_str + quote
424
424
  end
425
425
 
426
+ # Add leading spaces before the str according to Configuration.tab_width.
427
+ # @param str [String]
428
+ # @return [String]
429
+ def add_leading_spaces(str)
430
+ " " * Configuration.tab_width + str;
431
+ end
432
+
426
433
  private
427
434
 
428
435
  # Read file source.
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Synvert
4
4
  module Core
5
- VERSION = '1.20.0'
5
+ VERSION = '1.21.0'
6
6
  end
7
7
  end
@@ -394,5 +394,11 @@ module Synvert::Core
394
394
  end
395
395
  end
396
396
  end
397
+
398
+ describe '#add_leading_spaces' do
399
+ it 'adds leading spaces' do
400
+ expect(instance.add_leading_spaces('foo')).to eq ' foo';
401
+ end
402
+ end
397
403
  end
398
404
  end
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.add_runtime_dependency "activesupport", "< 7.0.0"
23
23
  spec.add_runtime_dependency "erubis"
24
24
  spec.add_runtime_dependency "node_query", ">= 1.12.0"
25
- spec.add_runtime_dependency "node_mutation", ">= 1.8.2"
25
+ spec.add_runtime_dependency "node_mutation", ">= 1.9.0"
26
26
  spec.add_runtime_dependency "parser"
27
27
  spec.add_runtime_dependency "parser_node_ext", ">= 0.9.0"
28
28
  spec.add_runtime_dependency "parallel"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synvert-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.20.0
4
+ version: 1.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 1.8.2
61
+ version: 1.9.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 1.8.2
68
+ version: 1.9.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: parser
71
71
  requirement: !ruby/object:Gem::Requirement