custom_elements_manifest_parser 0.2.0 → 0.2.1
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 +6 -2
- data/Gemfile.lock +1 -1
- data/README.md +6 -2
- data/lib/custom_elements_manifest_parser/parser.rb +18 -0
- data/lib/custom_elements_manifest_parser/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b034129185a15c3ecc863a4dbad481f9a74dd3c56dfdacae153388233afd274b
|
4
|
+
data.tar.gz: d1117275df17115129e2252d8b460b4cee37122785e8c0e7fe3b62ad3e5d43ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4baa54509b17090097ba88f6b13027d286b6a78203109e944cacef0b80bd88c9504fbc82b7b28226a89411c99ddacfd13404e35e0b0180ed2f9192db41326058
|
7
|
+
data.tar.gz: 75f9b399a7b70b82c058c21b3c821aa3b2d593e54ead8912f7843b1c37d3f66d5b4eb161bbf863c7b725d1cafccdb4131dc9d19976befe32ecd6f31658c56fba
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
-
##
|
1
|
+
## Unreleased
|
2
2
|
|
3
|
-
|
3
|
+
## [0.2.1] - 10/07/2023
|
4
|
+
|
5
|
+
- Added a `Parser#find_all_tag_names` method to the parser that returns a Hash keyed off the tag name.
|
6
|
+
|
7
|
+
## [0.2.0] - 10/07/2023
|
4
8
|
|
5
9
|
- Added a `Parser#find_by_tag_names(['tag-name'])` method to the parser that returns a Hash keyed off the tag name.
|
6
10
|
- Removed `tag_names` as a parameters for `Parser#find_custom_elements`
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -63,8 +63,12 @@ end
|
|
63
63
|
hash = parser.find_by_tag_names("light-pen", "light-preview")
|
64
64
|
hash = parser.find_by_tag_names(["light-pen", "light-preview"])
|
65
65
|
|
66
|
-
hash["light-pen"] # =>
|
67
|
-
hash["light-preview"] # =>
|
66
|
+
hash["light-pen"] # => ClassDeclaration
|
67
|
+
hash["light-preview"] # => ClassDeclaration
|
68
|
+
|
69
|
+
# Finds every declaration with a "tagName"
|
70
|
+
hash = parser.find_all_tag_names
|
71
|
+
hash["light-preview"] # => ClassDeclaration
|
68
72
|
|
69
73
|
# Searches for all custom elements regardless of tagName
|
70
74
|
parser.find_custom_elements.each do |declaration|
|
@@ -122,5 +122,23 @@ module CustomElementsManifestParser
|
|
122
122
|
|
123
123
|
custom_elements
|
124
124
|
end
|
125
|
+
|
126
|
+
# @return [Hash{String => Nodes::ClassDeclaration}] - Returns a hash keyed off of found tagNames.
|
127
|
+
def find_all_tag_names
|
128
|
+
custom_elements = {}
|
129
|
+
|
130
|
+
manifest.modules.flatten.each do |mod|
|
131
|
+
mod.declarations.flatten.each do |dec|
|
132
|
+
# Needs to be != true because == false fails nil checks.
|
133
|
+
next if dec.attributes[:customElement] != true
|
134
|
+
|
135
|
+
tag_name = dec.attributes[:tagName]
|
136
|
+
|
137
|
+
custom_elements[tag_name] = dec if tag_name
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
custom_elements
|
142
|
+
end
|
125
143
|
end
|
126
144
|
end
|