Class: Webmention::Verification
- Inherits:
-
Object
- Object
- Webmention::Verification
- Defined in:
- lib/webmention/verification.rb
Instance Method Summary collapse
-
#initialize(source_url, target_url, vouch_url: nil) ⇒ Verification
constructor
A new instance of Verification.
-
#inspect ⇒ String
:nocov:.
- #source_mentions_target? ⇒ Boolean
- #verified? ⇒ Boolean
- #verify_vouch? ⇒ Boolean
- #vouch_mentions_source? ⇒ Boolean
Constructor Details
#initialize(source_url, target_url, vouch_url: nil) ⇒ Verification
Returns a new instance of Verification.
8 9 10 11 12 |
# File 'lib/webmention/verification.rb', line 8 def initialize(source_url, target_url, vouch_url: nil) @source_url = source_url @target_url = target_url @vouch_url = vouch_url end |
Instance Method Details
#inspect ⇒ String
:nocov:
16 17 18 19 20 21 |
# File 'lib/webmention/verification.rb', line 16 def inspect "#<#{self.class}:#{format("%#0x", object_id)} " \ "source_url: #{source_url} " \ "target_url: #{target_url} " \ "vouch_url: #{vouch_url}>" end |
#source_mentions_target? ⇒ Boolean
25 26 27 |
# File 'lib/webmention/verification.rb', line 25 def source_mentions_target? @source_mentions_target ||= mentioned_urls(source_url.response).any?(target_url.to_s) end |
#verified? ⇒ Boolean
30 31 32 33 34 |
# File 'lib/webmention/verification.rb', line 30 def verified? return source_mentions_target? unless verify_vouch? source_mentions_target? && vouch_mentions_source? end |
#verify_vouch? ⇒ Boolean
37 38 39 |
# File 'lib/webmention/verification.rb', line 37 def verify_vouch? !vouch_url.nil? && !vouch_url.to_s.strip.empty? end |
#vouch_mentions_source? ⇒ Boolean
42 43 44 45 |
# File 'lib/webmention/verification.rb', line 42 def vouch_mentions_source? @vouch_mentions_source ||= verify_vouch? && mentioned_domains(vouch_url.response).any?(source_url.uri.host) end |