synvert-core 1.4.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +0 -1
- data/.gitignore +0 -5
- data/CHANGELOG.md +12 -0
- data/Gemfile +0 -3
- data/Gemfile.lock +101 -0
- data/Guardfile +0 -9
- data/README.md +31 -13
- data/Rakefile +1 -15
- data/lib/synvert/core/engine/erb.rb +1 -1
- data/lib/synvert/core/engine.rb +1 -1
- data/lib/synvert/core/node_ext.rb +0 -639
- data/lib/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action.rb +20 -17
- data/lib/synvert/core/rewriter/condition/if_exist_condition.rb +1 -5
- data/lib/synvert/core/rewriter/condition/if_only_exist_condition.rb +1 -1
- data/lib/synvert/core/rewriter/condition/unless_exist_condition.rb +1 -5
- data/lib/synvert/core/rewriter/condition.rb +5 -1
- data/lib/synvert/core/rewriter/instance.rb +91 -140
- data/lib/synvert/core/rewriter/scope/query_scope.rb +8 -6
- data/lib/synvert/core/rewriter/scope/within_scope.rb +4 -87
- data/lib/synvert/core/rewriter.rb +0 -10
- data/lib/synvert/core/version.rb +1 -1
- data/lib/synvert/core.rb +4 -6
- data/spec/synvert/core/engine/erb_spec.rb +3 -3
- data/spec/synvert/core/node_ext_spec.rb +0 -965
- data/spec/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action_spec.rb +21 -1
- data/spec/synvert/core/rewriter/instance_spec.rb +64 -131
- data/spec/synvert/core/rewriter/scope/goto_scope_spec.rb +1 -4
- data/spec/synvert/core/rewriter/scope/query_scope_spec.rb +1 -16
- data/spec/synvert/core/rewriter/scope/within_scope_spec.rb +22 -13
- data/synvert-core-ruby.gemspec +5 -3
- metadata +46 -62
- data/lib/synvert/core/array_ext.rb +0 -48
- data/lib/synvert/core/node_query/compiler/array.rb +0 -34
- data/lib/synvert/core/node_query/compiler/attribute.rb +0 -39
- data/lib/synvert/core/node_query/compiler/attribute_list.rb +0 -24
- data/lib/synvert/core/node_query/compiler/basic_selector.rb +0 -28
- data/lib/synvert/core/node_query/compiler/boolean.rb +0 -23
- data/lib/synvert/core/node_query/compiler/comparable.rb +0 -86
- data/lib/synvert/core/node_query/compiler/dynamic_attribute.rb +0 -51
- data/lib/synvert/core/node_query/compiler/expression.rb +0 -41
- data/lib/synvert/core/node_query/compiler/float.rb +0 -23
- data/lib/synvert/core/node_query/compiler/identifier.rb +0 -41
- data/lib/synvert/core/node_query/compiler/integer.rb +0 -23
- data/lib/synvert/core/node_query/compiler/invalid_operator_error.rb +0 -7
- data/lib/synvert/core/node_query/compiler/nil.rb +0 -23
- data/lib/synvert/core/node_query/compiler/parse_error.rb +0 -7
- data/lib/synvert/core/node_query/compiler/regexp.rb +0 -37
- data/lib/synvert/core/node_query/compiler/selector.rb +0 -113
- data/lib/synvert/core/node_query/compiler/string.rb +0 -23
- data/lib/synvert/core/node_query/compiler/symbol.rb +0 -23
- data/lib/synvert/core/node_query/compiler.rb +0 -25
- data/lib/synvert/core/node_query/lexer.rex +0 -99
- data/lib/synvert/core/node_query/lexer.rex.rb +0 -299
- data/lib/synvert/core/node_query/parser.racc.rb +0 -306
- data/lib/synvert/core/node_query/parser.y +0 -60
- data/lib/synvert/core/node_query.rb +0 -36
- data/lib/synvert/core/rewriter/action/append_action.rb +0 -28
- data/lib/synvert/core/rewriter/action/delete_action.rb +0 -34
- data/lib/synvert/core/rewriter/action/insert_action.rb +0 -34
- data/lib/synvert/core/rewriter/action/insert_after_action.rb +0 -22
- data/lib/synvert/core/rewriter/action/prepend_action.rb +0 -44
- data/lib/synvert/core/rewriter/action/remove_action.rb +0 -56
- data/lib/synvert/core/rewriter/action/replace_action.rb +0 -33
- data/lib/synvert/core/rewriter/action/replace_with_action.rb +0 -36
- data/lib/synvert/core/rewriter/action/wrap_action.rb +0 -37
- data/lib/synvert/core/rewriter/action.rb +0 -102
- data/spec/synvert/core/node_query/lexer_spec.rb +0 -580
- data/spec/synvert/core/node_query/parser_spec.rb +0 -337
- data/spec/synvert/core/rewriter/action/append_action_spec.rb +0 -70
- data/spec/synvert/core/rewriter/action/delete_action_spec.rb +0 -26
- data/spec/synvert/core/rewriter/action/insert_action_spec.rb +0 -70
- data/spec/synvert/core/rewriter/action/insert_after_action_spec.rb +0 -26
- data/spec/synvert/core/rewriter/action/prepend_action_spec.rb +0 -175
- data/spec/synvert/core/rewriter/action/remove_action_spec.rb +0 -26
- data/spec/synvert/core/rewriter/action/replace_action_spec.rb +0 -28
- data/spec/synvert/core/rewriter/action/replace_with_action_spec.rb +0 -59
- data/spec/synvert/core/rewriter/action/wrap_action_spec.rb +0 -31
- data/spec/synvert/core/rewriter/action_spec.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d838da042cfdbc68e4a235117a465ca340fa732203f7470684a9279e6797fff
|
4
|
+
data.tar.gz: ad784c3e09faa73a55e0bf0ad51a982230d9a1b2a328c43414e4aa297e38a00e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b31e94f8071af04f1ae7b1292bb5af91e52ba047949535667cb6765a5ef32c9bbcf855dd92a212aa640b0185f42fbd1bbcf4614f424c596f9c52f62a313a643
|
7
|
+
data.tar.gz: 197318ccffd17c9eb60251731bf49f45198e2b5fb5812c22d4fe6d0d07bac94bff638bc5a125d05be2ccec930b16300ccdb83ffdd53bf8cf0c4cd8ad22a34c94
|
data/.github/workflows/main.yml
CHANGED
data/.gitignore
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
.bundle
|
4
4
|
.config
|
5
5
|
.yardoc
|
6
|
-
Gemfile.lock
|
7
6
|
InstalledFiles
|
8
7
|
_yardoc
|
9
8
|
coverage
|
@@ -15,7 +14,3 @@ spec/reports
|
|
15
14
|
test/tmp
|
16
15
|
test/version_tmp
|
17
16
|
tmp
|
18
|
-
|
19
|
-
lib/synvert/core/node_query/lexer.rex.rb
|
20
|
-
lib/synvert/core/node_query/parser.racc.rb
|
21
|
-
lib/synvert/core/node_query/parser.output
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
## 1.6.0 (2022-09-15)
|
4
|
+
|
5
|
+
* Make use of `NodeQuery` to query nodes
|
6
|
+
* Remove `Node#to_hash`
|
7
|
+
* Downgrade `activesupport` to < 7.0.0
|
8
|
+
|
9
|
+
## 1.5.0 (2022-07-02)
|
10
|
+
|
11
|
+
* Abstract `node_query`
|
12
|
+
* Abstract `node_mutation`
|
13
|
+
* Abstract `parser_node_ext`
|
14
|
+
|
3
15
|
## 1.4.0 (2022-05-21)
|
4
16
|
|
5
17
|
* Drop support `:first-child` and `:last-child`
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
synvert-core (1.6.0)
|
5
|
+
activesupport (< 7.0.0)
|
6
|
+
erubis
|
7
|
+
node_mutation
|
8
|
+
node_query
|
9
|
+
parser
|
10
|
+
parser_node_ext
|
11
|
+
|
12
|
+
GEM
|
13
|
+
remote: https://rubygems.org/
|
14
|
+
specs:
|
15
|
+
activesupport (6.1.7)
|
16
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
|
+
i18n (>= 1.6, < 2)
|
18
|
+
minitest (>= 5.1)
|
19
|
+
tzinfo (~> 2.0)
|
20
|
+
zeitwerk (~> 2.3)
|
21
|
+
ast (2.4.2)
|
22
|
+
coderay (1.1.3)
|
23
|
+
concurrent-ruby (1.1.10)
|
24
|
+
diff-lcs (1.5.0)
|
25
|
+
erubis (2.7.0)
|
26
|
+
ffi (1.15.5)
|
27
|
+
formatador (1.1.0)
|
28
|
+
guard (2.18.0)
|
29
|
+
formatador (>= 0.2.4)
|
30
|
+
listen (>= 2.7, < 4.0)
|
31
|
+
lumberjack (>= 1.0.12, < 2.0)
|
32
|
+
nenv (~> 0.1)
|
33
|
+
notiffany (~> 0.0)
|
34
|
+
pry (>= 0.13.0)
|
35
|
+
shellany (~> 0.0)
|
36
|
+
thor (>= 0.18.1)
|
37
|
+
guard-compat (1.2.1)
|
38
|
+
guard-rspec (4.7.3)
|
39
|
+
guard (~> 2.1)
|
40
|
+
guard-compat (~> 1.1)
|
41
|
+
rspec (>= 2.99.0, < 4.0)
|
42
|
+
i18n (1.12.0)
|
43
|
+
concurrent-ruby (~> 1.0)
|
44
|
+
listen (3.7.1)
|
45
|
+
rb-fsevent (~> 0.10, >= 0.10.3)
|
46
|
+
rb-inotify (~> 0.9, >= 0.9.10)
|
47
|
+
lumberjack (1.2.8)
|
48
|
+
method_source (1.0.0)
|
49
|
+
minitest (5.16.3)
|
50
|
+
nenv (0.3.0)
|
51
|
+
node_mutation (1.2.1)
|
52
|
+
activesupport
|
53
|
+
erubis
|
54
|
+
node_query (1.5.0)
|
55
|
+
activesupport (< 7.0.0)
|
56
|
+
notiffany (0.1.3)
|
57
|
+
nenv (~> 0.1)
|
58
|
+
shellany (~> 0.0)
|
59
|
+
parser (3.1.2.1)
|
60
|
+
ast (~> 2.4.1)
|
61
|
+
parser_node_ext (0.4.0)
|
62
|
+
parser
|
63
|
+
pry (0.14.1)
|
64
|
+
coderay (~> 1.1)
|
65
|
+
method_source (~> 1.0)
|
66
|
+
rake (13.0.6)
|
67
|
+
rb-fsevent (0.11.1)
|
68
|
+
rb-inotify (0.10.1)
|
69
|
+
ffi (~> 1.0)
|
70
|
+
rspec (3.10.0)
|
71
|
+
rspec-core (~> 3.10.0)
|
72
|
+
rspec-expectations (~> 3.10.0)
|
73
|
+
rspec-mocks (~> 3.10.0)
|
74
|
+
rspec-core (3.10.2)
|
75
|
+
rspec-support (~> 3.10.0)
|
76
|
+
rspec-expectations (3.10.2)
|
77
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
78
|
+
rspec-support (~> 3.10.0)
|
79
|
+
rspec-mocks (3.10.2)
|
80
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
81
|
+
rspec-support (~> 3.10.0)
|
82
|
+
rspec-support (3.10.3)
|
83
|
+
shellany (0.0.1)
|
84
|
+
thor (1.2.1)
|
85
|
+
tzinfo (2.0.5)
|
86
|
+
concurrent-ruby (~> 1.0)
|
87
|
+
zeitwerk (2.6.0)
|
88
|
+
|
89
|
+
PLATFORMS
|
90
|
+
ruby
|
91
|
+
|
92
|
+
DEPENDENCIES
|
93
|
+
guard
|
94
|
+
guard-rspec
|
95
|
+
rake
|
96
|
+
rspec
|
97
|
+
rspec-mocks
|
98
|
+
synvert-core!
|
99
|
+
|
100
|
+
BUNDLED WITH
|
101
|
+
2.3.7
|
data/Guardfile
CHANGED
@@ -3,14 +3,5 @@
|
|
3
3
|
guard :rspec, cmd: 'bundle exec rspec' do
|
4
4
|
watch(%r{^spec/.+_spec\.rb$})
|
5
5
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
6
|
-
watch('lib/synvert/core/node_query/lexer.rex.rb') { 'spec/synvert/core/node_query/lexer_spec.rb' }
|
7
|
-
watch('lib/synvert/core/node_query/compiler.rb') { 'spec/synvert/core/node_query/parser_spec.rb' }
|
8
|
-
watch(%r{^lib/synvert/core/node_query/compiler/.*\.rb$}) { 'spec/synvert/core/node_query/parser_spec.rb' }
|
9
|
-
watch('lib/synvert/core/node_query/parser.racc.rb') { 'spec/synvert/core/node_query/parser_spec.rb' }
|
10
6
|
watch('spec/spec_helper.rb') { "spec" }
|
11
7
|
end
|
12
|
-
|
13
|
-
guard :rake, task: 'generate' do
|
14
|
-
watch('lib/synvert/core/node_query/lexer.rex')
|
15
|
-
watch('lib/synvert/core/node_query/parser.y')
|
16
|
-
end
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# synvert-core-ruby
|
2
2
|
|
3
|
-
<img src="https://synvert.
|
3
|
+
<img src="https://synvert.net/img/logo_96.png" alt="logo" width="32" height="32" />
|
4
4
|
|
5
5
|
[![AwesomeCode Status for xinminlabs/synvert-core-ruby](https://awesomecode.io/projects/033f7f02-7b22-41c3-a902-fca37f1ec72a/status)](https://awesomecode.io/repos/xinminlabs/synvert-core-ruby)
|
6
6
|
![Main workflow](https://github.com/xinminlabs/synvert-core-ruby/actions/workflows/main.yml/badge.svg)
|
@@ -8,29 +8,46 @@
|
|
8
8
|
Synvert core provides a set of DSLs to rewrite ruby code. e.g.
|
9
9
|
|
10
10
|
```ruby
|
11
|
-
Synvert::Rewriter.new '
|
11
|
+
Synvert::Rewriter.new 'factory_bot', 'convert_factory_girl_to_factory_bot' do
|
12
12
|
description <<~EOS
|
13
|
-
It converts
|
13
|
+
It converts FactoryGirl to FactoryBot
|
14
14
|
|
15
15
|
```ruby
|
16
|
-
|
17
|
-
|
18
|
-
end.flatten
|
16
|
+
require 'factory_girl'
|
17
|
+
require 'factory_girl_rails'
|
19
18
|
```
|
20
19
|
|
21
20
|
=>
|
22
21
|
|
23
22
|
```ruby
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
require 'factory_bot'
|
24
|
+
require 'factory_bot_rails'
|
25
|
+
```
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
FactoryGirl.create(:user)
|
29
|
+
FactoryGirl.build(:user)
|
30
|
+
```
|
31
|
+
|
32
|
+
=>
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
FactoryBot.create(:user)
|
36
|
+
FactoryBot.build(:user)
|
27
37
|
```
|
28
38
|
EOS
|
29
39
|
|
30
|
-
within_files Synvert::
|
31
|
-
|
32
|
-
|
33
|
-
|
40
|
+
within_files Synvert::RAILS_TEST_FILES do
|
41
|
+
find_node '.const[name=FactoryGirl]' do
|
42
|
+
replace_with 'FactoryBot'
|
43
|
+
end
|
44
|
+
|
45
|
+
find_node ".send[receiver=nil][message=require][arguments.size=1][arguments.first='factory_girl']" do
|
46
|
+
replace :arguments, with: "'factory_bot'"
|
47
|
+
end
|
48
|
+
|
49
|
+
with_node type: 'send', receiver: nil, message: 'require', arguments: { size: 1, first: "'factory_girl_rails'" } do
|
50
|
+
replace :arguments, with: "'factory_bot_rails'"
|
34
51
|
end
|
35
52
|
end
|
36
53
|
end
|
@@ -56,6 +73,7 @@ DSLs are as follows
|
|
56
73
|
|
57
74
|
Scopes:
|
58
75
|
|
76
|
+
* [find_node](./Synvert/Core/Rewriter/Instance.html#find_node-instance_method) - recursively find matching ast nodes by node query language
|
59
77
|
* [within_node](./Synvert/Core/Rewriter/Instance.html#within_node-instance_method) - recursively find matching ast nodes
|
60
78
|
* [with_node](./Synvert/Core/Rewriter/Instance.html#with_node-instance_method) - alias to within_node
|
61
79
|
* [goto_node](./Synvert/Core/Rewriter/Instance.html#goto_node-instance_method) - go to a child node
|
data/Rakefile
CHANGED
@@ -2,21 +2,7 @@
|
|
2
2
|
|
3
3
|
require "bundler/gem_tasks"
|
4
4
|
require 'rspec/core/rake_task'
|
5
|
-
RSpec::Core::RakeTask.new(:spec)
|
6
|
-
require 'oedipus_lex'
|
7
|
-
Rake.application.rake_require "oedipus_lex"
|
8
|
-
|
9
|
-
file "lib/synvert/core/node_query/lexer.rex.rb" => "lib/synvert/core/node_query/lexer.rex"
|
10
|
-
file "lib/synvert/core/node_query/parser.racc.rb" => "lib/synvert/core/node_query/parser.y"
|
11
5
|
|
12
|
-
|
13
|
-
task :parser => "lib/synvert/core/node_query/parser.racc.rb"
|
14
|
-
task :generate => [:lexer, :parser]
|
15
|
-
|
16
|
-
rule '.racc.rb' => '.y' do |t|
|
17
|
-
cmd = "bundle exec racc -l -v -o #{t.name} #{t.source}"
|
18
|
-
sh cmd
|
19
|
-
end
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
20
7
|
|
21
8
|
task :default => :spec
|
22
|
-
task :spec => :generate
|