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 +4 -4
- data/.github/workflows/main.yml +1 -1
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +4 -4
- data/lib/synvert/core/configuration.rb +23 -1
- data/lib/synvert/core/rewriter/gem_spec.rb +2 -0
- data/lib/synvert/core/rewriter/instance.rb +4 -4
- data/lib/synvert/core/rewriter/ruby_version.rb +2 -0
- data/lib/synvert/core/utils.rb +1 -1
- data/lib/synvert/core/version.rb +1 -1
- data/spec/synvert/core/rewriter/gem_spec_spec.rb +7 -0
- data/spec/synvert/core/rewriter/ruby_version_spec.rb +9 -2
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fce0db1974beb18ed0cdfbaae3e68e11c50c3f7ba4bd0dc5904dd7b2035975b
|
4
|
+
data.tar.gz: 7de77483010cb937b6ae1020579d0d8c21889f9c4076a47c8d3a379e23fd76c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 175fc9b3ffef5f498d68667aa766a62c739940e3f2f525277c2a6c196ca4a33c025ace8b4d7dbb13ef41596e873f6fa477e46b35ddaa319fb0484debac0e5730
|
7
|
+
data.tar.gz: 3c43b3b9d6319998e5c9dd628c68890481c57974d68937a52586762d606772099f04f702b337a0cd1192bae733cd122d7d09742318893b1fa0ce14ed25b6fe4a
|
data/.github/workflows/main.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
synvert-core (1.30.
|
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.
|
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.
|
59
|
-
parser (3.
|
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
|
-
|
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
|
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
|
107
|
+
# Get rewriter's parser.
|
108
108
|
#
|
109
|
-
# @return [String]
|
109
|
+
# @return [String] parser
|
110
110
|
def parser
|
111
111
|
@rewriter.parser
|
112
112
|
end
|
113
113
|
|
114
|
-
#
|
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'))
|
data/lib/synvert/core/utils.rb
CHANGED
@@ -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,
|
11
|
+
eval(load_snippet(snippet_name), binding, "(eval #{snippet_name})")
|
12
12
|
end
|
13
13
|
|
14
14
|
def load_snippet(snippet_name)
|
data/lib/synvert/core/version.rb
CHANGED
@@ -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
|
-
|
9
|
-
|
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.
|
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:
|
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.
|
210
|
+
rubygems_version: 3.5.3
|
211
211
|
signing_key:
|
212
212
|
specification_version: 4
|
213
213
|
summary: convert ruby code to better syntax.
|