Class: Jekyll::WebmentionsStatic::Fetcher
- Inherits:
-
Object
- Object
- Jekyll::WebmentionsStatic::Fetcher
- Defined in:
- lib/jekyll-webmentions-static/fetcher.rb
Constant Summary collapse
- ENDPOINT =
"https://webmention.io/api/mentions.jf2"- DEFAULT_TTL =
3600
Instance Method Summary collapse
-
#fetch_and_group ⇒ Object
Returns a hash keyed by wm-target URL → Array of mention hashes.
-
#initialize(token:, domain:, site_source:, cache: true, cache_ttl: DEFAULT_TTL) ⇒ Fetcher
constructor
A new instance of Fetcher.
Constructor Details
#initialize(token:, domain:, site_source:, cache: true, cache_ttl: DEFAULT_TTL) ⇒ Fetcher
Returns a new instance of Fetcher.
12 13 14 15 16 17 18 19 |
# File 'lib/jekyll-webmentions-static/fetcher.rb', line 12 def initialize(token:, domain:, site_source:, cache: true, cache_ttl: DEFAULT_TTL) @token = token @domain = domain @site_source = site_source @cache = cache @cache_ttl = cache_ttl.to_i @cache_path = File.join(site_source, "_webmentions_cache.json") end |
Instance Method Details
#fetch_and_group ⇒ Object
Returns a hash keyed by wm-target URL → Array of mention hashes.
22 23 24 25 |
# File 'lib/jekyll-webmentions-static/fetcher.rb', line 22 def fetch_and_group raw = load_from_cache || fetch_from_api group_by_target(raw) end |