mediawiki-butt 0.8.2 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mediawiki/query/lists.rb +30 -3
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 213456f1170993110a675e00652fb5a4319797dd
4
- data.tar.gz: f43f85a958898445e7690dadeb99b5d30cfd56df
3
+ metadata.gz: a7fcf2ef47e61692db61d985c91b7cd22bcc1051
4
+ data.tar.gz: d806db7d3a63c4654322b30cae4ae98ce68e2eb9
5
5
  SHA512:
6
- metadata.gz: 7911cdaa9abcd01d41f048e2b422e1cf55d1302e768286ffeb891b90e699774f8a94dd90e646fd216b7bcde61ddaa51c0e52d1bea02240eed01f8c0a98eb9a04
7
- data.tar.gz: 4f740f7718b7de3934c8374463d37f1d2ebd1c21d969bcb0f321736093e7168c5f3bbf10b8ec93643a34bf340d544a3dd9811330274159942cc1050f6762321b
6
+ metadata.gz: 31c4e56c5104e4758fbe710bdec577feb3c16a2f9c620a9ccd45fbd8b47afa10e19027b114c2c06c9a6363822b1de964e0d7e7c84640ec33ef85414250964a9d
7
+ data.tar.gz: 915a073ac9f0d9654e46f4976b352c2318a56c939be7e1282bd8099c67f2a2c054af735d28342ee601f1aab27d76537897b52c57e42f15c26c187aa15692789a
@@ -28,23 +28,30 @@ module MediaWiki
28
28
  ret
29
29
  end
30
30
 
31
- # Returns an array of all page titles that belong to a given category.
31
+ # Returns an array of all page titles that belong to a given category. By
32
+ # default, it will only get the pages. Files and subcategories can be
33
+ # gotten through {#get_subcategories} and {#get_files_in_category} or
34
+ # setting the type parameter.
32
35
  # @param category [String] The category title. It can include "Category:",
33
36
  # or not, it doesn't really matter because we will add it if it is
34
37
  # missing.
35
38
  # @param limit [Int] The maximum number of members to get. Defaults to
36
39
  # 500, and cannot be greater than that unless the user is a bot.
37
40
  # If the user is a bot, the limit cannot be greater than 5000.
41
+ # @param type [String] The type of stuff to get. There are 3 valid values:
42
+ # page, file, and subcat. Separate these with a pipe character, e.g.,
43
+ # 'page|file|subcat'.
38
44
  # @see https://www.mediawiki.org/wiki/API:Categorymembers MediaWiki
39
45
  # Category Members API Docs
40
46
  # @since 0.1.0
41
47
  # @return [Array] All category members until the limit
42
- def get_category_members(category, limit = 500)
48
+ def get_category_members(category, limit = 500, type = 'page')
43
49
  params = {
44
50
  action: 'query',
45
51
  list: 'categorymembers',
46
52
  cmprop: 'title',
47
- cmlimit: get_limited(limit)
53
+ cmlimit: get_limited(limit),
54
+ cmtype: type
48
55
  }
49
56
 
50
57
  if category =~ /[Cc]ategory\:/
@@ -59,6 +66,26 @@ module MediaWiki
59
66
  ret
60
67
  end
61
68
 
69
+ # Gets the subcategories of a given category.
70
+ # @param category [String] See {#get_category_members}
71
+ # @param limit [Int] See {#get_category_members}
72
+ # @see {#get_category_members}
73
+ # @since 0.9.0
74
+ # @return [Array<String>] All subcategories.
75
+ def get_subcategories(category, limit = 500)
76
+ get_category_members(category, limit, 'subcat')
77
+ end
78
+
79
+ # Gets all of the files in a given category.
80
+ # @param category [String] See {#get_category_members}
81
+ # @param limit [Int] See {#get_category_members}
82
+ # @see {#get_category_members}
83
+ # @since 0.9.0
84
+ # @return [Array<String>] All files in the category.
85
+ def get_files_in_category(category, limit = 500)
86
+ get_category_members(category, limit, 'file')
87
+ end
88
+
62
89
  # Returns an array of random pages titles.
63
90
  # @param number_of_pages [Int] The number of articles to get.
64
91
  # Defaults to 1. Cannot be greater than 10 for normal users,
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: 0.8.2
4
+ version: 0.9.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: 2015-12-12 00:00:00.000000000 Z
12
+ date: 2015-12-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httpclient