Module: BlueFactory

Extended by:
Configurable, Feeds, Interactions
Defined in:
lib/blue_factory.rb,
lib/blue_factory/errors.rb,
lib/blue_factory/server.rb,
lib/blue_factory/version.rb,
lib/blue_factory/user_info.rb,
lib/blue_factory/interaction.rb,
lib/blue_factory/feed_handler.rb,
lib/blue_factory/configuration.rb,
lib/blue_factory/modules/feeds.rb,
lib/blue_factory/tasks/support.rb,
lib/blue_factory/request_context.rb,
lib/blue_factory/output_generator.rb,
lib/blue_factory/modules/configurable.rb,
lib/blue_factory/modules/interactions.rb

Overview

This is the main module of the library, through which you configure the feed service.

Examples:

Configuring the server and feeds

require 'blue_factory'

BlueFactory.set :publisher_did, 'did:plc:qwertyuiopasdf'
BlueFactory.set :hostname, 'feeds.example.com'

BlueFactory.add_feed 'photos', PhotographyFeed.new

Handling interactions

BlueFactory.on_interactions do |interactions, context|
  interactions.each do |i|
    unless i.type == :seen
      puts "[#{Time.now}] #{context.user.raw_did}: #{i.type} #{i.item}"
    end
  end
end

Defined Under Namespace

Modules: Configurable, Feeds, Interactions, Net Classes: AuthorizationError, ConfigurationError, FeedHandler, Interaction, InvalidFeedClassError, InvalidRequestError, InvalidResponseError, OutputGenerator, RequestContext, Server, UnsupportedAlgorithmError, UserInfo

Constant Summary collapse

FEED_GENERATOR_TYPE =

The collection NSID of a Bluesky feed generator service.

'app.bsky.feed.generator'
MAX_LIMIT =

Maximum allowed value for the limit parameter in getFeedSkeleton.

100
DEFAULT_LIMIT =

Default value for the limit parameter in getFeedSkeleton. This value isn't used by the library (if no limit parameter is passed, it isn't added), but you can use it as a fallback in your code.

50
VERSION =
"0.3.0"

Constants included from Feeds

Feeds::RKEY_REGEXP

Class Method Summary collapse

Methods included from Configurable

set

Methods included from Feeds

add_feed, all_feeds, feed_keys, get_feed

Methods included from Interactions

interactions_handler, interactions_handler=, on_interactions

Class Method Details

.environmentSymbol

Current application environment, usually :development or :production. It's read from the env variables APP_ENV or RACK_ENV, or :development by default.



30
31
32
# File 'lib/blue_factory/configuration.rb', line 30

def self.environment
  (ENV['APP_ENV'] || ENV['RACK_ENV'] || :development).to_sym
end

.hostnameString?

The hostname on which the feed server runs. Configured through BlueFactory::Configurable#set.



# File 'lib/blue_factory/configuration.rb', line 34

.publisher_didString?

The DID of the account publishing the feeds. Configured through BlueFactory::Configurable#set.



42
# File 'lib/blue_factory/configuration.rb', line 42

configurable :publisher_did, :hostname

.service_didString

The server's did:web: service DID built from the configured hostname.

Raises:



16
17
18
19
20
21
22
# File 'lib/blue_factory/configuration.rb', line 16

def self.service_did
  if hostname.nil?
    raise ConfigurationError, "The `hostname` property is not set. Set it with: BlueFactory.set(:hostname, 'example.com')"
  end

  'did:web:' + hostname
end