Top Level Namespace
Defined Under Namespace
Modules: WorldDB Classes: CodeReader, 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
-
#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
#title_esc_regex(title_unescaped) ⇒ Object
fix/todo: share helper for all text readers/parsers- where to put it?
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 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 |
# File 'lib/worlddb/utils.rb', line 34 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' |