Module: MediaWiki::Purge
- Included in:
- Butt
- Defined in:
- lib/mediawiki/purge.rb
Instance Method Summary collapse
-
#purge(*titles) ⇒ Hash<String, Boolean>
Purges the provided pages, without updating link tables.
-
#purge_link_update(*titles) ⇒ Hash<String, Boolean>
Purges the provided pages and updates their link tables.
-
#purge_recursive_link_update(*titles) ⇒ Hash<String, Boolean>
Purges the provided pages and recursively updates the link tables.
-
#purge_request(params, *titles) ⇒ Hash<String, Boolean>
private
Sends a purge API request, and handles the return value and warnings.
Instance Method Details
#purge(*titles) ⇒ Hash<String, Boolean>
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.
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.
10 11 12 |
# File 'lib/mediawiki/purge.rb', line 10 def purge(*titles) purge_request({}, titles) end |
#purge_link_update(*titles) ⇒ Hash<String, Boolean>
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.
Purges the provided pages and updates their link tables.
19 20 21 |
# File 'lib/mediawiki/purge.rb', line 19 def purge_link_update(*titles) purge_request({ forcelinkupdate: 1 }, titles) end |
#purge_recursive_link_update(*titles) ⇒ Hash<String, Boolean>
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.
Purges the provided pages and recursively updates the link tables.
28 29 30 |
# File 'lib/mediawiki/purge.rb', line 28 def purge_recursive_link_update(*titles) purge_request({ forcerecursivelinkupdate: 1 }, titles) end |
#purge_request(params, *titles) ⇒ Hash<String, Boolean> (private)
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.
Sends a purge API request, and handles the return value and warnings.
40 41 42 43 44 45 46 47 48 49 50 |
# 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 |