Module: BlueFactory::Feeds Private

Included in:
BlueFactory
Defined in:
lib/blue_factory/modules/feeds.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Adds configuration for feeds and provides lookup of configured feeds to BlueFactory. Use these APIs through the main BlueFactory module, not directly.

Constant Summary collapse

RKEY_REGEXP =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

/\A[A-Za-z0-9\.\-_:~]+\z/

Instance Method Summary collapse

Instance Method Details

#add_feed(key, feed_handler) ⇒ Object

Registers a feed handler for a given rkey. The full AT URI of the feed generator, which is listed in describeFeedGenerator and expected in the feed parameter to getFeedSkeleton will be: "at://#{publisher_did}/app.bsky.feed.generator/#{key}". The key should be a string no longer than 15 characters and should not contain slashes, preferably only lowercase letters, digits and hyphens.

The feed handler is expected to be an object which has a #get_posts method which accepts requests routed from the BlueFactory server and returns post data in a specified format. See the abstract BlueFactory::FeedHandler class for a description of the expected API.

Parameters:

  • key (String)

    the feed rkey

  • feed_handler (#get_posts)

    feed implementation object

Raises:



35
36
37
38
39
40
# File 'lib/blue_factory/modules/feeds.rb', line 35

def add_feed(key, feed_handler)
  validate_key(key)
  validate_feed(key, feed_handler)

  @feeds[key.to_s] = feed_handler
end

#all_feedsArray<#get_posts>

Returns an array of all registered feed handler objects.

Returns:

  • (Array<#get_posts>)


69
70
71
# File 'lib/blue_factory/modules/feeds.rb', line 69

def all_feeds
  @feeds.values
end

#feed_keysArray<String>

Lists all configured feed keys.

Returns:

  • (Array<String>)


48
49
50
# File 'lib/blue_factory/modules/feeds.rb', line 48

def feed_keys
  @feeds.keys
end

#get_feed(key) ⇒ #get_posts?

Returns a feed handler configured for a given rkey.

Parameters:

  • key (String)

    feed key

Returns:

  • (#get_posts, nil)

    feed object, if registered



59
60
61
# File 'lib/blue_factory/modules/feeds.rb', line 59

def get_feed(key)
  @feeds[key.to_s]
end