synvert-core 1.26.1 → 1.26.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 76425d306537f25b4323935112165ad6bbc02714793e39d7287ee97b884f2284
4
- data.tar.gz: 276cb3ec3ee5685b3233b51105ac1de4233927f3e7bcd89bac01e5d761aa5869
3
+ metadata.gz: 33af6c56062d411c6a6b22460889e1416975ce685fe1d8e8e86c73583ea8c3c3
4
+ data.tar.gz: fc14712ad5a4a95f4c97cfd7cf41dbd51973b43c9a24be9086baf321a626a92e
5
5
  SHA512:
6
- metadata.gz: d0e36b19d07fb73b93898b48833e5419e1f5e258da0c9660cf8584efdb142e6d4495a9a47105884ba558b6f2a2070c83eebfe54aee22f64d5eb4cfd3a3c712e8
7
- data.tar.gz: 6058cc41e9ac61a497d1ddb0f8cb642a48797d67ace1a0e7d513fbae1cce9a7fa50d4a35162caf3e396e0630f5ac394bd63d0a75a83f0a1012a7ef9d8b4a18fc
6
+ metadata.gz: ee2aee51d031543fade41cf86d36d8f3704fac0d1bebaf8d146400a73d277352318216b40c4b2bd819e6cd3dbb865ed8dbac05c6e53800a6e7e993460e0d1b73
7
+ data.tar.gz: 2ea5ae0070defc84ed1e2a157af58c3beab37c04cdc4b18b3528a5339a69aa8a4a02f53515a0fc14381e996bf7374497dc376c408dc305de1552f0db35cf503f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.28.3 (2023-05-13)
4
+
5
+ * Fix haml and slim engine to support attribute and ruby evalidation in the same line
6
+ * Fix ruby block in multi lins in haml and slim
7
+
8
+ ## 1.26.2 (2023-05-10)
9
+
10
+ * Update `node_mutation` to 1.16.0
11
+
3
12
  ## 1.26.1 (2023-05-06)
4
13
 
5
14
  * Compact test results
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- synvert-core (1.26.1)
4
+ synvert-core (1.26.3)
5
5
  activesupport (< 7.0.0)
6
- node_mutation (>= 1.15.3)
6
+ node_mutation (>= 1.16.0)
7
7
  node_query (>= 1.12.1)
8
8
  parallel
9
9
  parser
@@ -48,7 +48,7 @@ GEM
48
48
  method_source (1.0.0)
49
49
  minitest (5.18.0)
50
50
  nenv (0.3.0)
51
- node_mutation (1.15.3)
51
+ node_mutation (1.16.0)
52
52
  node_query (1.12.1)
53
53
  notiffany (0.1.3)
54
54
  nenv (~> 0.1)
@@ -69,6 +69,9 @@ module Synvert::Core
69
69
 
70
70
  while rest.rstrip.end_with?(',')
71
71
  rest = scanner.scan(/.*?(\z|\n)/)
72
+ if IF_KEYWORDS.include?(keyword) || rest =~ DO_BLOCK_REGEX
73
+ leading_spaces_counts << leading_spaces_count
74
+ end
72
75
  new_code << rest
73
76
  end
74
77
  end
@@ -85,6 +88,9 @@ module Synvert::Core
85
88
 
86
89
  while rest.rstrip.end_with?(',')
87
90
  rest = scanner.scan(/.*?(\z|\n)/)
91
+ if rest =~ DO_BLOCK_REGEX
92
+ leading_spaces_counts << leading_spaces_count
93
+ end
88
94
  new_code << rest
89
95
  end
90
96
  end
@@ -28,7 +28,7 @@ module Synvert::Core
28
28
  new_code << (WHITESPACE * scanner.matched.size)
29
29
  scan_matching_wrapper(scanner, new_code, '{', '}')
30
30
  if scanner.scan('=')
31
- new_code << WHITESPACE
31
+ new_code << ';'
32
32
  scan_ruby_expression(scanner, new_code, leading_spaces_counts, leading_spaces_count)
33
33
  else
34
34
  scan_ruby_interpolation_and_plain_text(scanner, new_code, leading_spaces_counts, leading_spaces_count)
@@ -33,7 +33,7 @@ module Synvert::Core
33
33
  end
34
34
  scan_attributes_between_whitespace(scanner, new_code)
35
35
  if scanner.scan(/ ?==?/) # it matches ruby expression " span= current_user.login"
36
- new_code << (WHITESPACE * scanner.matched.size)
36
+ new_code << (WHITESPACE * (scanner.matched.size - 1)) + ';'
37
37
  scan_ruby_expression(scanner, new_code, leading_spaces_counts, leading_spaces_count)
38
38
  else
39
39
  scan_ruby_interpolation_and_plain_text(scanner, new_code, leading_spaces_counts, leading_spaces_count)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Synvert
4
4
  module Core
5
- VERSION = '1.26.1'
5
+ VERSION = '1.26.3'
6
6
  end
7
7
  end
@@ -98,6 +98,14 @@ module Synvert::Core
98
98
  expect(encoded_source).to be_include '{:href=>"/posts", :data => {:author_id => 123, :category => 7}}'
99
99
  end
100
100
 
101
+ it 'encodes attributes with ruby evaluation' do
102
+ source = <<~EOS
103
+ %a{:href=>"/posts", :data => {:author_id => 123, :category => 7}}= current_user.name
104
+ EOS
105
+ encoded_source = Engine::Haml.encode(source)
106
+ expect(encoded_source).to be_include '{:href=>"/posts", :data => {:author_id => 123, :category => 7}}; current_user.name'
107
+ end
108
+
101
109
  it 'encodes class and ID' do
102
110
  source = <<~EOS
103
111
  %div#things
@@ -194,6 +202,17 @@ module Synvert::Core
194
202
  expect(encoded_source).not_to be_include 'See, I can count!'
195
203
  end
196
204
 
205
+ it 'encodes ruby block in multi lines' do
206
+ source = <<~EOS
207
+ = form_for(:document, builder: BootstrapForm,
208
+ html: {id: 'new_document_form', class: 'form-vertical'}) do |f|
209
+ EOS
210
+ encoded_source = Engine::Haml.encode(source)
211
+ expect(encoded_source).to be_include 'form_for'
212
+ expect(encoded_source).to be_include 'do |f|'
213
+ expect(encoded_source).to be_include 'end'
214
+ end
215
+
197
216
  it 'encodes ruby interpolation' do
198
217
  source = 'Look at #{h word} lack of backslash: \#{foo}'
199
218
  encoded_source = Engine::Haml.encode(source)
@@ -131,8 +131,8 @@ module Synvert::Core
131
131
  h2[id="tagline" class="small tagline"] = page_tagline
132
132
  EOS
133
133
  encoded_source = Engine::Slim.encode(source)
134
- expect(encoded_source).to be_include 'page_logo'
135
- expect(encoded_source).to be_include 'page_tagline'
134
+ expect(encoded_source).to be_include '; page_logo'
135
+ expect(encoded_source).to be_include '; page_tagline'
136
136
  expect(encoded_source).not_to be_include 'h1'
137
137
  expect(encoded_source).not_to be_include 'h2'
138
138
  expect(encoded_source).not_to be_include 'id'
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.add_runtime_dependency "activesupport", "< 7.0.0"
23
23
  spec.add_runtime_dependency "node_query", ">= 1.12.1"
24
- spec.add_runtime_dependency "node_mutation", ">= 1.15.3"
24
+ spec.add_runtime_dependency "node_mutation", ">= 1.16.0"
25
25
  spec.add_runtime_dependency "parser"
26
26
  spec.add_runtime_dependency "parser_node_ext", ">= 1.0.0"
27
27
  spec.add_runtime_dependency "parallel"
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.26.1
4
+ version: 1.26.3
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-05-06 00:00:00.000000000 Z
11
+ date: 2023-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 1.15.3
47
+ version: 1.16.0
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.15.3
54
+ version: 1.16.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: parser
57
57
  requirement: !ruby/object:Gem::Requirement