module MediaWiki::Purge
Public Instance Methods
Purges the provided pages, without updating link tables. This will warn for every invalid purge with the reason it is invalid, as provided by the MediaWiki
API. @param *titles [Array<String>] A list of the pages to purge. @return [Hash<String, Boolean>] The key is the page title, and the value is whether it was a successful purge. @see www.mediawiki.org/wiki/API:Purge MediaWiki
API Docs @note This creates a warning for every invalid purge with the reason it is invalid, as provided by the MediaWiki
API, as well as the title of the invalid page.
# File lib/mediawiki/purge.rb, line 10 def purge(*titles) purge_request({}, titles) end
Private Instance Methods
Sends a purge API request, and handles the return value and warnings. @param params [Hash<Object, Object>] The parameter hash to begin with. Cannot include the titles or action keys. @param (see purge
) @return (see purge
) @see (see purge
) @note (see purge
)
# File lib/mediawiki/purge.rb, line 40 def purge_request(params, *titles) params[:action] = 'purge' params[:titles] = titles.join('|') post(params)['purge'].inject({}) do |result, hash| title = hash['title'] result[title] = hash.key?('purged') && !hash.key?('missing') warn "Invalid purge (#{title}) #{hash['invalidreason']}" if hash.key?('invalid') result end end