mediawiki-butt 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d607878d899519bb2780c1e1b22e704d42e84ee0
4
- data.tar.gz: c9e1672f535750b5c9cee2f1922f8c9fadf6a912
3
+ metadata.gz: 6ac2473bbed75da107401d8c5dceeca3e2ed6b3c
4
+ data.tar.gz: 36463ff0c4f70d87ce6d6f62994d7ff03cf4b47a
5
5
  SHA512:
6
- metadata.gz: 5aff5ca892a0cad1a9db8a532d90117dbb7183487a0c1f326a223c295900147eae00d3f1f173d3157faed57054de8a67e4a1622fcbfa3f185c8b0806e97d5dd8
7
- data.tar.gz: a1cc08cc6e86caeda0cf63b7f7179e224511ad5012b972bb4cf3b7b217974678081b1a5b1018fd664a2270718081512eb55b061dac579359b461735a0ee7ef41
6
+ metadata.gz: 208c930ffa7dc8913b4c2b51bc6a82a46f1f55319d2ba92bf33eb139579dfbb8dff5b17327636df5235e651f63381ae4c808f84263868ca931a0cf1c9232035e
7
+ data.tar.gz: ef133085ca55bd92f603d43430c4c100d17011c0d64427950463c4e18856da642c2f2270df33e722c1efda9b971484d5a6e416767ed2b487e719ee444001acfc
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
  ## Version 1
3
+ ### Version 1.2.0
4
+ * Add support for the Purge API (#48)
5
+
3
6
  ### Version 1.1.1
4
7
  * Fix query methods throwing NoMethodErrors.
5
8
 
@@ -4,6 +4,7 @@ require_relative 'constants'
4
4
  require_relative 'edit'
5
5
  require_relative 'administration'
6
6
  require_relative 'watch'
7
+ require_relative 'purge'
7
8
  require 'httpclient'
8
9
  require 'json'
9
10
 
@@ -20,6 +21,7 @@ module MediaWiki
20
21
  include MediaWiki::Edit
21
22
  include MediaWiki::Administration
22
23
  include MediaWiki::Watch
24
+ include MediaWiki::Purge
23
25
 
24
26
  attr_accessor :query_limit_default
25
27
  attr_accessor :use_continuation
@@ -0,0 +1,57 @@
1
+ module MediaWiki
2
+ module Purge
3
+ # Purges the provided pages, without updating link tables. This will warn for every invalid purge with the reason
4
+ # it is invalid, as provided by the MediaWiki API.
5
+ # @param *titles [Array<String>] A list of the pages to purge.
6
+ # @return [Hash<String, Boolean>] The key is the page title, and the value is whether it was a successful purge.
7
+ # @see https://www.mediawiki.org/wiki/API:Purge MediaWiki API Docs
8
+ # @note This creates a warning for every invalid purge with the reason it is invalid, as provided by the MediaWiki
9
+ # API, as well as the title of the invalid page.
10
+ def purge(*titles)
11
+ purge_request({}, titles)
12
+ end
13
+
14
+ # Purges the provided pages and updates their link tables.
15
+ # @param (see #purge)
16
+ # @return (see #purge)
17
+ # @see (see #purge)
18
+ # @note (see #purge)
19
+ def purge_link_update(*titles)
20
+ purge_request({ forcelinkupdate: 1 }, titles)
21
+ end
22
+
23
+ # Purges the provided pages and recursively updates the link tables.
24
+ # @param (see #purge)
25
+ # @return (see #purge)
26
+ # @see (see #purge)
27
+ # @note (see #purge)
28
+ def purge_recursive_link_update(*titles)
29
+ purge_request({ forcerecursivelinkupdate: 1 }, titles)
30
+ end
31
+
32
+ private
33
+
34
+ # Sends a purge API request, and handles the return value and warnings.
35
+ # @param params [Hash<Object, Object>] The parameter hash to begin with. Cannot include the titles or action keys.
36
+ # @param (see #purge)
37
+ # @return (see #purge)
38
+ # @see (see #purge)
39
+ # @note (see #purge)
40
+ def purge_request(params, *titles)
41
+ params[:action] = 'purge'
42
+ params[:titles] = titles.join('|')
43
+
44
+ response = post(params)
45
+
46
+ ret = {}
47
+
48
+ response['purge'].each do |hash|
49
+ title = hash['title']
50
+ ret[title] = hash.key?('purged') && !hash.key?('missing')
51
+ warn "Invalid purge (#{title}) #{hash['invalidreason']}" if hash.key?('invalid')
52
+ end
53
+
54
+ ret
55
+ end
56
+ end
57
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mediawiki-butt
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eli Foster
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-08-31 00:00:00.000000000 Z
12
+ date: 2016-09-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httpclient
@@ -42,6 +42,7 @@ files:
42
42
  - lib/mediawiki/constants.rb
43
43
  - lib/mediawiki/edit.rb
44
44
  - lib/mediawiki/exceptions.rb
45
+ - lib/mediawiki/purge.rb
45
46
  - lib/mediawiki/query/lists/all.rb
46
47
  - lib/mediawiki/query/lists/backlinks.rb
47
48
  - lib/mediawiki/query/lists/categories.rb