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/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/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/shortcuts.rb,
lib/infoboxer/definitions/en.wikipedia.org.rb

Overview

Main client module for entire infoboxer functionality. If you're lucky, there's no other classes/modules you need to instantiate or call directly. You just do:

Infoboxer.wp.get('List of radio telescopes')
# or 
Infoboxer.wikiquote.get('Vonnegut')

...and have fully navigable Wiki information.

Please read wiki for extensive showcases and usage recommendations.

Here's main components list, which also can serve as a TOC for Infoboxer's functionality (we suggest to read their docs in this order):

  • Tree -- nodes, of which Wikipedia AST is consisting; you'll be interested in basic Tree::Node functionality, as well as node classes list (which is useful for navigation);
  • Navigation -- how to navigate the tree you have, basic way (children, parents, siblings) and hi-level shortcuts way (like all unnumbered list items in second level-3 section);
  • Templates -- the most advanced data extraction from wikipedia definitely needs your undestanding of this (rather complicated) topic.

You also may be interested in (though may be never need to use them directly):

NB Infoboxer module can also be included in other classes, like this:

class MyDataGrabber
  include Infoboxer

  def initialize
    wikipedia.get('Argentina')
  end
end

Defined Under Namespace

Modules: Navigation, Templates, Tree Classes: MediaWiki, Parser

Constant Summary collapse

MAJOR =
0
MINOR =
2
PATCH =
7
VERSION =
[MAJOR, MINOR, PATCH].join('.')

Class Method Summary collapse

Instance Method Summary collapse

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.



233
234
235
# File 'lib/infoboxer.rb', line 233

def Infoboxer.user_agent=(ua)
  MediaWiki.user_agent = ua
end

Instance Method Details

#commons(options = {}) ⇒ Object

Includeable version of #commons



# File 'lib/infoboxer.rb', line 103

#species(options = {}) ⇒ Object

Includeable version of #species



# File 'lib/infoboxer.rb', line 139

#wiki(api_url, options = {}) ⇒ MediaWiki

Default method for creating MediaWiki API client.

Parameters:

  • api_url

    should be URL of api.php for your MediaWiki

  • options (defaults to: {})

    list of options. The only recognized option for now, though, is

    • :user_agent (also aliased as :ua) -- custom User-Agent header.

Returns:

  • (MediaWiki)

    an instance of API client, which you can further use like this:

    Infoboxer.wiki('some_url').get('Some page title')
    


77
78
79
# File 'lib/infoboxer.rb', line 77

def wiki(api_url, options = {})
  WIKIS[api_url] ||= MediaWiki.new(api_url, options || {})
end

#wikia(*domains) ⇒ Object

Includeable version of #wikia



# File 'lib/infoboxer.rb', line 150

#wikibooks(lang = 'en', options = {}) ⇒ Object

Includeable version of #wikibooks



# File 'lib/infoboxer.rb', line 109

#wikinews(lang = 'en', options = {}) ⇒ Object

Includeable version of #wikinews



# File 'lib/infoboxer.rb', line 134

#wikipedia(lang = 'en', options = {}) ⇒ Object Also known as: wp

Includeable version of #wikipedia



# File 'lib/infoboxer.rb', line 96

#wikiquote(lang = 'en', options = {}) ⇒ Object

Includeable version of #wikiquote



# File 'lib/infoboxer.rb', line 114

#wikisource(lang = 'en', options = {}) ⇒ Object

Includeable version of #wikisource



# File 'lib/infoboxer.rb', line 124

#wikiversity(lang = 'en', options = {}) ⇒ Object

Includeable version of #wikiversity



# File 'lib/infoboxer.rb', line 119

#wikivoyage(lang = 'en', options = {}) ⇒ Object

Includeable version of #wikivoyage



# File 'lib/infoboxer.rb', line 129

#wiktionary(lang = 'en', options = {}) ⇒ Object

Includeable version of #wiktionary



# File 'lib/infoboxer.rb', line 145