syntax_tree-array_brackets 0.1.0 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -1
- data/Rakefile +1 -1
- data/lib/syntax_tree/array_brackets/version.rb +1 -1
- data/lib/syntax_tree/node.rb +46 -20
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49b660457db14aff9dcbd80f2c32d80f90572e5eb29926649c5a917da00c283d
|
4
|
+
data.tar.gz: fdc99b74a18cd62d1b7f1aa447abdee845e7ffc64ffbd530cded7f0a34f0af37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 299e44a474ec394a6acb7387c4bad12b299b3d8b9a43cc67327424cca01ae5d6686252771086e6b86cdfc2740cf298b73e58f785b23be0675ef4c4eb81da375d
|
7
|
+
data.tar.gz: 90f32e7ddb3d3902c574e9d0e0896e255239d1bc6e3d6609c07b8808b07bf42261263fc7bb7a7752efab5016ad1bdbc6cf2f618d4ea193c4a3e71865cf64bf39
|
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
data/lib/syntax_tree/node.rb
CHANGED
@@ -37,17 +37,19 @@ module SyntaxTree
|
|
37
37
|
q.group do
|
38
38
|
q.text(opening)
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
40
|
+
unless elements.empty?
|
41
|
+
loc = elements.first.location.to(elements.last.location)
|
42
|
+
str_contents =
|
43
|
+
elements.map do |element|
|
44
|
+
StringContent.new(parts: [element], location: nil)
|
45
|
+
end
|
46
|
+
contents = Args.new(parts: str_contents, location: loc)
|
46
47
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
48
|
+
q.indent do
|
49
|
+
q.breakable_empty
|
50
|
+
q.format(contents)
|
51
|
+
q.if_break { q.text(",") } if q.trailing_comma?
|
52
|
+
end
|
51
53
|
end
|
52
54
|
|
53
55
|
q.breakable_empty
|
@@ -63,22 +65,46 @@ module SyntaxTree
|
|
63
65
|
q.group do
|
64
66
|
q.text(opening)
|
65
67
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
end
|
71
|
-
contents = Args.new(parts: str_contents, location: loc)
|
68
|
+
unless elements.empty?
|
69
|
+
loc = elements.first.location.to(elements.last.location)
|
70
|
+
literals = convert_to_literals(q, elements)
|
71
|
+
contents = Args.new(parts: literals, location: loc)
|
72
72
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
73
|
+
q.indent do
|
74
|
+
q.breakable_empty
|
75
|
+
q.format(contents)
|
76
|
+
q.if_break { q.text(",") } if q.trailing_comma?
|
77
|
+
end
|
77
78
|
end
|
78
79
|
|
79
80
|
q.breakable_empty
|
80
81
|
q.text(closing)
|
81
82
|
end
|
82
83
|
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
def convert_to_literals(q, elements)
|
88
|
+
elements.map do |element|
|
89
|
+
value =
|
90
|
+
if element.value.intern.inspect.include?("\"") # consider symbols like :"foo:bar", :"?"
|
91
|
+
value = get_intern_representation(q, element.value)
|
92
|
+
element.copy(value: value, location: element.location)
|
93
|
+
else
|
94
|
+
element
|
95
|
+
end
|
96
|
+
|
97
|
+
SymbolLiteral.new(value: value, location: nil)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def get_intern_representation(q, value)
|
102
|
+
if value == q.quote
|
103
|
+
return "\"\\\"\"" if q.quote == "\""
|
104
|
+
return "\'\\\'\'" if q.quote == "'" # rubocop:disable Style/RedundantStringEscape
|
105
|
+
end
|
106
|
+
|
107
|
+
"#{q.quote}#{value}#{q.quote}"
|
108
|
+
end
|
83
109
|
end
|
84
110
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: syntax_tree-array_brackets
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nobuo Takizawa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: syntax_tree
|