synvert-core 1.30.1 → 1.30.2

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: a5923465a97b00d151c7877fb725f5f74c63975c9683d926a4bf14e2feae8fc8
4
- data.tar.gz: 94ed7f17447b0d501243b6074f9b4c2e57b09c5954b013727dc052933ac5e8fc
3
+ metadata.gz: 5fce0db1974beb18ed0cdfbaae3e68e11c50c3f7ba4bd0dc5904dd7b2035975b
4
+ data.tar.gz: 7de77483010cb937b6ae1020579d0d8c21889f9c4076a47c8d3a379e23fd76c1
5
5
  SHA512:
6
- metadata.gz: c0614ad3287376170341654f290599a0f3541dd26562124935c208d77be666a1073a439090731a42efe62806f4aac91238c0a5eaf79ce971515719ee34384863
7
- data.tar.gz: 1335bdfaaa06f1d8f8cca811d3e0fd4a9d40ca1f1ac0597a42b110555be59976e299cf9147c785c8c8d4ad418251a7fa0c7f2de7967ef71d77c46cbf86548076
6
+ metadata.gz: 175fc9b3ffef5f498d68667aa766a62c739940e3f2f525277c2a6c196ca4a33c025ace8b4d7dbb13ef41596e873f6fa477e46b35ddaa319fb0484debac0e5730
7
+ data.tar.gz: 3c43b3b9d6319998e5c9dd628c68890481c57974d68937a52586762d606772099f04f702b337a0cd1192bae733cd122d7d09742318893b1fa0ce14ed25b6fe4a
@@ -11,7 +11,7 @@ jobs:
11
11
  runs-on: ubuntu-latest
12
12
  strategy:
13
13
  matrix:
14
- ruby-version: ['2.7', '3.0', '3.1', '3.2']
14
+ ruby-version: ['2.7', '3.0', '3.1', '3.2', '3.3']
15
15
 
16
16
  steps:
17
17
  - uses: actions/checkout@v3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.30.2 (2024-01-09)
4
+
5
+ * Add `Configuration.strict` option
6
+
3
7
  ## 1.30.1 (2023-12-01)
4
8
 
5
9
  * It is `parser` option instead of `adapter`
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- synvert-core (1.30.1)
4
+ synvert-core (1.30.2)
5
5
  activesupport (< 7.0.0)
6
6
  node_mutation (>= 1.21.6)
7
7
  node_query (>= 1.13.12)
@@ -50,13 +50,13 @@ GEM
50
50
  method_source (1.0.0)
51
51
  minitest (5.20.0)
52
52
  nenv (0.3.0)
53
- node_mutation (1.22.0)
53
+ node_mutation (1.22.2)
54
54
  node_query (1.14.1)
55
55
  notiffany (0.1.3)
56
56
  nenv (~> 0.1)
57
57
  shellany (~> 0.0)
58
- parallel (1.23.0)
59
- parser (3.2.2.4)
58
+ parallel (1.24.0)
59
+ parser (3.3.0.2)
60
60
  ast (~> 2.4.1)
61
61
  racc
62
62
  parser_node_ext (1.2.1)
@@ -11,7 +11,15 @@ module Synvert::Core
11
11
  # @!attribute [w] number_of_workers
12
12
  # @!attribute [w] single_quote
13
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
+ # @!attribute [w] strict, if strict is false, it will ignore ruby version and gem version check.
15
+ attr_writer :root_path,
16
+ :skip_paths,
17
+ :only_paths,
18
+ :show_run_process,
19
+ :number_of_workers,
20
+ :single_quote,
21
+ :tab_width,
22
+ :strict
15
23
 
16
24
  # Get the path.
17
25
  #
@@ -55,9 +63,23 @@ module Synvert::Core
55
63
  @single_quote.nil? ? true : @single_quote
56
64
  end
57
65
 
66
+ # Returns the tab width used for indentation.
67
+ #
68
+ # If the tab width is not explicitly set, it defaults to 2.
69
+ #
70
+ # @return [Integer] The tab width.
58
71
  def tab_width
59
72
  @tab_width || 2
60
73
  end
74
+
75
+ # Returns the value of the strict flag.
76
+ #
77
+ # If the strict flag is not set, it returns true by default.
78
+ #
79
+ # @return [Boolean] the value of the strict flag
80
+ def strict
81
+ @strict.nil? ? true : @strict
82
+ end
61
83
  end
62
84
  end
63
85
  end
@@ -24,6 +24,8 @@ module Synvert::Core
24
24
  #
25
25
  # @return [Boolean] true if matches, otherwise false.
26
26
  def match?
27
+ return true unless Configuration.strict
28
+
27
29
  gemfile_lock_path = File.expand_path(File.join(Configuration.root_path, 'Gemfile.lock'))
28
30
 
29
31
  # if Gemfile.lock does not exist, just ignore this check
@@ -35,7 +35,7 @@ module Synvert::Core
35
35
  # @return file path
36
36
  # @!attribute [rw] current_node
37
37
  # @return current ast node
38
- attr_reader :file_path, :current_node
38
+ attr_reader :file_path
39
39
  attr_accessor :current_node
40
40
 
41
41
  # Process the instance.
@@ -104,14 +104,14 @@ module Synvert::Core
104
104
  @current_node
105
105
  end
106
106
 
107
- # Get rewriter's adapter.
107
+ # Get rewriter's parser.
108
108
  #
109
- # @return [String] adapter
109
+ # @return [String] parser
110
110
  def parser
111
111
  @rewriter.parser
112
112
  end
113
113
 
114
- # Gent current_mutation's adapter.
114
+ # Get current_mutation's adapter.
115
115
  #
116
116
  # @return [NodeMutation::Adapter]
117
117
  def mutation_adapter
@@ -16,6 +16,8 @@ module Synvert::Core
16
16
  #
17
17
  # @return [Boolean] true if matches, otherwise false.
18
18
  def match?
19
+ return true unless Configuration.strict
20
+
19
21
  if File.exist?(File.join(Configuration.root_path, '.ruby-version'))
20
22
  version_file = '.ruby-version'
21
23
  elsif File.exist?(File.join(Configuration.root_path, '.rvmrc'))
@@ -8,7 +8,7 @@ module Synvert::Core
8
8
  class Utils
9
9
  class << self
10
10
  def eval_snippet(snippet_name)
11
- eval(load_snippet(snippet_name), binding, __FILE__, __LINE__ + 1)
11
+ eval(load_snippet(snippet_name), binding, "(eval #{snippet_name})")
12
12
  end
13
13
 
14
14
  def load_snippet(snippet_name)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Synvert
4
4
  module Core
5
- VERSION = '1.30.1'
5
+ VERSION = '1.30.2'
6
6
  end
7
7
  end
@@ -51,5 +51,12 @@ module Synvert::Core
51
51
  gem_spec = Rewriter::GemSpec.new('ast', '1.1.0')
52
52
  expect(gem_spec).to be_match
53
53
  end
54
+
55
+ it 'returns true if Configuration.strict is false' do
56
+ Configuration.strict = false
57
+ gem_spec = Rewriter::GemSpec.new('synvert', '1.0.0')
58
+ expect(gem_spec).to be_match
59
+ Configuration.strict = true
60
+ end
54
61
  end
55
62
  end
@@ -5,8 +5,8 @@ require 'spec_helper'
5
5
  module Synvert::Core
6
6
  describe Rewriter::RubyVersion do
7
7
  before do
8
- expect(File).to receive(:exist?).with('./.ruby-version').and_return(true)
9
- expect(File).to receive(:read).with('./.ruby-version').and_return('3.0.0')
8
+ allow(File).to receive(:exist?).with('./.ruby-version').and_return(true)
9
+ allow(File).to receive(:read).with('./.ruby-version').and_return('3.0.0')
10
10
  end
11
11
 
12
12
  it 'returns true if ruby version is greater than 1.9' do
@@ -18,5 +18,12 @@ module Synvert::Core
18
18
  ruby_version = Rewriter::RubyVersion.new('19.0')
19
19
  expect(ruby_version).not_to be_match
20
20
  end
21
+
22
+ it 'returns true if strict Configuration is false' do
23
+ Configuration.strict = false
24
+ ruby_version = Rewriter::RubyVersion.new('19.0')
25
+ expect(ruby_version).to be_match
26
+ Configuration.strict = true
27
+ end
21
28
  end
22
29
  end
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: 1.30.1
4
+ version: 1.30.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-01 00:00:00.000000000 Z
11
+ date: 2024-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -207,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0'
209
209
  requirements: []
210
- rubygems_version: 3.4.20
210
+ rubygems_version: 3.5.3
211
211
  signing_key:
212
212
  specification_version: 4
213
213
  summary: convert ruby code to better syntax.