pubsubhubbub
Version, currently 0.1.32 versions
- 0.1.5latestJul 14, 2023
- 0.1.3not indexedAug 4, 2023
github.com/joseafga/pubsubhubbub.cr
Google PubSubHubbub subscriber library written in Crystal.
Nothing has been indexed for 0.1.3 yet. The tag is recorded, its shard.yml has not been read, so the manifest and dependency list below are empty because they are unknown rather than because they are absent.
Installation
# Add this to your shard.yml
dependencies:
pubsubhubbub:
github: joseafga/pubsubhubbub.cr
version: ~> 0.1.3Then run:
shards installshard.yml
No shard.yml has been indexed for 0.1.3. You can read it on the repository.
Dependencies
Unknown: the shard.yml for this version has not been read yet.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
PubSubHubbub.cr
PubSubHubbub subscriber library written in Crystal.
Installation
-
Add the dependency to your
shard.yml:dependencies: pubsubhubbub: github: joseafga/pubsubhubbub.cr -
Run
shards install
Usage
Basic
require "pubsubhubbub"
PubSubHubbub.configure do |settings|
settings.callback = "https://www.example.com/pubsubhubbub/some/path"
end
subscriber = PubSubHubbub::Subscriber.new "https://www.youtube.com/xml/feeds/videos.xml?channel_id=SomeChannelId"
subscriber.subscribe
HTTP Server
Basic usage allows sending requests to the server but new requests will be sent to the host address (configured in PubSubHubbub.configure) and will expect a specific response. To deal with this, we will need an HTTP::Server, fortunately PubSubHubbub.cr already has a handler created to be used together with HTTP::Server, which should provide the necessary functions for the most of use cases.
require "pubsubhubbub"
require "http"
class MyClass
class_getter subscriber = PubSubHubbub::Subscriber.new("https://www.youtube.com/xml/feeds/videos.xml?channel_id=SomeChannelId")
# `SubscriberHandler` uses to handle incoming requests from Hub.
# This is used to make more dynamic, so that it is possible to find a value from an array or
# database.
def self.find_subscriber!(topic : String?) : PubSubHubbub::Subscriber
subscriber
end
end
# This hook will execute when it receives a notification.
PubSubHubbub::Subscriber.on :notify do |subscriber, xml|
puts "Receiving notification from #{subscriber.topic}: #{xml}"
end
server = HTTP::Server.new([
PubSubHubbub::ErrorHandler.new,
PubSubHubbub::SubscriberHandler(MyClass).new,
])
address = server.bind_tcp 8080
puts "Listening on http://#{address}"
server.listen
Contributing
- Fork it (https://github.com/joseafga/pubsubhubbub.cr/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- José Almeida - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.3- Tagged
- Aug 4, 2023
- Commit
c20f81eb6583- Indexed
- not yet
Dependents
Repository
github.com/joseafga/pubsubhubbub.cr
Metadata
- Created
- Aug 19, 2026
- Updated
- Oct 22, 2026
- Synced
- Oct 22, 2026
- Versions
- 2