Module: Html2rss::Config::Schema::Selectors
- Defined in:
- lib/html2rss/config/schema.rb
Overview
Provides schema fragments that document selector configuration.
Constant Summary collapse
- RESERVED_SELECTOR_PATTERN =
'^(?!items$|enclosure$|guid$|categories$).+$'
Class Method Summary collapse
- .dynamic_selector_schema ⇒ Object
- .enclosure_schema ⇒ Object
- .items_schema ⇒ Object
-
.pattern_properties ⇒ Object
rubocop:enable Layout/LineLength.
-
.reference_array(description) ⇒ Object
JSON Schema can enforce non-empty reference arrays, while runtime validation remains authoritative for checking that each entry points to an existing sibling selector key.
- .schema ⇒ Object
-
.selector_properties ⇒ Object
rubocop:disable Layout/LineLength.
Class Method Details
.dynamic_selector_schema ⇒ Object
152 153 154 155 156 |
# File 'lib/html2rss/config/schema.rb', line 152 def dynamic_selector_schema Html2rss::Selectors::Config::Selector.new.schema.json_schema(loose: true).merge( description: 'Dynamic selector definition keyed by attribute name.' ) end |
.enclosure_schema ⇒ Object
164 165 166 167 168 |
# File 'lib/html2rss/config/schema.rb', line 164 def enclosure_schema Html2rss::Selectors::Config::Enclosure.new.schema.json_schema(loose: true).merge( description: 'Describes enclosure extraction settings.' ) end |
.items_schema ⇒ Object
158 159 160 161 162 |
# File 'lib/html2rss/config/schema.rb', line 158 def items_schema Html2rss::Selectors::Config::Items.new.schema.json_schema(loose: true).merge( description: 'Defines the items selector and optional enhancement settings.' ) end |
.pattern_properties ⇒ Object
rubocop:enable Layout/LineLength
148 149 150 |
# File 'lib/html2rss/config/schema.rb', line 148 def pattern_properties { RESERVED_SELECTOR_PATTERN => dynamic_selector_schema } end |
.reference_array(description) ⇒ Object
JSON Schema can enforce non-empty reference arrays, while runtime validation remains authoritative for checking that each entry points to an existing sibling selector key.
173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/html2rss/config/schema.rb', line 173 def reference_array(description) { type: 'array', description:, minItems: 1, items: { type: 'string', description: 'Selector key defined elsewhere in this object.' } } end |
.schema ⇒ Object
127 128 129 130 131 132 133 134 135 |
# File 'lib/html2rss/config/schema.rb', line 127 def schema { type: 'object', description: 'Selectors used to extract article attributes.', properties: selector_properties, patternProperties: pattern_properties, additionalProperties: true } end |
.selector_properties ⇒ Object
rubocop:disable Layout/LineLength
138 139 140 141 142 143 144 145 |
# File 'lib/html2rss/config/schema.rb', line 138 def selector_properties { items: items_schema, enclosure: enclosure_schema, guid: reference_array('List of selector keys used to build the GUID. Each entry must reference a sibling selector key; runtime validation enforces those references.'), categories: reference_array('List of selector keys whose values will be used as categories. Each entry must reference a sibling selector key; runtime validation enforces those references.') } end |