No release in over 3 years
Low commit activity in last 3 years
MediaWiki::Butt provides a fully-featured interface to the MediaWiki API. It includes methods for changing wiki content, authentication, and queries.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

~> 0.13
 Project Readme

MediaWiki::Butt

Gem Version Build Status

A Ruby library for the MediaWiki API.

Why?

Two of the main editors at the FTB Gamepedia site found that the lack of functional Ruby Gems for MediaWiki API interactions made it difficult to interact with the wiki through IRC bots (ESAEBSAD and SatanicBot) and scripts. Some core features were either missing entirely or severely out of date in the many other MediaWiki gems, such as basic queries needed for everyday-actions like getting page contents and page backlinks.

MediaWiki::Butt actually began as two local libraries that @xbony2 and @elifoster, the two developers of this gem, worked on separately in their own IRC bot repositories, called wikiutils. This was an extremely basic API interface for pretty much only queries, with no authentication. Eventually, however, using two or three separate libraries for various API actions grew tiresome, and thus, Butt was born!

Basic feature overview

Pretty much every API action in core MediaWiki is possible through a helper instance method. However, for things that are not supported, there is the post method, which submits a POST request (which works fine for things that require a GET request in the API), that takes a hash parameter to pass to the API. Through this helper method, any API can be accessed!

Limitations

There is currently no extension support. Some APIs are also not supported because the majority of the testing occurs on Gamepedia, which often uses software that is not always up to date.

Installation

RubyGems

$ gem install mediawiki-butt

Bundler

Add this line to application's Gemfile:

gem('mediawiki-butt')

And then execute:

$ bundle

Documentation

Documentation can be found here.

Quick start

To get the text of the main page:

require 'mediawiki/butt'
wiki = MediaWiki::Butt.new('https://en.wikipedia.org/w/api.php')
wiki.login(username, password)
main_page_text = wiki.get_text('Main Page')