Class: Decidim::ContentParsers::ProposalParser
- Inherits:
-
ResourceParser
- Object
- BaseParser
- ResourceParser
- Decidim::ContentParsers::ProposalParser
- Defined in:
- decidim-proposals/lib/decidim/content_parsers/proposal_parser.rb
Overview
A parser that searches mentions of Proposals in content.
This parser accepts two ways for linking Proposals.
-
Using a standard url starting with http or https.
-
With a word starting with ‘~` and digits afterwards will be considered a possible mentioned proposal.
For example ‘~1234`, but no `~ 1234`.
Also fills a ‘Metadata#linked_proposals` attribute.
Defined Under Namespace
Classes: Metadata
Constant Summary
Constants inherited from ResourceParser
ResourceParser::ID_REGEX, ResourceParser::URL_REGEX_CONTENT, ResourceParser::URL_REGEX_END_CHAR, ResourceParser::URL_REGEX_SCHEME
Constants inherited from BaseParser
Instance Attribute Summary collapse
-
#metadata ⇒ Metadata
readonly
abstract
Collects and returns metadata.
Attributes inherited from BaseParser
Instance Method Summary collapse
-
#initialize(content, context) ⇒ ProposalParser
constructor
A new instance of ProposalParser.
Methods inherited from ResourceParser
Methods inherited from BaseParser
Methods included from Decidim::ContentProcessor::Common
#html_content?, #html_fragment
Constructor Details
#initialize(content, context) ⇒ ProposalParser
Returns a new instance of ProposalParser.
22 23 24 25 |
# File 'decidim-proposals/lib/decidim/content_parsers/proposal_parser.rb', line 22 def initialize(content, context) super @metadata = Metadata.new([]) end |
Instance Attribute Details
#metadata ⇒ Metadata (readonly)
Subclass is expected to implement it
Collects and returns metadata. This metadata is accessible at parsing time so it can be acted upon (sending emails to the users) or maybe even stored at the DB for later consultation.
28 29 30 |
# File 'decidim-proposals/lib/decidim/content_parsers/proposal_parser.rb', line 28 def @metadata end |