Module: MediaWiki::Query::Meta::FileRepoInfo

Included in:
Butt, MediaWiki::Query::Meta
Defined in:
lib/mediawiki/query/meta/filerepoinfo.rb

Overview

Instance Method Summary collapse

Instance Method Details

#get_filerepo_faviconsHash<String, String>

Gets the repository names and their according favicon URLs.

Returns:

  • (Hash<String, String>)

    Names as the keys, with their favicons as the values.

Since:

  • 0.7.0



77
78
79
80
81
82
# File 'lib/mediawiki/query/meta/filerepoinfo.rb', line 77

def get_filerepo_favicons
  response = get_filerepoinfo('name|favicon')
  ret = {}
  response['query']['repos'].each { |h| ret[h['name']] = h['favicon'] }
  ret
end

#get_filerepo_namesHash<String, String>

Returns an array of all the wiki’s file repository names.

Returns:

  • (Hash<String, String>)

    All wiki’s file repository names. Keys are names, values are display names.

Since:

  • 0.1.0



23
24
25
26
27
28
# File 'lib/mediawiki/query/meta/filerepoinfo.rb', line 23

def get_filerepo_names
  response = get_filerepoinfo('name|displayname')
  ret = {}
  response['query']['repos'].each { |h| ret[h['name']] = h['displayname'] }
  ret
end

#get_filerepo_rooturlsHash<String, String>

Gets the root URLs for the file repositories.

Returns:

  • (Hash<String, String>)

    A hash containing keys of the names, and values of the root URLs.

Since:

  • 0.7.0



33
34
35
36
37
38
# File 'lib/mediawiki/query/meta/filerepoinfo.rb', line 33

def get_filerepo_rooturls
  response = get_filerepoinfo('name|rootUrl')
  ret = {}
  response['query']['repos'].each { |h| ret[h['name']] = h['rootUrl'] }
  ret
end

#get_filerepo_thumburlsHash<String, String>

Gets the repository names and their accoring thumbnail URLs.

Returns:

  • (Hash<String, String>)

    Names as the keys, with their URLs as the values.

Since:

  • 0.7.0



67
68
69
70
71
72
# File 'lib/mediawiki/query/meta/filerepoinfo.rb', line 67

def get_filerepo_thumburls
  response = get_filerepoinfo('name|thumbUrl')
  ret = {}
  response['query']['repos'].each { |h| ret[h['name']] = h['thumbUrl'] }
  ret
end

#get_filerepo_urlsHash<String, String>

Gets the repository names and their according URLs.

Returns:

  • (Hash<String, String>)

    Names as the keys, with their URLs as the values.

Since:

  • 0.7.0



57
58
59
60
61
62
# File 'lib/mediawiki/query/meta/filerepoinfo.rb', line 57

def get_filerepo_urls
  response = get_filerepoinfo('name|url')
  ret = {}
  response['query']['repos'].each { |h| ret[h['name']] = h['url'] }
  ret
end

#get_filerepoinfo(prop) ⇒ Hash

Gets FileRepoInfo for the property.

Parameters:

  • prop (String)

    The friprop to get.

Returns:

  • (Hash)

    The full parsed response.

Since:

  • 0.7.0



10
11
12
13
14
15
16
17
18
# File 'lib/mediawiki/query/meta/filerepoinfo.rb', line 10

def get_filerepoinfo(prop)
  params = {
    action: 'query',
    meta: 'filerepoinfo',
    friprop: prop
  }

  post(params)
end

#get_local_filereposArray<String>

Gets an array containing all local repositories.

Returns:

  • (Array<String>)

    All repository names that are marked as local.

Since:

  • 0.7.0



43
44
45
# File 'lib/mediawiki/query/meta/filerepoinfo.rb', line 43

def get_local_filerepos
  get_filerepoinfo('name|local')['query']['repos'].select { |h| h.key?('local') }.collect { |h| h['name'] }
end

#get_nonlocal_filereposArray<String>

Gets an array containing all repositories that aren’t local.

Returns:

  • (Array<String>)

    All repositories that are not marked as local.

Since:

  • 0.7.0



50
51
52
# File 'lib/mediawiki/query/meta/filerepoinfo.rb', line 50

def get_nonlocal_filerepos
  get_filerepoinfo('name|local')['query']['repos'].reject { |h| h.key?('local') }.collect { |h| h['name'] }
end