Class: MineShaft::Shaft

Inherits:
Object
  • Object
show all
Defined in:
lib/mine_shaft/shaft.rb

Overview

Provides simple interface for deserializing an id'd HTML table from a specific page of a Redmine project site.

Constant Summary collapse

LOGIN_PAGE_URL =

The relative URL for the login page on a Redmine site

"/login"

Instance Method Summary collapse

Instance Method Details

#grab(table_id, relative_wiki_page_url) ⇒ Object

Public: Logs in and parses the specified page for a

with the specified ID.

table_id - The HTML id of the desired table as a String. relative_wiki_page_url - The relative URL of the page within the Redmine site.

Examples

shaft.grab('names', '/projects/name-parser/Wiki/Name_Data')

Returns an Array of Hash objects. Each Hash element is a key-value mapping of "table header"-"row content". (Note that the the key is a downcased-symbol of the heading value). Raises FailedLogin if the login failed Raises InvalidPage if the login page of the site renders a 404 OR if a table with the supplied ID is not found on the specified page.



42
43
44
45
46
47
# File 'lib/mine_shaft/shaft.rb', line 42

def grab(table_id, relative_wiki_page_url)
  @agent.
  wiki_page = WebPage.new(@agent.get(relative_wiki_page_url))
  requested_table = wiki_page.find_table(table_id)
  requested_table.deserialize
end