lib/sportdb/utils.rb in sportdb-1.1.0 vs lib/sportdb/utils.rb in sportdb-1.2.0

- old
+ new

@@ -17,18 +17,18 @@ def is_knockout_round?( line ) ## todo: check for adding ignore case for regex (e.g. 1st leg/1st Leg) if line =~ SportDB.lang.regex_leg1 - puts " two leg knockout; skip knockout flag on first leg" + logger.debug " two leg knockout; skip knockout flag on first leg" false elsif line =~ SportDB.lang.regex_knockout_round - puts " setting knockout flag to true" + logger.debug " setting knockout flag to true" true elsif line =~ /K\.O\.|Knockout/ ## NB: add two language independent markers, that is, K.O. and Knockout - puts " setting knockout flag to true (lang independent marker)" + logger.debug " setting knockout flag to true (lang independent marker)" true else false end end @@ -59,12 +59,12 @@ else match[1].to_i end title = match[0] - puts " title: >#{title}<" - puts " pos: >#{pos}<" + logger.debug " title: >#{title}<" + logger.debug " pos: >#{pos}<" line.sub!( regex, '[GROUP|TITLE+POS]' ) return [title,pos] end @@ -79,11 +79,11 @@ # extract optional round pos from line # e.g. (1) - must start line regex = /^[ \t]*\((\d{1,3})\)[ \t]+/ if line =~ regex - puts " pos: >#{$1}<" + logger.debug " pos: >#{$1}<" line.sub!( regex, '[ROUND|POS] ' ) ## NB: add back trailing space that got swallowed w/ regex -> [ \t]+ return $1.to_i end @@ -108,11 +108,11 @@ regex = /\b(\d+)\b/ if line =~ regex value = $1.to_i - puts " pos: >#{value}<" + logger.debug " pos: >#{value}<" line.sub!( regex, '[ROUND|POS]' ) return value else @@ -137,38 +137,38 @@ # e.g. 14.09.2012 20:30 => DD.MM.YYYY HH:MM regex_de2 = /\b(\d{2})\.(\d{2})\.(\d{4})\s+(\d{2}):(\d{2})\b/ if line =~ regex_db value = "#{$1}-#{$2}-#{$3} #{$4}:#{$5}" - puts " date: >#{value}<" + logger.debug " date: >#{value}<" ## todo: lets you configure year ## and time zone (e.g. cet, eet, utc, etc.) line.sub!( regex_db, '[DATE.DB]' ) return DateTime.strptime( value, '%Y-%m-%d %H:%M' ) elsif line =~ regex_db2 value = "#{$1}-#{$2}-#{$3} 12:00" - puts " date: >#{value}<" + logger.debug " date: >#{value}<" line.sub!( regex_db2, '[DATE.DB2]' ) return DateTime.strptime( value, '%Y-%m-%d %H:%M' ) elsif line =~ regex_de2 value = "#{$3}-#{$2}-#{$1} #{$4}:#{$5}" - puts " date: >#{value}<" + logger.debug " date: >#{value}<" ## todo: lets you configure year ## and time zone (e.g. cet, eet, utc, etc.) line.sub!( regex_de2, '[DATE.DE2]' ) return DateTime.strptime( value, '%Y-%m-%d %H:%M' ) elsif line =~ regex_de value = "2012-#{$2}-#{$1} #{$3}:#{$4}" - puts " date: >#{value}<" + logger.debug " date: >#{value}<" ## todo: lets you configure year ## and time zone (e.g. cet, eet, utc, etc.) line.sub!( regex_de, '[DATE.DE]' ) @@ -186,11 +186,11 @@ # NB: side effect - removes pos from line string # e.g. (1) - must start line regex = /^[ \t]*\((\d{1,3})\)[ \t]+/ if line =~ regex - puts " pos: >#{$1}<" + logger.debug " pos: >#{$1}<" line.sub!( regex, '[POS] ' ) return $1.to_i else return nil @@ -220,27 +220,27 @@ regex_p = /\b(\d)[:\-](\d)[ \t]?[iI][eE]\b/ scores = [] if line =~ regex - puts " score: >#{$1}-#{$2}<" + logger.debug " score: >#{$1}-#{$2}<" line.sub!( regex, '[SCORE]' ) scores << $1.to_i scores << $2.to_i if line =~ regex_ot - puts " score.ot: >#{$1}-#{$2}<" + logger.debug " score.ot: >#{$1}-#{$2}<" line.sub!( regex_ot, '[SCORE.OT]' ) scores << $1.to_i scores << $2.to_i if line =~ regex_p - puts " score.p: >#{$1}-#{$2}<" + logger.debug " score.p: >#{$1}-#{$2}<" line.sub!( regex_p, '[SCORE.P]' ) scores << $1.to_i scores << $2.to_i @@ -254,11 +254,11 @@ def find_team_worker!( line, index ) regex = /@@oo([^@]+?)oo@@/ # e.g. everything in @@ .... @@ (use non-greedy +? plus all chars but not @, that is [^@]) if line =~ regex value = "#{$1}" - puts " team#{index}: >#{value}<" + logger.debug " team#{index}: >#{value}<" line.sub!( regex, "[TEAM#{index}]" ) return $1 else @@ -295,11 +295,11 @@ ## (thus add it, allows match for Benfica Lis. for example - note . at the end) ## check add $ e.g. (\b| |\t|$) does this work? - check w/ Benfica Lis.$ regex = /\b#{value}(\b| |\t|$)/ # wrap with world boundry (e.g. match only whole words e.g. not wac in wacker) if line =~ regex - puts " match for team >#{key}< >#{value}<" + logger.debug " match for team >#{key}< >#{value}<" # make sure @@oo{key}oo@@ doesn't match itself with other key e.g. wacker, wac, etc. line.sub!( regex, "@@oo#{key}oo@@ " ) # NB: add one space char at end return true # break out after first match (do NOT continue) end end @@ -315,6 +315,5 @@ end # each known_teams end # method translate_teams! end # module SportDB::FixtureHelpers -