Top Level Namespace
Defined Under Namespace
Modules: WorldDB Classes: File, HashReader, LineReader, Time, ValuesReader
Constant Summary collapse
- Tag =
shortcuts for models
WorldDB::Models::Tag
- Tagging =
WorldDB::Models::Tagging
- Country =
WorldDB::Models::Country
- Region =
WorldDB::Models::Region
- City =
WorldDB::Models::City
- Prop =
WorldDB::Models::Prop
- DB_CONFIG =
connect to db
{ adapter: 'sqlite3', database: 'world.db' }
- AT =
local variables (e.g. at) not working; use constants instead (e.g. AT)
Country.find_by_key( 'at' )
- DE =
Country.find_by_key( 'de' )
- EN =
Country.find_by_key( 'en' )
- GB =
Country.find_by_key( 'gb' )
- EU =
Country.find_by_key( 'eu' )
- US =
Country.find_by_key( 'us' )
- CA =
Country.find_by_key( 'ca' )
- MX =
Country.find_by_key( 'mx' )
- NYC =
some cities
City.find_by_key( 'newyork' )
- LON =
City.find_by_key( 'london' )
- VIE =
City.find_by_key( 'wien' )
- EURO =
todo: add some predefined tags (e.g. europe, america, g8, euro, etc.)
Tag.find_by_key( 'euro' )
- EUROPE =
Tag.find_by_key( 'europe' )
- ASIA =
Tag.find_by_key( 'asia' )
- PACIFIC =
Tag.find_by_key( 'pacific' )
Instance Method Summary collapse
-
#fixture_name_to_prop_key(name) ⇒ Object
helper change at/2012_13/bl to at.2012/13.bl or quali_2012_13_europe_c to quali.2012/13.europe.c.
-
#title_esc_regex(title_unescaped) ⇒ Object
fix/todo: share helper for all text readers/parsers- where to put it?.
-
#worlddb ⇒ Object
for use to run with interactive ruby (irb) e.g.
Instance Method Details
#fixture_name_to_prop_key(name) ⇒ Object
helper
change at/2012_13/bl to at.2012/13.bl
or quali_2012_13_europe_c to quali.2012/13.europe.c
38 39 40 41 42 43 |
# File 'lib/worlddb/utils.rb', line 38 def fixture_name_to_prop_key( name ) prop_key = name.gsub( '/', '.' ) prop_key = prop_key.gsub( /(\d{4})_(\d{2})/, '\1/\2' ) # 2012_13 => 2012/13 prop_key = prop_key.gsub( '_', '.' ) prop_key end |
#title_esc_regex(title_unescaped) ⇒ Object
fix/todo: share helper for all text readers/parsers- where to put it?
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/worlddb/utils.rb', line 49 def title_esc_regex( title_unescaped ) ## escape regex special chars e.g. . to \. and ( to \( etc. # e.g. Benfica Lis. # e.g. Club Atlético Colón (Santa Fe) ## NB: cannot use Regexp.escape! will escape space '' to '\ ' ## title = Regexp.escape( title_unescaped ) title = title_unescaped.gsub( '.', '\.' ) title = title.gsub( '(', '\(' ) title = title.gsub( ')', '\)' ) ## match accented char with or without accents ## add (ü|ue) etc. ## also make - optional change to (-| ) e.g. Blau-Weiss == Blau Weiss ## todo: add some more ## see http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references for more ## ## reuse for all readers! alternatives = [ ['-', '(-| )'], ['ß', '(ß|ss)'], ['æ', '(æ|ae)'], ['á', '(á|a)'], ## e.g. Bogotá ['ã', '(ã|a)'], ## e.g São Paulo ['ä', '(ä|ae)'], ## add a ? ['Ö', '(Ö|Oe)'], ## e.g. Österreich ['ö', '(ö|oe)'], ## add o ? ['ó', '(ó|o)'], ## e.g. Colón ['ü', '(ü|ue)'], ## add u ? ['é', '(é|e)'], ## e.g. Vélez ['ê', '(ê|e)'], ## e.g. Grêmio ['ñ', '(ñ|n)'], ## e.g. Porteño ['ú', '(ú|u)'] ## e.g. Fútbol ] alternatives.each do |alt| title = title.gsub( alt[0], alt[1] ) end title end |
#worlddb ⇒ Object
for use to run with interactive ruby (irb)
e.g. irb -r worlddb/console
4 |
# File 'lib/worlddb/console.rb', line 4 require 'worlddb' |