pubsubhubbub
Version, currently 0.1.52 versions
- 0.1.5latestJul 14, 2023
- 0.1.3not indexedAug 4, 2023
github.com/joseafga/pubsubhubbub.cr
Google PubSubHubbub subscriber library written in Crystal.
Installation
# Add this to your shard.yml
dependencies:
pubsubhubbub:
github: joseafga/pubsubhubbub.cr
version: ~> 0.1.5Then run:
shards installshard.yml
- Crystal
1.8.2- License
- MIT
- Author
- José Almeida
Dependencies
This version declares no dependencies.
README
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.5- Tagged
- Jul 14, 2023
- Commit
71f48310933f- Crystal
1.8.2- Indexed
- yes
Dependents
Repository
github.com/joseafga/pubsubhubbub.cr
Metadata
- Created
- Aug 19, 2026
- Updated
- Oct 22, 2026
- Synced
- Oct 22, 2026
- Versions
- 2