Project

kekka

0.0
No commit activity in last 3 years
No release in over 3 years
Kekka is a parser of the XML format XRR (XML Regatta Reporting: http://www.sailing.org/xml .) It accepts XML on this format and sorts it in boat, event and result hashes.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.1
~> 1.8
~> 3.12
~> 2.11

Runtime

>= 1.5
 Project Readme

kekka

Kekka is a thin ruby library on top of the XML format ISAF XRR (XML Regatta Reporting). In its first version it takes care of parsing the XML and putting data in convenient hashes - it also manages the relations between different data sets. In future versions exports will be supported also.

Usage

To get hold of it:

require 'kekka'

To create a kekka:

kekka = Kekka.parse open('/path/to/xrr')

The argument to parse can be exactly the same as what nokogiris parse method accepts. A kekka is actually a Hash so it is possible to use all Hash methods on it and its parts. The resulting Hash is structured exactly as the XML. On the first level there are persons, boats, teams and events. Symbols are used to get collectionesque subparts. For example - to get to boats:

kekka[:boats]

Elements that got an id are put in a Hash with ids as keys. So to get to the boat with id '9':

kekka[:boats]['9']

Attributes are downcased (by nokogiri) and used as keys in the Hash for its instance. To get the sail number for a boat:

kekka[:boats]['9']['sailnumber']

Events have a deeper structure inside. To get to races for the event with id '9':

kekka[:events]['9'][:races]

To get the race status for the race with id '32':

kekka[:events]['9'][:races]['32']['racestatus']

It is starting to get deep now and it is probably wise to split such a thing into parts.

event = kekka[:events]['9']
race = event[:races]['32']
race['racestatus']

The event also have divisions that contains both race results and series results (the latter being the sum of race results for a team). Results does not have ids so they are represented with an array. You would probably want to get all results for a race in a division and could then do seomthing like:

event = kekka[:events]['9']
division = event[:divisions]['4711']
division[:raceresults].select { |one_result| one_result['raceid'] == '32' }

Doing things like this easier may be added in future versions.

Manipulation

  • Kekka adds the field 'boatclass' to the boat based on the division that the boat raced in.
  • Kekka adds the field 'boatid' to race reult hashes. It finds it via 'teamid'.
  • Kekka adds the field 'scoretype' to division hashes with a default value of 'points'.

Copyright

Copyright (c) 2012 Fredrik Rubensson. See LICENSE.txt for further details.