synvert-core 0.63.1 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/main.yml +1 -1
  3. data/.gitignore +4 -0
  4. data/CHANGELOG.md +9 -1
  5. data/Guardfile +11 -2
  6. data/README.md +74 -34
  7. data/Rakefile +15 -1
  8. data/lib/synvert/core/array_ext.rb +41 -0
  9. data/lib/synvert/core/configuration.rb +12 -0
  10. data/lib/synvert/core/engine/erb.rb +9 -8
  11. data/lib/synvert/core/exceptions.rb +0 -4
  12. data/lib/synvert/core/node_ext.rb +232 -128
  13. data/lib/synvert/core/node_query/compiler/array.rb +34 -0
  14. data/lib/synvert/core/node_query/compiler/attribute.rb +51 -0
  15. data/lib/synvert/core/node_query/compiler/attribute_list.rb +24 -0
  16. data/lib/synvert/core/node_query/compiler/boolean.rb +23 -0
  17. data/lib/synvert/core/node_query/compiler/comparable.rb +79 -0
  18. data/lib/synvert/core/node_query/compiler/dynamic_attribute.rb +51 -0
  19. data/lib/synvert/core/node_query/compiler/expression.rb +88 -0
  20. data/lib/synvert/core/node_query/compiler/float.rb +23 -0
  21. data/lib/synvert/core/node_query/compiler/identifier.rb +41 -0
  22. data/lib/synvert/core/node_query/compiler/integer.rb +23 -0
  23. data/lib/synvert/core/node_query/compiler/invalid_operator_error.rb +7 -0
  24. data/lib/synvert/core/node_query/compiler/nil.rb +23 -0
  25. data/lib/synvert/core/node_query/compiler/parse_error.rb +7 -0
  26. data/lib/synvert/core/node_query/compiler/regexp.rb +37 -0
  27. data/lib/synvert/core/node_query/compiler/selector.rb +51 -0
  28. data/lib/synvert/core/node_query/compiler/string.rb +34 -0
  29. data/lib/synvert/core/node_query/compiler/symbol.rb +23 -0
  30. data/lib/synvert/core/node_query/compiler.rb +24 -0
  31. data/lib/synvert/core/node_query/lexer.rex +96 -0
  32. data/lib/synvert/core/node_query/lexer.rex.rb +293 -0
  33. data/lib/synvert/core/node_query/parser.racc.rb +518 -0
  34. data/lib/synvert/core/node_query/parser.y +84 -0
  35. data/lib/synvert/core/node_query.rb +36 -0
  36. data/lib/synvert/core/rewriter/action/append_action.rb +4 -3
  37. data/lib/synvert/core/rewriter/action/delete_action.rb +17 -8
  38. data/lib/synvert/core/rewriter/action/insert_action.rb +16 -7
  39. data/lib/synvert/core/rewriter/action/insert_after_action.rb +3 -2
  40. data/lib/synvert/core/rewriter/action/prepend_action.rb +3 -2
  41. data/lib/synvert/core/rewriter/action/remove_action.rb +16 -10
  42. data/lib/synvert/core/rewriter/action/replace_action.rb +15 -5
  43. data/lib/synvert/core/rewriter/action/replace_erb_stmt_with_expr_action.rb +18 -11
  44. data/lib/synvert/core/rewriter/action/replace_with_action.rb +6 -5
  45. data/lib/synvert/core/rewriter/action/wrap_action.rb +16 -7
  46. data/lib/synvert/core/rewriter/action.rb +22 -10
  47. data/lib/synvert/core/rewriter/any_value.rb +1 -0
  48. data/lib/synvert/core/rewriter/condition/if_exist_condition.rb +4 -0
  49. data/lib/synvert/core/rewriter/condition/if_only_exist_condition.rb +4 -0
  50. data/lib/synvert/core/rewriter/condition/unless_exist_condition.rb +4 -0
  51. data/lib/synvert/core/rewriter/condition.rb +11 -3
  52. data/lib/synvert/core/rewriter/gem_spec.rb +6 -3
  53. data/lib/synvert/core/rewriter/helper.rb +7 -4
  54. data/lib/synvert/core/rewriter/instance.rb +217 -104
  55. data/lib/synvert/core/rewriter/ruby_version.rb +4 -4
  56. data/lib/synvert/core/rewriter/scope/goto_scope.rb +5 -6
  57. data/lib/synvert/core/rewriter/scope/query_scope.rb +36 -0
  58. data/lib/synvert/core/rewriter/scope/within_scope.rb +10 -5
  59. data/lib/synvert/core/rewriter/scope.rb +8 -0
  60. data/lib/synvert/core/rewriter/warning.rb +1 -1
  61. data/lib/synvert/core/rewriter.rb +91 -43
  62. data/lib/synvert/core/version.rb +1 -1
  63. data/lib/synvert/core.rb +22 -6
  64. data/spec/synvert/core/engine/erb_spec.rb +2 -2
  65. data/spec/synvert/core/node_ext_spec.rb +36 -12
  66. data/spec/synvert/core/node_query/lexer_spec.rb +512 -0
  67. data/spec/synvert/core/node_query/parser_spec.rb +270 -0
  68. data/spec/synvert/core/rewriter/action_spec.rb +0 -4
  69. data/spec/synvert/core/rewriter/condition/if_only_exist_condition_spec.rb +1 -6
  70. data/spec/synvert/core/rewriter/gem_spec_spec.rb +1 -1
  71. data/spec/synvert/core/rewriter/helper_spec.rb +4 -1
  72. data/spec/synvert/core/rewriter/instance_spec.rb +31 -20
  73. data/spec/synvert/core/rewriter/scope/query_scope_spec.rb +74 -0
  74. data/spec/synvert/core/rewriter/scope/within_scope_spec.rb +12 -9
  75. data/spec/synvert/core/rewriter_spec.rb +4 -2
  76. data/synvert-core-ruby.gemspec +7 -2
  77. metadata +91 -4
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: 0.63.1
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-26 00:00:00.000000000 Z
11
+ date: 2022-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -95,7 +95,7 @@ dependencies:
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
- name: rake
98
+ name: guard-rake
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ">="
@@ -109,7 +109,35 @@ dependencies:
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
- name: rspec
112
+ name: oedipus_lex
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: racc
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rake
113
141
  requirement: !ruby/object:Gem::Requirement
114
142
  requirements:
115
143
  - - ">="
@@ -122,6 +150,34 @@ dependencies:
122
150
  - - ">="
123
151
  - !ruby/object:Gem::Version
124
152
  version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rspec
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '='
158
+ - !ruby/object:Gem::Version
159
+ version: 3.10.0
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '='
165
+ - !ruby/object:Gem::Version
166
+ version: 3.10.0
167
+ - !ruby/object:Gem::Dependency
168
+ name: rspec-mocks
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - '='
172
+ - !ruby/object:Gem::Version
173
+ version: 3.10.2
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - '='
179
+ - !ruby/object:Gem::Version
180
+ version: 3.10.2
125
181
  description: convert ruby code to better syntax automatically.
126
182
  email:
127
183
  - flyerhzm@gmail.com
@@ -139,11 +195,35 @@ files:
139
195
  - README.md
140
196
  - Rakefile
141
197
  - lib/synvert/core.rb
198
+ - lib/synvert/core/array_ext.rb
142
199
  - lib/synvert/core/configuration.rb
143
200
  - lib/synvert/core/engine.rb
144
201
  - lib/synvert/core/engine/erb.rb
145
202
  - lib/synvert/core/exceptions.rb
146
203
  - lib/synvert/core/node_ext.rb
204
+ - lib/synvert/core/node_query.rb
205
+ - lib/synvert/core/node_query/compiler.rb
206
+ - lib/synvert/core/node_query/compiler/array.rb
207
+ - lib/synvert/core/node_query/compiler/attribute.rb
208
+ - lib/synvert/core/node_query/compiler/attribute_list.rb
209
+ - lib/synvert/core/node_query/compiler/boolean.rb
210
+ - lib/synvert/core/node_query/compiler/comparable.rb
211
+ - lib/synvert/core/node_query/compiler/dynamic_attribute.rb
212
+ - lib/synvert/core/node_query/compiler/expression.rb
213
+ - lib/synvert/core/node_query/compiler/float.rb
214
+ - lib/synvert/core/node_query/compiler/identifier.rb
215
+ - lib/synvert/core/node_query/compiler/integer.rb
216
+ - lib/synvert/core/node_query/compiler/invalid_operator_error.rb
217
+ - lib/synvert/core/node_query/compiler/nil.rb
218
+ - lib/synvert/core/node_query/compiler/parse_error.rb
219
+ - lib/synvert/core/node_query/compiler/regexp.rb
220
+ - lib/synvert/core/node_query/compiler/selector.rb
221
+ - lib/synvert/core/node_query/compiler/string.rb
222
+ - lib/synvert/core/node_query/compiler/symbol.rb
223
+ - lib/synvert/core/node_query/lexer.rex
224
+ - lib/synvert/core/node_query/lexer.rex.rb
225
+ - lib/synvert/core/node_query/parser.racc.rb
226
+ - lib/synvert/core/node_query/parser.y
147
227
  - lib/synvert/core/rewriter.rb
148
228
  - lib/synvert/core/rewriter/action.rb
149
229
  - lib/synvert/core/rewriter/action/append_action.rb
@@ -167,6 +247,7 @@ files:
167
247
  - lib/synvert/core/rewriter/ruby_version.rb
168
248
  - lib/synvert/core/rewriter/scope.rb
169
249
  - lib/synvert/core/rewriter/scope/goto_scope.rb
250
+ - lib/synvert/core/rewriter/scope/query_scope.rb
170
251
  - lib/synvert/core/rewriter/scope/within_scope.rb
171
252
  - lib/synvert/core/rewriter/warning.rb
172
253
  - lib/synvert/core/version.rb
@@ -174,6 +255,8 @@ files:
174
255
  - spec/support/parser_helper.rb
175
256
  - spec/synvert/core/engine/erb_spec.rb
176
257
  - spec/synvert/core/node_ext_spec.rb
258
+ - spec/synvert/core/node_query/lexer_spec.rb
259
+ - spec/synvert/core/node_query/parser_spec.rb
177
260
  - spec/synvert/core/rewriter/action/append_action_spec.rb
178
261
  - spec/synvert/core/rewriter/action/delete_action_spec.rb
179
262
  - spec/synvert/core/rewriter/action/insert_action_spec.rb
@@ -194,6 +277,7 @@ files:
194
277
  - spec/synvert/core/rewriter/instance_spec.rb
195
278
  - spec/synvert/core/rewriter/ruby_version_spec.rb
196
279
  - spec/synvert/core/rewriter/scope/goto_scope_spec.rb
280
+ - spec/synvert/core/rewriter/scope/query_scope_spec.rb
197
281
  - spec/synvert/core/rewriter/scope/within_scope_spec.rb
198
282
  - spec/synvert/core/rewriter/scope_spec.rb
199
283
  - spec/synvert/core/rewriter/warning_spec.rb
@@ -227,6 +311,8 @@ test_files:
227
311
  - spec/support/parser_helper.rb
228
312
  - spec/synvert/core/engine/erb_spec.rb
229
313
  - spec/synvert/core/node_ext_spec.rb
314
+ - spec/synvert/core/node_query/lexer_spec.rb
315
+ - spec/synvert/core/node_query/parser_spec.rb
230
316
  - spec/synvert/core/rewriter/action/append_action_spec.rb
231
317
  - spec/synvert/core/rewriter/action/delete_action_spec.rb
232
318
  - spec/synvert/core/rewriter/action/insert_action_spec.rb
@@ -247,6 +333,7 @@ test_files:
247
333
  - spec/synvert/core/rewriter/instance_spec.rb
248
334
  - spec/synvert/core/rewriter/ruby_version_spec.rb
249
335
  - spec/synvert/core/rewriter/scope/goto_scope_spec.rb
336
+ - spec/synvert/core/rewriter/scope/query_scope_spec.rb
250
337
  - spec/synvert/core/rewriter/scope/within_scope_spec.rb
251
338
  - spec/synvert/core/rewriter/scope_spec.rb
252
339
  - spec/synvert/core/rewriter/warning_spec.rb