Ruby
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

README.md

webmention-client-ruby

A Ruby gem for sending Webmention and Pingback notifications.

Gem Downloads Build Maintainability Coverage

Key Features

  • Programatically crawls a given URL for mentioned URLs, performs endpoint discovery on mentioned URLs, and sends webmentions and/or pingbacks to mentioned URLs.
  • Provides a CLI for sending webmentions from the given URL to mentioned URLs within a parsed h-entry.

Getting Started

Before installing and using webmention-client-ruby, you'll want to have Ruby 2.4 (or newer) installed. It's recommended that you use a Ruby version managment tool like rbenv, chruby, or rvm.

webmention-client-ruby is developed using Ruby 2.4.4 and is additionally tested against Ruby 2.5.1 using Travis CI.

Installation

If you're using Bundler to manage gem dependencies, add webmention-client-ruby to your project's Gemfile:

source 'https://rubygems.org'

gem 'webmention', '~> 0.1.6'

…and then run:

bundle install

Usage

To send webmentions to all URLs mentioned within an h-entry:

require 'webmention'

client = Webmention::Client.new('https://source.example.com/post/100')
sent_count = client.send_mentions

puts "Webmentions sent: #{sent_count}"

This example will crawl https://source.example.com/post/100, parse its markup for an h-entry, perform endpoint discovery on mentioned URLs, and attempt to send webmentions and/or pingbacks to mentioned URLs.

To send a webmention from a source URL to a target URL:

require 'webmention'

source = 'https://source.example.com/post/100' # A post on your website
target = 'https://target.example.com/post/100' # A post on someone else's website

endpoint = Webmention::Endpoint.discover(target)

if endpoint
  Webmention::Client.send_mention(endpoint, source, target)
end

Command Line Interface

webmention-client-ruby also includes a command line program for manually sending webmentions and pingbacks from a given URL to all mentioned URLs.

$ webmention https://source.example.com/post/100

Acknowledgments

webmention-client-ruby is written and maintained by Aaron Parecki (@aaronpk) and Nat Welch (@icco) with help from these additional contributors.

To learn more about Webmention, see indieweb.org/Webmention and webmention.net.

License

webmention-client-ruby is freely available under the Apache License 2.0. See LICENSE for more details.