Module: Infoboxer
- Extended by:
- Infoboxer
- Included in:
- Infoboxer
- Defined in:
- lib/infoboxer.rb,
lib/infoboxer/tree.rb,
lib/infoboxer/parser.rb,
lib/infoboxer/version.rb,
lib/infoboxer/tree/ref.rb,
lib/infoboxer/templates.rb,
lib/infoboxer/tree/html.rb,
lib/infoboxer/tree/list.rb,
lib/infoboxer/tree/math.rb,
lib/infoboxer/tree/node.rb,
lib/infoboxer/tree/text.rb,
lib/infoboxer/wiki_path.rb,
lib/infoboxer/media_wiki.rb,
lib/infoboxer/navigation.rb,
lib/infoboxer/tree/image.rb,
lib/infoboxer/tree/nodes.rb,
lib/infoboxer/tree/table.rb,
lib/infoboxer/parser/html.rb,
lib/infoboxer/parser/util.rb,
lib/infoboxer/tree/inline.rb,
lib/infoboxer/parser/image.rb,
lib/infoboxer/parser/table.rb,
lib/infoboxer/tree/gallery.rb,
lib/infoboxer/parser/inline.rb,
lib/infoboxer/templates/set.rb,
lib/infoboxer/tree/compound.rb,
lib/infoboxer/tree/document.rb,
lib/infoboxer/tree/linkable.rb,
lib/infoboxer/tree/template.rb,
lib/infoboxer/tree/wikilink.rb,
lib/infoboxer/parser/context.rb,
lib/infoboxer/templates/base.rb,
lib/infoboxer/media_wiki/page.rb,
lib/infoboxer/parser/template.rb,
lib/infoboxer/tree/paragraphs.rb,
lib/infoboxer/media_wiki/traits.rb,
lib/infoboxer/navigation/lookup.rb,
lib/infoboxer/parser/paragraphs.rb,
lib/infoboxer/navigation/sections.rb,
lib/infoboxer/navigation/selector.rb,
lib/infoboxer/navigation/wikipath.rb,
lib/infoboxer/navigation/shortcuts.rb,
lib/infoboxer/definitions/en.wikipedia.org.rb
Overview
rubocop:disable Layout/EmptyLinesAroundArguments
Defined Under Namespace
Modules: Navigation, Templates, Tree Classes: MediaWiki, Parser
Constant Summary collapse
- WIKIMEDIA_PROJECTS =
{ wikipedia: 'wikipedia.org', wikivoyage: 'wikivoyage.org', wikiquote: 'wikiquote.org', wiktionary: 'wiktionary.org', wikibooks: 'wikibooks.org', wikinews: 'wikinews.org', wikiversity: 'wikiversity.org', wikisource: 'wikisource.org' }.freeze
- WIKIMEDIA_COMMONS =
{ commons: 'commons.wikimedia.org', species: 'species.wikimedia.org', }.freeze
- MAJOR =
0
- MINOR =
4
- PATCH =
0
- PRE =
nil
- VERSION =
[MAJOR, MINOR, PATCH, PRE].compact.join('.')
Class Method Summary collapse
-
.user_agent=(ua) ⇒ Object
Sets user agent string globally.
Instance Method Summary collapse
-
#commons(options = {}) ⇒ Object
Includeable version of #commons.
-
#species(options = {}) ⇒ Object
Includeable version of #species.
-
#url_for(symbol, lang = 'en') ⇒ String
Returns URL of API entry-point for a well-known Wiki-project (wikipedia, wikivoyage etc.) by project’s name.
-
#wiki(api_url, options = {}) ⇒ MediaWiki
Default method for creating MediaWiki API client.
-
#wikia(*domains) ⇒ Object
Includeable version of #wikia.
-
#wikibooks(lang = 'en', options = {}) ⇒ Object
Includeable version of #wikibooks.
-
#wikinews(lang = 'en', options = {}) ⇒ Object
Includeable version of #wikinews.
-
#wikipedia(lang = 'en', options = {}) ⇒ Object
(also: #wp)
Includeable version of #wikipedia.
-
#wikiquote(lang = 'en', options = {}) ⇒ Object
Includeable version of #wikiquote.
- #wikis ⇒ Object
-
#wikisource(lang = 'en', options = {}) ⇒ Object
Includeable version of #wikisource.
-
#wikiversity(lang = 'en', options = {}) ⇒ Object
Includeable version of #wikiversity.
-
#wikivoyage(lang = 'en', options = {}) ⇒ Object
Includeable version of #wikivoyage.
-
#wiktionary(lang = 'en', options = {}) ⇒ Object
Includeable version of #wiktionary.
Class Method Details
.user_agent=(ua) ⇒ Object
Sets user agent string globally. Default user agent is Infoboxer::MediaWiki::UA.
User agent can also be rewriten as an option to #wiki method (and its shortcuts like #wikipedia), or by using Infoboxer::MediaWiki#initialize explicitly.
241 242 243 |
# File 'lib/infoboxer.rb', line 241 def self.user_agent=(ua) MediaWiki.user_agent = ua end |
Instance Method Details
#url_for(symbol, lang = 'en') ⇒ String
Returns URL of API entry-point for a well-known Wiki-project (wikipedia, wikivoyage etc.) by project’s name.
190 191 192 193 194 195 196 |
# File 'lib/infoboxer.rb', line 190 def url_for(symbol, lang = 'en') if (domain = WIKIMEDIA_PROJECTS[symbol]) "https://#{lang}.#{domain}/w/api.php" elsif (domain = WIKIMEDIA_COMMONS[symbol]) "https://#{domain}/w/api.php" end end |
#wiki(api_url, options = {}) ⇒ MediaWiki
Default method for creating MediaWiki API client.
73 74 75 |
# File 'lib/infoboxer.rb', line 73 def wiki(api_url, **) wikis[api_url] ||= MediaWiki.new(api_url, **) end |
#wikibooks(lang = 'en', options = {}) ⇒ Object
Includeable version of #wikibooks
|
# File 'lib/infoboxer.rb', line 105
|
#wikinews(lang = 'en', options = {}) ⇒ Object
Includeable version of #wikinews
|
# File 'lib/infoboxer.rb', line 130
|
#wikipedia(lang = 'en', options = {}) ⇒ Object Also known as: wp
Includeable version of #wikipedia
|
# File 'lib/infoboxer.rb', line 92
|
#wikiquote(lang = 'en', options = {}) ⇒ Object
Includeable version of #wikiquote
|
# File 'lib/infoboxer.rb', line 110
|
#wikis ⇒ Object
68 69 70 |
# File 'lib/infoboxer.rb', line 68 def wikis @wikis ||= {} end |
#wikisource(lang = 'en', options = {}) ⇒ Object
Includeable version of #wikisource
|
# File 'lib/infoboxer.rb', line 120
|
#wikiversity(lang = 'en', options = {}) ⇒ Object
Includeable version of #wikiversity
|
# File 'lib/infoboxer.rb', line 115
|
#wikivoyage(lang = 'en', options = {}) ⇒ Object
Includeable version of #wikivoyage
|
# File 'lib/infoboxer.rb', line 125
|
#wiktionary(lang = 'en', options = {}) ⇒ Object
Includeable version of #wiktionary
|
# File 'lib/infoboxer.rb', line 141
|