sportdb-models 1.14.0 → 1.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2cebb6c98e88a5cbb12889d6a90b4a890d09ac21
4
- data.tar.gz: 7d9017176287c6f00a2a209fa6a9e1877fabf286
3
+ metadata.gz: cf909494cd7fbd51b980c7e109ad3d61bee25c8f
4
+ data.tar.gz: a8b43bdc6c24e06f632af294f2878a164373003d
5
5
  SHA512:
6
- metadata.gz: 42901342ef3482dfc37ad8abb60b0870c91c718922c85493129249e7ab4ca55bb95aa8fcba3e3f9a04f57b513705003eefddfd55828301e44186e432bc682c53
7
- data.tar.gz: d514e02328829f767cac4bf4b75499ba9e9acf4358498e8a77bd8043869120720b9e138b38ed0eeed02bcb1f4d64d77fa3d25588b7e8883f642d8c58c2fc36f0
6
+ metadata.gz: 91f1926c5fc03895d000801f5481845f5cf8bd96fdd08b310aa13ce1427f9c1dbab514227f3d82f9bbc38dbd4d246445a6405c0027175b4b93c6c435d6d66fea
7
+ data.tar.gz: 8a710213ac56aca68ef77450d44073adca016feed8f448c08105b317f8d9006852956449fa2c9aa7afeeb92c37f44097f38484c0acee3f534f6b34da785e688b
data/Manifest.txt CHANGED
@@ -1,148 +1,153 @@
1
- HISTORY.md
2
- Manifest.txt
3
- README.md
4
- Rakefile
5
- config/fixtures/de.yml
6
- config/fixtures/en.yml
7
- config/fixtures/es.yml
8
- config/fixtures/fr.yml
9
- config/fixtures/it.yml
10
- config/fixtures/pt.yml
11
- config/fixtures/ro.yml
12
- data/seasons.txt
13
- data/setups/all.txt
14
- lib/sportdb/calc.rb
15
- lib/sportdb/deleter.rb
16
- lib/sportdb/finders/date.rb
17
- lib/sportdb/finders/goals.rb
18
- lib/sportdb/finders/scores.rb
19
- lib/sportdb/lang.rb
20
- lib/sportdb/matcher.rb
21
- lib/sportdb/models.rb
22
- lib/sportdb/models/assoc.rb
23
- lib/sportdb/models/assoc_assoc.rb
24
- lib/sportdb/models/badge.rb
25
- lib/sportdb/models/event.rb
26
- lib/sportdb/models/event_ground.rb
27
- lib/sportdb/models/event_team.rb
28
- lib/sportdb/models/forward.rb
29
- lib/sportdb/models/game.rb
30
- lib/sportdb/models/goal.rb
31
- lib/sportdb/models/ground.rb
32
- lib/sportdb/models/group.rb
33
- lib/sportdb/models/group_team.rb
34
- lib/sportdb/models/league.rb
35
- lib/sportdb/models/person.rb
36
- lib/sportdb/models/roster.rb
37
- lib/sportdb/models/round.rb
38
- lib/sportdb/models/season.rb
39
- lib/sportdb/models/stats/alltime_standing.rb
40
- lib/sportdb/models/stats/alltime_standing_entry.rb
41
- lib/sportdb/models/stats/event_standing.rb
42
- lib/sportdb/models/stats/event_standing_entry.rb
43
- lib/sportdb/models/stats/group_standing.rb
44
- lib/sportdb/models/stats/group_standing_entry.rb
45
- lib/sportdb/models/team.rb
46
- lib/sportdb/models/team_compat.rb
47
- lib/sportdb/models/utils.rb
48
- lib/sportdb/models/world/city.rb
49
- lib/sportdb/models/world/continent.rb
50
- lib/sportdb/models/world/country.rb
51
- lib/sportdb/models/world/state.rb
52
- lib/sportdb/patterns.rb
53
- lib/sportdb/pretty_printer.rb
54
- lib/sportdb/reader.rb
55
- lib/sportdb/reader_file.rb
56
- lib/sportdb/reader_zip.rb
57
- lib/sportdb/readers/assoc.rb
58
- lib/sportdb/readers/event.rb
59
- lib/sportdb/readers/game.rb
60
- lib/sportdb/readers/ground.rb
61
- lib/sportdb/readers/league.rb
62
- lib/sportdb/readers/season.rb
63
- lib/sportdb/readers/squad_club.rb
64
- lib/sportdb/readers/squad_national_team.rb
65
- lib/sportdb/readers/team.rb
66
- lib/sportdb/schema.rb
67
- lib/sportdb/standings.rb
68
- lib/sportdb/stats.rb
69
- lib/sportdb/utils.rb
70
- lib/sportdb/utils_date.rb
71
- lib/sportdb/utils_goals.rb
72
- lib/sportdb/utils_group.rb
73
- lib/sportdb/utils_map.rb
74
- lib/sportdb/utils_round.rb
75
- lib/sportdb/utils_scores.rb
76
- lib/sportdb/utils_teams.rb
77
- lib/sportdb/version.rb
78
- test/data/at-austria/2013_14/bl.txt
79
- test/data/at-austria/2013_14/bl.yml
80
- test/data/at-austria/2013_14/bl_ii.txt
81
- test/data/at-austria/2013_14/el.txt
82
- test/data/at-austria/2013_14/el.yml
83
- test/data/at-austria/2013_14/squads/austria.txt
84
- test/data/at-austria/2013_14/squads/salzburg.txt
85
- test/data/at-austria/2014_15/1-bundesliga-ii.txt
86
- test/data/at-austria/2015_16/1-bundesliga.yml
87
- test/data/at-austria/2015_16/cup.yml
88
- test/data/at-austria/leagues.txt
89
- test/data/at-austria/teams.txt
90
- test/data/at-austria/teams_2.txt
91
- test/data/national-teams/assocs.txt
92
- test/data/national-teams/europe/assocs.txt
93
- test/data/national-teams/europe/teams.txt
94
- test/data/national-teams/north-america/assocs.txt
95
- test/data/national-teams/north-america/teams.txt
96
- test/data/national-teams/teams.txt
97
- test/data/players/europe/at-austria/players.txt
98
- test/data/players/europe/de-deutschland/players.txt
99
- test/data/players/south-america/br-brazil/players.txt
100
- test/data/world-cup/1930/cup.txt
101
- test/data/world-cup/1930/cup.yml
102
- test/data/world-cup/1930/cup_goals.txt
103
- test/data/world-cup/1930/cup_goals.yml
104
- test/data/world-cup/1954/cup.txt
105
- test/data/world-cup/1954/cup.yml
106
- test/data/world-cup/1962/cup.txt
107
- test/data/world-cup/1962/cup.yml
108
- test/data/world-cup/1974/cup.yml
109
- test/data/world-cup/1974/cup_finals.txt
110
- test/data/world-cup/1974/cup_i.txt
111
- test/data/world-cup/1974/cup_ii.txt
112
- test/data/world-cup/2014/cup.txt
113
- test/data/world-cup/2014/cup.yml
114
- test/data/world-cup/2014/squads/br-brazil.txt
115
- test/data/world-cup/2014/squads/de-deutschland.txt
116
- test/data/world-cup/2014/squads/jp-japan.txt
117
- test/data/world-cup/2014/squads/uy-uruguay.txt
118
- test/data/world-cup/leagues.txt
119
- test/data/world-cup/seasons_1930.txt
120
- test/data/world-cup/seasons_1954.txt
121
- test/data/world-cup/seasons_1962.txt
122
- test/data/world-cup/seasons_1974.txt
123
- test/data/world-cup/teams_1930.txt
124
- test/data/world-cup/teams_1954.txt
125
- test/data/world-cup/teams_1962.txt
126
- test/data/world-cup/teams_1974.txt
127
- test/helper.rb
128
- test/test_assoc_reader.rb
129
- test/test_changes.rb
130
- test/test_cursor.rb
131
- test/test_date.rb
132
- test/test_event_reader.rb
133
- test/test_goals.rb
134
- test/test_lang.rb
135
- test/test_load.rb
136
- test/test_pp.rb
137
- test/test_reader.rb
138
- test/test_reader_from_string.rb
139
- test/test_round_auto.rb
140
- test/test_round_def.rb
141
- test/test_round_header.rb
142
- test/test_scores.rb
143
- test/test_squad_club_reader.rb
144
- test/test_squad_national_team_reader.rb
145
- test/test_standings.rb
146
- test/test_standings_ii.rb
147
- test/test_utils.rb
148
- test/test_winner.rb
1
+ HISTORY.md
2
+ Manifest.txt
3
+ README.md
4
+ Rakefile
5
+ config/fixtures/de.yml
6
+ config/fixtures/en.yml
7
+ config/fixtures/es.yml
8
+ config/fixtures/fr.yml
9
+ config/fixtures/it.yml
10
+ config/fixtures/pt.yml
11
+ config/fixtures/ro.yml
12
+ data/seasons.txt
13
+ data/setups/all.txt
14
+ lib/sportdb/calc.rb
15
+ lib/sportdb/deleter.rb
16
+ lib/sportdb/finders/date.rb
17
+ lib/sportdb/finders/goals.rb
18
+ lib/sportdb/finders/scores.rb
19
+ lib/sportdb/lang.rb
20
+ lib/sportdb/matcher.rb
21
+ lib/sportdb/models.rb
22
+ lib/sportdb/models/assoc.rb
23
+ lib/sportdb/models/assoc_assoc.rb
24
+ lib/sportdb/models/badge.rb
25
+ lib/sportdb/models/event.rb
26
+ lib/sportdb/models/event_ground.rb
27
+ lib/sportdb/models/event_team.rb
28
+ lib/sportdb/models/forward.rb
29
+ lib/sportdb/models/game.rb
30
+ lib/sportdb/models/goal.rb
31
+ lib/sportdb/models/ground.rb
32
+ lib/sportdb/models/group.rb
33
+ lib/sportdb/models/group_team.rb
34
+ lib/sportdb/models/league.rb
35
+ lib/sportdb/models/person.rb
36
+ lib/sportdb/models/roster.rb
37
+ lib/sportdb/models/round.rb
38
+ lib/sportdb/models/season.rb
39
+ lib/sportdb/models/stats/alltime_standing.rb
40
+ lib/sportdb/models/stats/alltime_standing_entry.rb
41
+ lib/sportdb/models/stats/event_standing.rb
42
+ lib/sportdb/models/stats/event_standing_entry.rb
43
+ lib/sportdb/models/stats/group_standing.rb
44
+ lib/sportdb/models/stats/group_standing_entry.rb
45
+ lib/sportdb/models/team.rb
46
+ lib/sportdb/models/team_compat.rb
47
+ lib/sportdb/models/utils.rb
48
+ lib/sportdb/models/world/city.rb
49
+ lib/sportdb/models/world/continent.rb
50
+ lib/sportdb/models/world/country.rb
51
+ lib/sportdb/models/world/state.rb
52
+ lib/sportdb/patterns.rb
53
+ lib/sportdb/pretty_printer.rb
54
+ lib/sportdb/reader.rb
55
+ lib/sportdb/reader_file.rb
56
+ lib/sportdb/reader_zip.rb
57
+ lib/sportdb/readers/assoc.rb
58
+ lib/sportdb/readers/event.rb
59
+ lib/sportdb/readers/game.rb
60
+ lib/sportdb/readers/ground.rb
61
+ lib/sportdb/readers/league.rb
62
+ lib/sportdb/readers/season.rb
63
+ lib/sportdb/readers/squad_club.rb
64
+ lib/sportdb/readers/squad_national_team.rb
65
+ lib/sportdb/readers/team.rb
66
+ lib/sportdb/rsssf_reader.rb
67
+ lib/sportdb/schema.rb
68
+ lib/sportdb/standings.rb
69
+ lib/sportdb/stats.rb
70
+ lib/sportdb/utils.rb
71
+ lib/sportdb/utils_date.rb
72
+ lib/sportdb/utils_goals.rb
73
+ lib/sportdb/utils_group.rb
74
+ lib/sportdb/utils_map.rb
75
+ lib/sportdb/utils_round.rb
76
+ lib/sportdb/utils_scores.rb
77
+ lib/sportdb/utils_teams.rb
78
+ lib/sportdb/version.rb
79
+ test/data/at-austria/2013_14/bl.txt
80
+ test/data/at-austria/2013_14/bl.yml
81
+ test/data/at-austria/2013_14/bl_ii.txt
82
+ test/data/at-austria/2013_14/el.txt
83
+ test/data/at-austria/2013_14/el.yml
84
+ test/data/at-austria/2013_14/squads/austria.txt
85
+ test/data/at-austria/2013_14/squads/salzburg.txt
86
+ test/data/at-austria/2014_15/1-bundesliga-ii.txt
87
+ test/data/at-austria/2014_15/1-bundesliga.yml
88
+ test/data/at-austria/2015_16/1-bundesliga.yml
89
+ test/data/at-austria/2015_16/cup.yml
90
+ test/data/at-austria/leagues.txt
91
+ test/data/at-austria/teams.txt
92
+ test/data/at-austria/teams_2.txt
93
+ test/data/national-teams/assocs.txt
94
+ test/data/national-teams/europe/assocs.txt
95
+ test/data/national-teams/europe/teams.txt
96
+ test/data/national-teams/north-america/assocs.txt
97
+ test/data/national-teams/north-america/teams.txt
98
+ test/data/national-teams/teams.txt
99
+ test/data/players/europe/at-austria/players.txt
100
+ test/data/players/europe/de-deutschland/players.txt
101
+ test/data/players/south-america/br-brazil/players.txt
102
+ test/data/rsssf/at-2014-15--1-bundesliga.txt
103
+ test/data/rsssf/at-2015-16--1-bundesliga.txt
104
+ test/data/world-cup/1930/cup.txt
105
+ test/data/world-cup/1930/cup.yml
106
+ test/data/world-cup/1930/cup_goals.txt
107
+ test/data/world-cup/1930/cup_goals.yml
108
+ test/data/world-cup/1954/cup.txt
109
+ test/data/world-cup/1954/cup.yml
110
+ test/data/world-cup/1962/cup.txt
111
+ test/data/world-cup/1962/cup.yml
112
+ test/data/world-cup/1974/cup.yml
113
+ test/data/world-cup/1974/cup_finals.txt
114
+ test/data/world-cup/1974/cup_i.txt
115
+ test/data/world-cup/1974/cup_ii.txt
116
+ test/data/world-cup/2014/cup.txt
117
+ test/data/world-cup/2014/cup.yml
118
+ test/data/world-cup/2014/squads/br-brazil.txt
119
+ test/data/world-cup/2014/squads/de-deutschland.txt
120
+ test/data/world-cup/2014/squads/jp-japan.txt
121
+ test/data/world-cup/2014/squads/uy-uruguay.txt
122
+ test/data/world-cup/leagues.txt
123
+ test/data/world-cup/seasons_1930.txt
124
+ test/data/world-cup/seasons_1954.txt
125
+ test/data/world-cup/seasons_1962.txt
126
+ test/data/world-cup/seasons_1974.txt
127
+ test/data/world-cup/teams_1930.txt
128
+ test/data/world-cup/teams_1954.txt
129
+ test/data/world-cup/teams_1962.txt
130
+ test/data/world-cup/teams_1974.txt
131
+ test/helper.rb
132
+ test/test_assoc_reader.rb
133
+ test/test_changes.rb
134
+ test/test_cursor.rb
135
+ test/test_date.rb
136
+ test/test_event_reader.rb
137
+ test/test_goals.rb
138
+ test/test_lang.rb
139
+ test/test_load.rb
140
+ test/test_pp.rb
141
+ test/test_reader.rb
142
+ test/test_reader_from_string.rb
143
+ test/test_round_auto.rb
144
+ test/test_round_def.rb
145
+ test/test_round_header.rb
146
+ test/test_rsssf_reader.rb
147
+ test/test_scores.rb
148
+ test/test_squad_club_reader.rb
149
+ test/test_squad_national_team_reader.rb
150
+ test/test_standings.rb
151
+ test/test_standings_ii.rb
152
+ test/test_utils.rb
153
+ test/test_winner.rb
@@ -1,11 +1,103 @@
1
1
  # encoding: utf-8
2
2
 
3
- #### fix: move to textutils for reuse !!!!!
3
+ #### fix: move to textutils for reuse !!!!!!!!!! - why?? why not ??
4
4
 
5
5
 
6
6
  module SportDb
7
7
 
8
- class DateFinder
8
+
9
+ class DateFinderBase
10
+
11
+ MONTH_EN_TO_MM = {
12
+ 'Jan' => '1', 'January' => '1',
13
+ 'Feb' => '2', 'February' => '2',
14
+ 'Mar' => '3', 'March' => '3',
15
+ 'Apr' => '4', 'April' => '4',
16
+ 'May' => '5',
17
+ 'Jun' => '6', 'June' => '6',
18
+ 'Jul' => '7', 'July' => '7',
19
+ 'Aug' => '8', 'August' => '8',
20
+ 'Sep' => '9', 'Sept' => '9', 'September' => '9',
21
+ 'Oct' => '10', 'October' => '10',
22
+ 'Nov' => '11', 'November' => '11',
23
+ 'Dec' => '12', 'December' =>'12' }
24
+
25
+ MONTH_FR_TO_MM = {
26
+ 'Janvier' => '1', 'Janv' => '1', 'Jan' => '1', ## check janv in use??
27
+ 'Février' => '2', 'Févr' => '2', 'Fév' => '2', ## check fevr in use???
28
+ 'Mars' => '3', 'Mar' => '3',
29
+ 'Avril' => '4', 'Avri' => '4', 'Avr' => '4', ## check avri in use??? if not remove
30
+ 'Mai' => '5',
31
+ 'Juin' => '6',
32
+ 'Juillet' => '7', 'Juil' => '7',
33
+ 'Août' => '8',
34
+ 'Septembre' => '9', 'Sept' => '9',
35
+ 'Octobre' => '10', 'Octo' => '10', 'Oct' => '10', ### check octo in use??
36
+ 'Novembre' => '11', 'Nove' => '11', 'Nov' => '11', ## check nove in use??
37
+ 'Décembre' => '12', 'Déce' => '12', 'Déc' => '12' } ## check dece in use??
38
+
39
+ MONTH_ES_TO_MM = {
40
+ 'Ene' => '1', 'Enero' => '1',
41
+ 'Feb' => '2',
42
+ 'Mar' => '3', 'Marzo' => '3',
43
+ 'Abr' => '4', 'Abril' => '4',
44
+ 'May' => '5', 'Mayo' => '5',
45
+ 'Jun' => '6', 'Junio' => '6',
46
+ 'Jul' => '7', 'Julio' => '7',
47
+ 'Ago' => '8', 'Agosto' => '8',
48
+ 'Sep' => '9', 'Set' => '9', 'Sept' => '9',
49
+ 'Oct' => '10',
50
+ 'Nov' => '11',
51
+ 'Dic' => '12' }
52
+
53
+ private
54
+ def calc_year( month, day, opts )
55
+ start_at = opts[:start_at]
56
+
57
+ logger.debug " [calc_year] ????-#{month}-#{day} -- start_at: #{start_at}"
58
+
59
+ if month >= start_at.month
60
+ # assume same year as start_at event (e.g. 2013 for 2013/14 season)
61
+ start_at.year
62
+ else
63
+ # assume year+1 as start_at event (e.g. 2014 for 2013/14 season)
64
+ start_at.year+1
65
+ end
66
+ end
67
+
68
+ def parse_date_time( match_data, opts={} )
69
+
70
+ # convert regex match_data captures to hash
71
+ # - note: cannont use match_data like a hash (e.g. raises exception if key/name not present/found)
72
+ h = {}
73
+ # - note: do NOT forget to turn name into symbol for lookup in new hash (name.to_sym)
74
+ match_data.names.each { |name| h[name.to_sym] = match_data[name] } # or use match_data.names.zip( match_data.captures ) - more cryptic but "elegant"??
75
+
76
+ ## puts "[parse_date_time] match_data:"
77
+ ## pp h
78
+ logger.debug " [parse_date_time] hash: >#{h.inspect}<"
79
+
80
+ h[ :month ] = MONTH_EN_TO_MM[ h[:month_en] ] if h[:month_en]
81
+ h[ :month ] = MONTH_ES_TO_MM[ h[:month_es] ] if h[:month_es]
82
+ h[ :month ] = MONTH_FR_TO_MM[ h[:month_fr] ] if h[:month_fr]
83
+
84
+ month = h[:month]
85
+ day = h[:day]
86
+ year = h[:year] || calc_year( month.to_i, day.to_i, opts ).to_s
87
+
88
+ hours = h[:hours] || '12' # default to 12:00 for HH:MM (hours:minutes)
89
+ minutes = h[:minutes] || '00'
90
+
91
+ value = '%d-%02d-%02d %02d:%02d' % [year.to_i, month.to_i, day.to_i, hours.to_i, minutes.to_i]
92
+ logger.debug " date: >#{value}<"
93
+
94
+ DateTime.strptime( value, '%Y-%m-%d %H:%M' )
95
+ end
96
+
97
+ end # class DateFinderBase
98
+
99
+
100
+ class DateFinder < DateFinderBase
9
101
 
10
102
  include LogUtils::Logging
11
103
 
@@ -27,19 +119,7 @@ class DateFinder
27
119
  'Octobre|Octo|Oct|' +
28
120
  'Novembre|Nove|Nov|' +
29
121
  'Décembre|Déce|Déc'
30
- MONTH_FR_TO_MM = {
31
- 'Janvier' => '1', 'Janv' => '1', 'Jan' => '1', ## check janv in use??
32
- 'Février' => '2', 'Févr' => '2', 'Fév' => '2', ## check fevr in use???
33
- 'Mars' => '3', 'Mar' => '3',
34
- 'Avril' => '4', 'Avri' => '4', 'Avr' => '4', ## check avri in use??? if not remove
35
- 'Mai' => '5',
36
- 'Juin' => '6',
37
- 'Juillet' => '7', 'Juil' => '7',
38
- 'Août' => '8',
39
- 'Septembre' => '9', 'Sept' => '9',
40
- 'Octobre' => '10', 'Octo' => '10', 'Oct' => '10', ### check octo in use??
41
- 'Novembre' => '11', 'Nove' => '11', 'Nov' => '11', ## check nove in use??
42
- 'Décembre' => '12', 'Déce' => '12', 'Déc' => '12' } ## check dece in use??
122
+
43
123
  WEEKDAY_FR = 'Lundi|Lun|L|' +
44
124
  'Mardi|Mar|Ma|' +
45
125
  'Mercredi|Mer|Me|' +
@@ -61,19 +141,6 @@ class DateFinder
61
141
  'October|Oct|'+
62
142
  'November|Nov|'+
63
143
  'December|Dec'
64
- MONTH_EN_TO_MM = {
65
- 'Jan' => '1', 'January' => '1',
66
- 'Feb' => '2', 'February' => '2',
67
- 'Mar' => '3', 'March' => '3',
68
- 'Apr' => '4', 'April' => '4',
69
- 'May' => '5',
70
- 'Jun' => '6', 'June' => '6',
71
- 'Jul' => '7', 'July' => '7',
72
- 'Aug' => '8', 'August' => '8',
73
- 'Sep' => '9', 'Sept' => '9', 'September' => '9',
74
- 'Oct' => '10', 'October' => '10',
75
- 'Nov' => '11', 'November' => '11',
76
- 'Dec' => '12', 'December' =>'12' }
77
144
 
78
145
  ###
79
146
  ## todo: add days
@@ -83,20 +150,18 @@ class DateFinder
83
150
  ## 7. Saturday - Sat.
84
151
 
85
152
 
86
- MONTH_ES = 'Enero|Ene|Feb|Marzo|Mar|Abril|Abr|Mayo|May|Junio|Jun|Julio|Jul|Agosto|Ago|Sept|Set|Sep|Oct|Nov|Dic'
87
- MONTH_ES_TO_MM = {
88
- 'Ene' => '1', 'Enero' => '1',
89
- 'Feb' => '2',
90
- 'Mar' => '3', 'Marzo' => '3',
91
- 'Abr' => '4', 'Abril' => '4',
92
- 'May' => '5', 'Mayo' => '5',
93
- 'Jun' => '6', 'Junio' => '6',
94
- 'Jul' => '7', 'Julio' => '7',
95
- 'Ago' => '8', 'Agosto' => '8',
96
- 'Sep' => '9', 'Set' => '9', 'Sept' => '9',
97
- 'Oct' => '10',
98
- 'Nov' => '11',
99
- 'Dic' => '12' }
153
+ MONTH_ES = 'Enero|Ene|'+
154
+ 'Feb|'+
155
+ 'Marzo|Mar|'+
156
+ 'Abril|Abr|'+
157
+ 'Mayo|May|'+
158
+ 'Junio|Jun|'+
159
+ 'Julio|Jul|'+
160
+ 'Agosto|Ago|'+
161
+ 'Sept|Set|Sep|'+
162
+ 'Oct|'+
163
+ 'Nov|'+
164
+ 'Dic'
100
165
 
101
166
  # todo/fix - add de and es too!!
102
167
  # note: in Austria - Jänner - in Deutschland Januar allow both ??
@@ -242,6 +307,10 @@ class DateFinder
242
307
  \b/x
243
308
 
244
309
  # e.g. Jun/12 w/ implied year and implied hours (set to 12:00)
310
+ # note: allow space too e.g Jun 12 -- check if conflicts w/ other formats??? (added for rsssf reader)
311
+ # -- fix: might eat french weekday mar 12 is mardi (mar) !!! see FR__ pattern
312
+ # fix: remove space again for now - and use simple en date reader or something!!!
313
+ ## was [\/ ] changed back to \/
245
314
  EN__MONTH_DD__DATE_REGEX = /\b
246
315
  (?<month_en>#{MONTH_EN})
247
316
  \/
@@ -323,52 +392,55 @@ class DateFinder
323
392
  return nil # no match found
324
393
  end
325
394
 
326
- private
327
- def calc_year( month, day, opts )
328
- start_at = opts[:start_at]
329
-
330
- logger.debug " [calc_year] ????-#{month}-#{day} -- start_at: #{start_at}"
331
-
332
- if month >= start_at.month
333
- # assume same year as start_at event (e.g. 2013 for 2013/14 season)
334
- start_at.year
335
- else
336
- # assume year+1 as start_at event (e.g. 2014 for 2013/14 season)
337
- start_at.year+1
338
- end
339
- end
340
-
341
- def parse_date_time( match_data, opts={} )
342
-
343
- # convert regex match_data captures to hash
344
- # - note: cannont use match_data like a hash (e.g. raises exception if key/name not present/found)
345
- h = {}
346
- # - note: do NOT forget to turn name into symbol for lookup in new hash (name.to_sym)
347
- match_data.names.each { |name| h[name.to_sym] = match_data[name] } # or use match_data.names.zip( match_data.captures ) - more cryptic but "elegant"??
348
-
349
- ## puts "[parse_date_time] match_data:"
350
- ## pp h
351
- logger.debug " [parse_date_time] hash: >#{h.inspect}<"
395
+ end # class DateFinder
352
396
 
353
- h[ :month ] = MONTH_EN_TO_MM[ h[:month_en] ] if h[:month_en]
354
- h[ :month ] = MONTH_ES_TO_MM[ h[:month_es] ] if h[:month_es]
355
- h[ :month ] = MONTH_FR_TO_MM[ h[:month_fr] ] if h[:month_fr]
356
397
 
357
- month = h[:month]
358
- day = h[:day]
359
- year = h[:year] || calc_year( month.to_i, day.to_i, opts ).to_s
398
+ class RsssfDateFinder < DateFinderBase
360
399
 
361
- hours = h[:hours] || '12' # default to 12:00 for HH:MM (hours:minutes)
362
- minutes = h[:minutes] || '00'
400
+ include LogUtils::Logging
363
401
 
364
- value = '%d-%02d-%02d %02d:%02d' % [year.to_i, month.to_i, day.to_i, hours.to_i, minutes.to_i]
365
- logger.debug " date: >#{value}<"
402
+ MONTH_EN = 'Jan|'+
403
+ 'Feb|'+
404
+ 'March|Mar|'+
405
+ 'April|Apr|'+
406
+ 'May|'+
407
+ 'June|Jun|'+
408
+ 'July|Jul|'+
409
+ 'Aug|'+
410
+ 'Sept|Sep|'+
411
+ 'Oct|'+
412
+ 'Nov|'+
413
+ 'Dec'
414
+
415
+ ## e.g.
416
+ ## [Jun 7] or [Aug 12] etc. - not MUST include brackets e.g. []
417
+ ##
418
+ ## check add \b at the beginning and end - why?? why not?? working??
419
+ EN__MONTH_DD__DATE_REGEX = /\[
420
+ (?<month_en>#{MONTH_EN})
421
+ \s
422
+ (?<day>\d{1,2})
423
+ \]/x
366
424
 
367
- DateTime.strptime( value, '%Y-%m-%d %H:%M' )
425
+ def find!( line, opts={} )
426
+ # fix: use more lookahead for all required trailing spaces!!!!!
427
+ # fix: use <name capturing group> for month,day,year etc.!!!
428
+
429
+ tag = '[EN_MONTH_DD]'
430
+ pattern = EN__MONTH_DD__DATE_REGEX
431
+ md = pattern.match( line )
432
+ if md
433
+ date = parse_date_time( md, opts )
434
+ ## fix: use md[0] e.g. match for sub! instead of using regex again - why? why not???
435
+ ## fix: use md.begin(0), md.end(0)
436
+ line.sub!( md[0], tag )
437
+ ## todo/fix: make sure match data will not get changed (e.g. using sub! before parse_date_time)
438
+ return date
439
+ end
440
+ return nil # no match found
368
441
  end
369
442
 
370
443
 
371
- end # class DateFinder
372
-
444
+ end ## class RsssfDateFinder
373
445
 
374
446
  end # module SportDb
@@ -90,6 +90,9 @@ require 'sportdb/stats'
90
90
 
91
91
  require 'sportdb/pretty_printer'
92
92
 
93
+ ## "simplified" match reader for rsssf-formated/style leagues
94
+ require 'sportdb/rsssf_reader'
95
+
93
96
 
94
97
  module SportDb
95
98