syntax_tree-haml 1.3.2 → 2.0.0

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: bddc6888f36d28a1f0829960a0be5a71edb719342895c68a1635f474fe977634
4
- data.tar.gz: b56774e91f16a8521ca888824f84a4d9dbd3242837d74107add7255f3bc571d7
3
+ metadata.gz: 61fd378df6679c193bda86bdb1f1f78de949b0978c7ec02ec114e1d8fadcd3b5
4
+ data.tar.gz: 1011cad24c3f91ab3086c14b9dda49c6a0093d20c8d3af8fc86286e8dd8851ed
5
5
  SHA512:
6
- metadata.gz: e9b36d29e67e7ea5424825a8344580c3560e7a49672fceb121eec6959a4e0becbb0a8481e935450c3566e6c5647062f90ad6b9411d2d8ce202d2c98b4695eece
7
- data.tar.gz: 35dcaa252fdfe1b53bf8904feb2d312cd7c6f353bc48343f0944a030c315a9289bce62a6578f5c6d5813d992c35681cb9770abd66e2cc5ea53fab3389b8b4f7f
6
+ metadata.gz: 3cfb430120300e2fe6a593a7a47e8be22c09d160960b5a6f6d324e117827d752c648d6111c47d664a8d137cff584aa5fb856d93241c5f7edf2be2360e7e8f8c4
7
+ data.tar.gz: 4e4597ea20a6514cc10ff326db244616ebdd41f11d71095f76ca4aabfb1a1c355e76620e024223ff761e5f9f5bcd0eb868ca62323b2ba669a202da8c0ba13d55
@@ -0,0 +1,22 @@
1
+ name: Dependabot auto-merge
2
+ on: pull_request
3
+
4
+ permissions:
5
+ contents: write
6
+ pull-requests: write
7
+
8
+ jobs:
9
+ dependabot:
10
+ runs-on: ubuntu-latest
11
+ if: ${{ github.actor == 'dependabot[bot]' }}
12
+ steps:
13
+ - name: Dependabot metadata
14
+ id: metadata
15
+ uses: dependabot/fetch-metadata@v1.3.3
16
+ with:
17
+ github-token: "${{ secrets.GITHUB_TOKEN }}"
18
+ - name: Enable auto-merge for Dependabot PRs
19
+ run: gh pr merge --auto --merge "$PR_URL"
20
+ env:
21
+ PR_URL: ${{github.event.pull_request.html_url}}
22
+ GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
@@ -1,14 +1,17 @@
1
1
  name: Main
2
2
  on:
3
- - push
4
- - pull_request_target
3
+ push:
4
+ branches:
5
+ - main
6
+ pull_request: {}
5
7
  jobs:
6
8
  ci:
7
9
  strategy:
8
10
  fail-fast: false
9
11
  matrix:
10
12
  ruby:
11
- - '2.7'
13
+ - '2.7.0'
14
+ - '2.7.5'
12
15
  - '3.0'
13
16
  - '3.1'
14
17
  name: CI
@@ -16,7 +19,7 @@ jobs:
16
19
  env:
17
20
  CI: true
18
21
  steps:
19
- - uses: actions/checkout@master
22
+ - uses: actions/checkout@v3
20
23
  - uses: ruby/setup-ruby@v1
21
24
  with:
22
25
  bundler-cache: true
@@ -25,17 +28,3 @@ jobs:
25
28
  run: |
26
29
  bundle exec rake test
27
30
  bundle exec rake stree:check
28
- automerge:
29
- name: AutoMerge
30
- needs: ci
31
- runs-on: ubuntu-latest
32
- if: github.event_name == 'pull_request_target' && github.actor == 'dependabot[bot]'
33
- steps:
34
- - uses: actions/github-script@v3
35
- with:
36
- script: |
37
- github.pulls.merge({
38
- owner: context.payload.repository.owner.login,
39
- repo: context.payload.repository.name,
40
- pull_number: context.payload.pull_request.number
41
- })
data/CHANGELOG.md CHANGED
@@ -6,6 +6,18 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [2.0.0] - 2022-10-18
10
+
11
+ ### Added
12
+
13
+ - Support for Ruby 2.7.0, not just 2.7.3
14
+ - Require syntax_tree 4.0.1 or higher.
15
+ - Require prettier_print 1.0.0 or higher.
16
+
17
+ ### Changed
18
+
19
+ - Nodes must now be formatted with a `SyntaxTree::Haml::Formatter`.
20
+
9
21
  ## [1.3.2] - 2022-09-19
10
22
 
11
23
  ### Added
@@ -60,7 +72,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
60
72
 
61
73
  - 🎉 Initial release! 🎉
62
74
 
63
- [unreleased]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v1.3.2...HEAD
75
+ [unreleased]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v2.0.0...HEAD
76
+ [2.0.0]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v1.3.2...v2.0.0
64
77
  [1.3.2]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v1.3.1...v1.3.2
65
78
  [1.3.1]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v1.3.0...v1.3.1
66
79
  [1.3.0]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v1.2.1...v1.3.0
data/Gemfile.lock CHANGED
@@ -1,20 +1,21 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- syntax_tree-haml (1.3.2)
5
- haml (>= 5.2)
6
- prettier_print
7
- syntax_tree (>= 2.0.1)
4
+ syntax_tree-haml (2.0.0)
5
+ haml (>= 5.2, != 6.0.0)
6
+ prettier_print (>= 1.0.0)
7
+ syntax_tree (>= 4.0.0)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
12
  docile (1.4.0)
13
- haml (5.2.2)
14
- temple (>= 0.8.0)
13
+ haml (6.0.7)
14
+ temple (>= 0.8.2)
15
+ thor
15
16
  tilt
16
17
  minitest (5.16.3)
17
- prettier_print (0.1.0)
18
+ prettier_print (1.0.1)
18
19
  rake (13.0.6)
19
20
  simplecov (0.21.2)
20
21
  docile (~> 1.1)
@@ -22,9 +23,10 @@ GEM
22
23
  simplecov_json_formatter (~> 0.1)
23
24
  simplecov-html (0.12.3)
24
25
  simplecov_json_formatter (0.1.4)
25
- syntax_tree (3.6.0)
26
- prettier_print
26
+ syntax_tree (4.0.1)
27
+ prettier_print (>= 1.0.1)
27
28
  temple (0.8.2)
29
+ thor (1.2.1)
28
30
  tilt (2.0.11)
29
31
 
30
32
  PLATFORMS
@@ -6,7 +6,7 @@ module SyntaxTree
6
6
  class Formatter < ::SyntaxTree::Formatter
7
7
  attr_reader :literal_lines, :quote
8
8
 
9
- def initialize(source, ...)
9
+ def initialize(source, *rest)
10
10
  @literal_lines = {}
11
11
  source
12
12
  .lines
@@ -15,7 +15,7 @@ module SyntaxTree
15
15
  @literal_lines[index] = line.rstrip if line.start_with?("!")
16
16
  end
17
17
 
18
- super(source, ...)
18
+ super(source, *rest)
19
19
  end
20
20
  end
21
21
 
@@ -62,11 +62,17 @@ module SyntaxTree
62
62
  q.text(node.value[:name])
63
63
 
64
64
  q.indent do
65
- q.breakable(force: true)
65
+ q.breakable_force
66
+ first = true
66
67
 
67
- segments = node.value[:text].strip.split("\n")
68
- q.seplist(segments, -> { q.breakable(force: true) }) do |segment|
69
- q.text(segment)
68
+ node.value[:text].each_line(chomp: true) do |line|
69
+ if first
70
+ first = false
71
+ else
72
+ q.breakable_force
73
+ end
74
+
75
+ q.text(line)
70
76
  end
71
77
  end
72
78
  end
@@ -78,11 +84,19 @@ module SyntaxTree
78
84
  text = node.value[:text].strip
79
85
 
80
86
  if text.include?("\n")
81
- separator = -> { q.breakable(force: true) }
82
-
83
87
  q.indent do
84
- separator.call
85
- q.seplist(text.split("\n"), separator) { |segment| q.text(segment) }
88
+ q.breakable_force
89
+ first = true
90
+
91
+ text.each_line(chomp: true) do |line|
92
+ if first
93
+ first = false
94
+ else
95
+ q.breakable_force
96
+ end
97
+
98
+ q.text(line)
99
+ end
86
100
  end
87
101
  else
88
102
  q.text(" #{text}")
@@ -104,7 +118,7 @@ module SyntaxTree
104
118
  def visit_root(node)
105
119
  node.children.each do |child|
106
120
  visit(child)
107
- q.breakable(force: true)
121
+ q.breakable_force
108
122
  end
109
123
  end
110
124
 
@@ -130,11 +144,11 @@ module SyntaxTree
130
144
 
131
145
  node.children.each do |child|
132
146
  if continuation?(node, child)
133
- q.breakable(force: true)
147
+ q.breakable_force
134
148
  visit(child)
135
149
  else
136
150
  q.indent do
137
- q.breakable(force: true)
151
+ q.breakable_force
138
152
  visit(child)
139
153
  end
140
154
  end
@@ -143,7 +157,6 @@ module SyntaxTree
143
157
  end
144
158
 
145
159
  LiteralHashValue = Struct.new(:value)
146
-
147
160
  StringHashValue = Struct.new(:value, :quote)
148
161
 
149
162
  # When formatting a tag, there are a lot of different kinds of things that
@@ -201,6 +214,14 @@ module SyntaxTree
201
214
  end
202
215
 
203
216
  class HTMLAttributesPart
217
+ class Separator
218
+ def call(q)
219
+ q.fill_breakable
220
+ end
221
+ end
222
+
223
+ SEPARATOR = Separator.new
224
+
204
225
  attr_reader :values
205
226
 
206
227
  def initialize(raw)
@@ -214,11 +235,9 @@ module SyntaxTree
214
235
  q.group do
215
236
  q.text("(")
216
237
  q.nest(align) do
217
- q.seplist(
218
- values,
219
- -> { q.fill_breakable },
220
- :each_pair
221
- ) { |key, value| q.text("#{key}=#{value}") }
238
+ q.seplist(values, SEPARATOR, :each_pair) do |key, value|
239
+ q.text("#{key}=#{value}")
240
+ end
222
241
  end
223
242
  q.text(")")
224
243
  end
@@ -249,7 +268,7 @@ module SyntaxTree
249
268
  q.text("{")
250
269
  q.indent do
251
270
  q.group do
252
- q.breakable(level == 0 ? "" : " ")
271
+ level == 0 ? q.breakable_empty : q.breakable_space
253
272
  q.seplist(hash, nil, :each_pair) do |key, value|
254
273
  if key.match?(/^@|[-:]/)
255
274
  q.text("#{quote}#{Quotes.normalize(key, quote)}#{quote}:")
@@ -275,7 +294,7 @@ module SyntaxTree
275
294
  end
276
295
  end
277
296
 
278
- q.breakable(level == 0 ? "" : " ")
297
+ level == 0 ? q.breakable_empty : q.breakable_space
279
298
  q.text("}")
280
299
  end
281
300
  end
@@ -363,7 +382,7 @@ module SyntaxTree
363
382
  q.indent do
364
383
  # Split between the declaration of the tag and the contents of the
365
384
  # tag.
366
- q.breakable("")
385
+ q.breakable_empty
367
386
 
368
387
  if node.value[:parse] && value.match?(/#[{$@]/)
369
388
  # There's a weird case here where if the value includes
@@ -373,8 +392,7 @@ module SyntaxTree
373
392
  q.if_break { q.text("") }.if_flat { q.text(" ") }
374
393
  q.text(value[1...-1].gsub(/\\"/, "\""))
375
394
  elsif node.value[:parse]
376
- q.text("= ")
377
- q.text(value)
395
+ q.text("= #{value}")
378
396
  else
379
397
  q.if_break { q.text("") }.if_flat { q.text(" ") }
380
398
  q.text(value)
@@ -413,8 +431,8 @@ module SyntaxTree
413
431
  end
414
432
  end
415
433
 
416
- # Take a source string and attempt to parse it into a set of attributes that
417
- # can be used to format the source.
434
+ # Take a source string and attempt to parse it into a set of attributes
435
+ # that can be used to format the source.
418
436
  def parse_attributes(source)
419
437
  case Ripper.sexp(source)
420
438
  in [:program, [[:hash, *], *]] if parsed =
@@ -435,7 +453,7 @@ module SyntaxTree
435
453
  q.group { yield }
436
454
  q.indent do
437
455
  node.children.each do |child|
438
- q.breakable(force: true)
456
+ q.breakable_force
439
457
  visit(child)
440
458
  end
441
459
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module SyntaxTree
4
4
  module Haml
5
- VERSION = "1.3.2"
5
+ VERSION = "2.0.0"
6
6
  end
7
7
  end
@@ -24,9 +24,10 @@ Gem::Specification.new do |spec|
24
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
25
  spec.require_paths = %w[lib]
26
26
 
27
- spec.add_dependency "haml", ">= 5.2"
28
- spec.add_dependency "prettier_print"
29
- spec.add_dependency "syntax_tree", ">= 2.0.1"
27
+ # Can't use 6.0.0 due to https://github.com/haml/haml/issues/1085
28
+ spec.add_dependency "haml", ">= 5.2", "!= 6.0.0"
29
+ spec.add_dependency "prettier_print", ">= 1.0.0"
30
+ spec.add_dependency "syntax_tree", ">= 4.0.0"
30
31
 
31
32
  spec.add_development_dependency "bundler"
32
33
  spec.add_development_dependency "minitest"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syntax_tree-haml
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Newton
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-19 00:00:00.000000000 Z
11
+ date: 2022-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: haml
@@ -17,6 +17,9 @@ dependencies:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '5.2'
20
+ - - "!="
21
+ - !ruby/object:Gem::Version
22
+ version: 6.0.0
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -24,34 +27,37 @@ dependencies:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '5.2'
30
+ - - "!="
31
+ - !ruby/object:Gem::Version
32
+ version: 6.0.0
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: prettier_print
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - ">="
32
38
  - !ruby/object:Gem::Version
33
- version: '0'
39
+ version: 1.0.0
34
40
  type: :runtime
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
44
  - - ">="
39
45
  - !ruby/object:Gem::Version
40
- version: '0'
46
+ version: 1.0.0
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: syntax_tree
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
51
  - - ">="
46
52
  - !ruby/object:Gem::Version
47
- version: 2.0.1
53
+ version: 4.0.0
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
58
  - - ">="
53
59
  - !ruby/object:Gem::Version
54
- version: 2.0.1
60
+ version: 4.0.0
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: bundler
57
63
  requirement: !ruby/object:Gem::Requirement
@@ -116,6 +122,7 @@ extensions: []
116
122
  extra_rdoc_files: []
117
123
  files:
118
124
  - ".github/dependabot.yml"
125
+ - ".github/workflows/auto-merge.yml"
119
126
  - ".github/workflows/main.yml"
120
127
  - ".gitignore"
121
128
  - CHANGELOG.md