syntax_tree-haml 2.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -1
- data/Gemfile.lock +7 -7
- data/lib/syntax_tree/haml/format.rb +17 -12
- data/lib/syntax_tree/haml/version.rb +1 -1
- data/lib/syntax_tree/haml.rb +13 -11
- data/syntax_tree-haml.gemspec +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93531550f281631f3aa86988c3309f3a48250bd6e218c3712013bbcc1a590480
|
4
|
+
data.tar.gz: f8cf31bae239650f86a13dd8d0bdda41c5eab011bbd1ae829656df387b22b1bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: caac6d625f266b6ac4d5808065573f2ae70de84ad3670cbed2c1cea8089e75e1f8986e5391f0349975ff0d1cb32a65aa114e3d3578207be46b8637358162f06a
|
7
|
+
data.tar.gz: fc8b9c900b04d1a6536ac7d7299d66be150111d11989f855e5bfd17820939fefca789f09fd8c830e761721a3ffc396c2a54865792e9c242e66de498efe5aef8d
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [3.0.0] - 2022-12-23
|
10
|
+
|
11
|
+
### Changed
|
12
|
+
|
13
|
+
- Required syntax_tree version 5.0.1 or higher.
|
14
|
+
- Drop internal pattern matching in order to support Ruby implementations that don't support it.
|
15
|
+
|
9
16
|
## [2.0.0] - 2022-10-18
|
10
17
|
|
11
18
|
### Added
|
@@ -72,7 +79,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|
72
79
|
|
73
80
|
- 🎉 Initial release! 🎉
|
74
81
|
|
75
|
-
[unreleased]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/
|
82
|
+
[unreleased]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v3.0.0...HEAD
|
83
|
+
[3.0.0]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v2.0.0...v3.0.0
|
76
84
|
[2.0.0]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v1.3.2...v2.0.0
|
77
85
|
[1.3.2]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v1.3.1...v1.3.2
|
78
86
|
[1.3.1]: https://github.com/ruby-syntax-tree/syntax_tree-haml/compare/v1.3.0...v1.3.1
|
data/Gemfile.lock
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
syntax_tree-haml (
|
4
|
+
syntax_tree-haml (3.0.0)
|
5
5
|
haml (>= 5.2, != 6.0.0)
|
6
6
|
prettier_print (>= 1.0.0)
|
7
|
-
syntax_tree (>=
|
7
|
+
syntax_tree (>= 5.0.1)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: https://rubygems.org/
|
11
11
|
specs:
|
12
12
|
docile (1.4.0)
|
13
|
-
haml (6.
|
13
|
+
haml (6.1.1)
|
14
14
|
temple (>= 0.8.2)
|
15
15
|
thor
|
16
16
|
tilt
|
17
17
|
minitest (5.16.3)
|
18
|
-
prettier_print (1.0
|
18
|
+
prettier_print (1.1.0)
|
19
19
|
rake (13.0.6)
|
20
20
|
simplecov (0.21.2)
|
21
21
|
docile (~> 1.1)
|
@@ -23,9 +23,9 @@ GEM
|
|
23
23
|
simplecov_json_formatter (~> 0.1)
|
24
24
|
simplecov-html (0.12.3)
|
25
25
|
simplecov_json_formatter (0.1.4)
|
26
|
-
syntax_tree (
|
27
|
-
prettier_print (>= 1.0
|
28
|
-
temple (0.
|
26
|
+
syntax_tree (5.0.1)
|
27
|
+
prettier_print (>= 1.1.0)
|
28
|
+
temple (0.9.1)
|
29
29
|
thor (1.2.1)
|
30
30
|
tilt (2.0.11)
|
31
31
|
|
@@ -4,9 +4,13 @@ module SyntaxTree
|
|
4
4
|
module Haml
|
5
5
|
class Format < Visitor
|
6
6
|
class Formatter < ::SyntaxTree::Formatter
|
7
|
-
attr_reader :literal_lines
|
7
|
+
attr_reader :literal_lines
|
8
8
|
|
9
|
-
def initialize(
|
9
|
+
def initialize(
|
10
|
+
source,
|
11
|
+
*rest,
|
12
|
+
options: ::SyntaxTree::Formatter::Options.new
|
13
|
+
)
|
10
14
|
@literal_lines = {}
|
11
15
|
source
|
12
16
|
.lines
|
@@ -15,7 +19,7 @@ module SyntaxTree
|
|
15
19
|
@literal_lines[index] = line.rstrip if line.start_with?("!")
|
16
20
|
end
|
17
21
|
|
18
|
-
super(source, *rest)
|
22
|
+
super(source, *rest, options: options)
|
19
23
|
end
|
20
24
|
end
|
21
25
|
|
@@ -412,11 +416,11 @@ module SyntaxTree
|
|
412
416
|
def continuation?(node, child)
|
413
417
|
return false if child.type != :silent_script
|
414
418
|
|
415
|
-
case
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
419
|
+
case node.value[:keyword]
|
420
|
+
when "case"
|
421
|
+
%w[in when else].include?(child.value[:keyword])
|
422
|
+
when "if", "unless"
|
423
|
+
%w[elsif else].include?(child.value[:keyword])
|
420
424
|
else
|
421
425
|
false
|
422
426
|
end
|
@@ -434,11 +438,12 @@ module SyntaxTree
|
|
434
438
|
# Take a source string and attempt to parse it into a set of attributes
|
435
439
|
# that can be used to format the source.
|
436
440
|
def parse_attributes(source)
|
437
|
-
|
438
|
-
|
439
|
-
|
441
|
+
program = Ripper.sexp(source)
|
442
|
+
type = program && program[1][0][0]
|
443
|
+
|
444
|
+
if type == :hash && (parsed = ::Haml::AttributeParser.parse(source))
|
440
445
|
parsed.to_h { |key, value| [key, parse_attributes(value)] }
|
441
|
-
|
446
|
+
elsif type == :string_literal
|
442
447
|
SyntaxTree.parse(source).statements.body[0]
|
443
448
|
else
|
444
449
|
LiteralHashValue.new(source)
|
data/lib/syntax_tree/haml.rb
CHANGED
@@ -33,8 +33,8 @@ module SyntaxTree
|
|
33
33
|
|
34
34
|
# This is the main entrypoint for the formatter. It parses the source,
|
35
35
|
# builds a formatter, then pretty prints the result.
|
36
|
-
def self.format(source, maxwidth = 80)
|
37
|
-
formatter = Format::Formatter.new(source, +"", maxwidth)
|
36
|
+
def self.format(source, maxwidth = 80, options: Formatter::Options.new)
|
37
|
+
formatter = Format::Formatter.new(source, +"", maxwidth, options: options)
|
38
38
|
parse(source).format(formatter)
|
39
39
|
|
40
40
|
formatter.flush
|
@@ -59,24 +59,26 @@ class Haml::Parser::ParseNode
|
|
59
59
|
# accept a visitor in order to walk through the tree.
|
60
60
|
def accept(visitor)
|
61
61
|
case type
|
62
|
-
|
62
|
+
when :comment
|
63
63
|
visitor.visit_comment(self)
|
64
|
-
|
64
|
+
when :doctype
|
65
65
|
visitor.visit_doctype(self)
|
66
|
-
|
66
|
+
when :filter
|
67
67
|
visitor.visit_filter(self)
|
68
|
-
|
68
|
+
when :haml_comment
|
69
69
|
visitor.visit_haml_comment(self)
|
70
|
-
|
70
|
+
when :plain
|
71
71
|
visitor.visit_plain(self)
|
72
|
-
|
72
|
+
when :root
|
73
73
|
visitor.visit_root(self)
|
74
|
-
|
74
|
+
when :script
|
75
75
|
visitor.visit_script(self)
|
76
|
-
|
76
|
+
when :silent_script
|
77
77
|
visitor.visit_silent_script(self)
|
78
|
-
|
78
|
+
when :tag
|
79
79
|
visitor.visit_tag(self)
|
80
|
+
else
|
81
|
+
raise "Unknown node type: #{type}"
|
80
82
|
end
|
81
83
|
end
|
82
84
|
|
data/syntax_tree-haml.gemspec
CHANGED
@@ -27,7 +27,7 @@ Gem::Specification.new do |spec|
|
|
27
27
|
# Can't use 6.0.0 due to https://github.com/haml/haml/issues/1085
|
28
28
|
spec.add_dependency "haml", ">= 5.2", "!= 6.0.0"
|
29
29
|
spec.add_dependency "prettier_print", ">= 1.0.0"
|
30
|
-
spec.add_dependency "syntax_tree", ">=
|
30
|
+
spec.add_dependency "syntax_tree", ">= 5.0.1"
|
31
31
|
|
32
32
|
spec.add_development_dependency "bundler"
|
33
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:
|
4
|
+
version: 3.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-
|
11
|
+
date: 2022-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: haml
|
@@ -50,14 +50,14 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
53
|
+
version: 5.0.1
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
60
|
+
version: 5.0.1
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: bundler
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|