synvert-core 1.32.0 → 1.33.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 +10 -0
- data/Gemfile.lock +10 -10
- data/lib/synvert/core/configuration.rb +9 -0
- data/lib/synvert/core/utils.rb +19 -8
- data/lib/synvert/core/version.rb +1 -1
- data/spec/synvert/core/utils_spec.rb +34 -8
- data/synvert-core-ruby.gemspec +4 -4
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 279c659ed3a5da5cda7a67c95ef3cc74601d2f64d7dc70ae29431ef8ec4a9929
|
4
|
+
data.tar.gz: 65caaa8ccc16f8789137b8269ad5ec45c6fe1c9d9198dc0b940b09ad3e3e06cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f45bf64e55621191bfe3a17c689d337d0b25fd356217dd8965876540514bb4b5d04cabb25a834b0567dfba538c93095b12ba281cc02c90a596ec34f8b3dc9231
|
7
|
+
data.tar.gz: 45c5c88b22be8e616cda46e518ee304333d3a8973f58b174182950eef2b958b16ed880311085cf63dc022fe79f8ec3e45fab3a32d23891db829dc5ba8066e075
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 1.33.0 (2024-02-18)
|
4
|
+
|
5
|
+
* Add `Configuration.respect_gitignore`
|
6
|
+
* Glob files with `git check-ignore` if `Configuration.respect_gitignore` is true
|
7
|
+
|
8
|
+
## 1.32.1 (2024-02-17)
|
9
|
+
|
10
|
+
* Update `node_mutation` to 1.23.2
|
11
|
+
* Update `node_query` to 1.15.1
|
12
|
+
|
3
13
|
## 1.32.0 (2024-02-11)
|
4
14
|
|
5
15
|
* Support `prism`
|
data/Gemfile.lock
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
synvert-core (1.
|
4
|
+
synvert-core (1.33.0)
|
5
5
|
activesupport (< 7.0.0)
|
6
|
-
node_mutation (>= 1.23.
|
7
|
-
node_query (>= 1.15.
|
6
|
+
node_mutation (>= 1.23.2)
|
7
|
+
node_query (>= 1.15.1)
|
8
8
|
parallel
|
9
9
|
parser
|
10
10
|
parser_node_ext (>= 1.2.2)
|
11
11
|
prism
|
12
|
-
prism_ext (>= 0.2.
|
12
|
+
prism_ext (>= 0.2.3)
|
13
13
|
syntax_tree
|
14
|
-
syntax_tree_ext (>= 0.7.
|
14
|
+
syntax_tree_ext (>= 0.7.2)
|
15
15
|
|
16
16
|
GEM
|
17
17
|
remote: https://rubygems.org/
|
@@ -52,8 +52,8 @@ GEM
|
|
52
52
|
method_source (1.0.0)
|
53
53
|
minitest (5.22.2)
|
54
54
|
nenv (0.3.0)
|
55
|
-
node_mutation (1.23.
|
56
|
-
node_query (1.15.
|
55
|
+
node_mutation (1.23.2)
|
56
|
+
node_query (1.15.1)
|
57
57
|
notiffany (0.1.3)
|
58
58
|
nenv (~> 0.1)
|
59
59
|
shellany (~> 0.0)
|
@@ -64,8 +64,8 @@ GEM
|
|
64
64
|
parser_node_ext (1.2.2)
|
65
65
|
parser
|
66
66
|
prettier_print (1.2.1)
|
67
|
-
prism (0.
|
68
|
-
prism_ext (0.2.
|
67
|
+
prism (0.24.0)
|
68
|
+
prism_ext (0.2.3)
|
69
69
|
prism
|
70
70
|
pry (0.14.1)
|
71
71
|
coderay (~> 1.1)
|
@@ -91,7 +91,7 @@ GEM
|
|
91
91
|
shellany (0.0.1)
|
92
92
|
syntax_tree (6.2.0)
|
93
93
|
prettier_print (>= 1.2.0)
|
94
|
-
syntax_tree_ext (0.7.
|
94
|
+
syntax_tree_ext (0.7.2)
|
95
95
|
syntax_tree
|
96
96
|
thor (1.2.1)
|
97
97
|
tzinfo (2.0.6)
|
@@ -7,6 +7,7 @@ module Synvert::Core
|
|
7
7
|
# @!attribute [w] root_path
|
8
8
|
# @!attribute [w] skip_paths
|
9
9
|
# @!attribute [w] only_paths
|
10
|
+
# @!attribute [w] respect_gitignore
|
10
11
|
# @!attribute [w] show_run_process
|
11
12
|
# @!attribute [w] number_of_workers
|
12
13
|
# @!attribute [w] single_quote
|
@@ -16,6 +17,7 @@ module Synvert::Core
|
|
16
17
|
attr_writer :root_path,
|
17
18
|
:skip_paths,
|
18
19
|
:only_paths,
|
20
|
+
:respect_gitignore,
|
19
21
|
:show_run_process,
|
20
22
|
:number_of_workers,
|
21
23
|
:single_quote,
|
@@ -44,6 +46,13 @@ module Synvert::Core
|
|
44
46
|
@only_paths || []
|
45
47
|
end
|
46
48
|
|
49
|
+
# Check if respect .gitignore
|
50
|
+
#
|
51
|
+
# @return [Boolean] default is true
|
52
|
+
def respect_gitignore
|
53
|
+
@respect_gitignore.nil? ? true : @respect_gitignore
|
54
|
+
end
|
55
|
+
|
47
56
|
# Check if show run process.
|
48
57
|
#
|
49
58
|
# @return [Boolean] default is false
|
data/lib/synvert/core/utils.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'net/http'
|
4
4
|
require 'uri'
|
5
5
|
require 'open-uri'
|
6
|
+
require 'open3'
|
6
7
|
|
7
8
|
module Synvert::Core
|
8
9
|
class Utils
|
@@ -35,11 +36,21 @@ module Synvert::Core
|
|
35
36
|
# @return [Array<String>] file paths
|
36
37
|
def glob(file_patterns)
|
37
38
|
Dir.chdir(Configuration.root_path) do
|
38
|
-
all_files =
|
39
|
-
|
40
|
-
|
39
|
+
all_files = file_patterns.flat_map { |pattern| Dir.glob(pattern) }
|
40
|
+
ignored_files = []
|
41
|
+
|
42
|
+
if Configuration.respect_gitignore
|
43
|
+
Open3.popen3('git check-ignore --stdin') do |stdin, stdout, stderr, wait_thr|
|
44
|
+
stdin.puts(all_files.join("\n"))
|
45
|
+
stdin.close
|
46
|
+
|
47
|
+
ignored_files = stdout.read.split("\n")
|
41
48
|
end
|
42
|
-
|
49
|
+
end
|
50
|
+
|
51
|
+
filtered_files = filter_only_paths(all_files - ignored_files)
|
52
|
+
|
53
|
+
filtered_files -= get_explicitly_skipped_files
|
43
54
|
end
|
44
55
|
end
|
45
56
|
|
@@ -85,16 +96,16 @@ module Synvert::Core
|
|
85
96
|
# Filter only paths with `Configuration.only_paths`.
|
86
97
|
# @return [Array<String>] filtered file paths
|
87
98
|
def filter_only_paths(all_files)
|
88
|
-
return all_files if Configuration.only_paths.
|
99
|
+
return all_files if Configuration.only_paths.empty?
|
89
100
|
|
90
101
|
Configuration.only_paths.flat_map do |only_path|
|
91
102
|
all_files.filter { |file_path| file_path.starts_with?(only_path) }
|
92
103
|
end
|
93
104
|
end
|
94
105
|
|
95
|
-
# Get
|
96
|
-
# @return [Array<String>]
|
97
|
-
def
|
106
|
+
# Get skipped files.
|
107
|
+
# @return [Array<String>] skipped files
|
108
|
+
def get_explicitly_skipped_files
|
98
109
|
Configuration.skip_paths.flat_map do |skip_path|
|
99
110
|
if File.directory?(skip_path)
|
100
111
|
Dir.glob(File.join(skip_path, "**/*"))
|
data/lib/synvert/core/version.rb
CHANGED
@@ -58,16 +58,42 @@ module Synvert::Core
|
|
58
58
|
before do
|
59
59
|
Configuration.only_paths = []
|
60
60
|
Configuration.skip_paths = []
|
61
|
+
Configuration.respect_gitignore = false
|
61
62
|
end
|
62
63
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
64
|
+
context 'Configuration.respect_gitignore is false' do
|
65
|
+
it 'gets all files' do
|
66
|
+
expect(Dir).to receive(:glob).with('**/*.rb').and_return(
|
67
|
+
[
|
68
|
+
'app/models/post.rb',
|
69
|
+
'app/controllers/posts_controller.rb'
|
70
|
+
]
|
71
|
+
)
|
72
|
+
expect(described_class.glob(['**/*.rb'])).to eq(['app/models/post.rb', 'app/controllers/posts_controller.rb'])
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'Configuration.respect_gitignore is true' do
|
77
|
+
before do
|
78
|
+
Configuration.respect_gitignore = true
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'correctly filters out ignored files' do
|
82
|
+
file_patterns = ["**/*.rb"]
|
83
|
+
all_files = ["app/models/post.rb", "app/controllers/posts_controller.rb", "app/controllers/temp.tmp"]
|
84
|
+
not_ignored_files = ["app/models/post.rb", "app/controllers/posts_controller.rb"]
|
85
|
+
command_output = "app/controllers/temp.tmp\n"
|
86
|
+
|
87
|
+
allow(Open3).to receive(:popen3).with('git check-ignore --stdin').and_yield(
|
88
|
+
instance_double(IO, puts: nil, close: nil),
|
89
|
+
StringIO.new(command_output),
|
90
|
+
StringIO.new(''),
|
91
|
+
instance_double(Process::Waiter, value: instance_double(Process::Status, success?: true))
|
92
|
+
)
|
93
|
+
allow(Dir).to receive(:glob).and_return(all_files)
|
94
|
+
|
95
|
+
expect(described_class.glob(file_patterns)).to match_array(not_ignored_files)
|
96
|
+
end
|
71
97
|
end
|
72
98
|
|
73
99
|
it 'filters only paths' do
|
data/synvert-core-ruby.gemspec
CHANGED
@@ -20,13 +20,13 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
22
|
spec.add_runtime_dependency "activesupport", "< 7.0.0"
|
23
|
-
spec.add_runtime_dependency "node_query", ">= 1.15.
|
24
|
-
spec.add_runtime_dependency "node_mutation", ">= 1.23.
|
23
|
+
spec.add_runtime_dependency "node_query", ">= 1.15.1"
|
24
|
+
spec.add_runtime_dependency "node_mutation", ">= 1.23.2"
|
25
25
|
spec.add_runtime_dependency "parser"
|
26
26
|
spec.add_runtime_dependency "parser_node_ext", ">= 1.2.2"
|
27
27
|
spec.add_runtime_dependency "syntax_tree"
|
28
|
-
spec.add_runtime_dependency "syntax_tree_ext", ">= 0.7.
|
28
|
+
spec.add_runtime_dependency "syntax_tree_ext", ">= 0.7.2"
|
29
29
|
spec.add_runtime_dependency "prism"
|
30
|
-
spec.add_runtime_dependency "prism_ext", ">= 0.2.
|
30
|
+
spec.add_runtime_dependency "prism_ext", ">= 0.2.3"
|
31
31
|
spec.add_runtime_dependency "parallel"
|
32
32
|
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.
|
4
|
+
version: 1.33.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: 2024-02-
|
11
|
+
date: 2024-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -30,28 +30,28 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 1.15.
|
33
|
+
version: 1.15.1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 1.15.
|
40
|
+
version: 1.15.1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: node_mutation
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.23.
|
47
|
+
version: 1.23.2
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.23.
|
54
|
+
version: 1.23.2
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: parser
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: 0.7.
|
103
|
+
version: 0.7.2
|
104
104
|
type: :runtime
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 0.7.
|
110
|
+
version: 0.7.2
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
112
|
name: prism
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,14 +128,14 @@ dependencies:
|
|
128
128
|
requirements:
|
129
129
|
- - ">="
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: 0.2.
|
131
|
+
version: 0.2.3
|
132
132
|
type: :runtime
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: 0.2.
|
138
|
+
version: 0.2.3
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
140
|
name: parallel
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|