custom_elements_manifest_parser 0.2.0 → 0.2.1

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: 66c8bdbc69aa76da418725dd7a36f155378aa6af3e88a8d2743e519c2edea4f0
4
- data.tar.gz: 966d6a3b1678f7d8ab2135db6248fbd0cfa86f72ee0f0ad5971f4f61f5a56788
3
+ metadata.gz: b034129185a15c3ecc863a4dbad481f9a74dd3c56dfdacae153388233afd274b
4
+ data.tar.gz: d1117275df17115129e2252d8b460b4cee37122785e8c0e7fe3b62ad3e5d43ba
5
5
  SHA512:
6
- metadata.gz: 8ff7c6e45d310418da1a780b2ba26a88382c91f0e682dccdb8159fdc3ae5aa36af0d2629003bbd92fd622d401533956a4e637a06f83e50b97c4fbb9a430b9832
7
- data.tar.gz: 3a5aafc4e04d5619e2f15bef227e1a7e7d741e03caaa1587d3aee0a6533b7608a9816bd475b2a8275ae93478a157d664d5e7f7383100b651a615718925797069
6
+ metadata.gz: 4baa54509b17090097ba88f6b13027d286b6a78203109e944cacef0b80bd88c9504fbc82b7b28226a89411c99ddacfd13404e35e0b0180ed2f9192db41326058
7
+ data.tar.gz: 75f9b399a7b70b82c058c21b3c821aa3b2d593e54ead8912f7843b1c37d3f66d5b4eb161bbf863c7b725d1cafccdb4131dc9d19976befe32ecd6f31658c56fba
data/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
- ## [Unreleased]
1
+ ## Unreleased
2
2
 
3
- # [0.2.0] - 10/07/2023
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- custom_elements_manifest_parser (0.2.0)
4
+ custom_elements_manifest_parser (0.2.1)
5
5
  dry-struct (~> 1.0)
6
6
  dry-types (~> 1.0)
7
7
  dry-validation (~> 1.0)
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"] # => declaration
67
- hash["light-preview"] # => declaration
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CustomElementsManifestParser
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: custom_elements_manifest_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - konnorrogers