sportdb 1.8.2 → 1.8.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,20 +19,23 @@ class Ground < ActiveRecord::Base
19
19
  city_title = ''
20
20
 
21
21
  values.each_with_index do |value, index|
22
- if value =~ /^[12][0-9]{3}$/ ## assume founding year
23
- # skip founding/opening year fow now
24
- logger.info " found year #{value}; skipping for now"
22
+ if value =~ /^(19|20)[0-9]{2}$/ ## assume founding year -- allow 19|20
23
+ logger.info " founding/opening year #{value}"
24
+ new_attributes[ :since ] = value.to_i
25
25
  elsif value =~ /^[1-9][0-9_]+[0-9]$/ # number; assume capacity e.g. 12_541 or similar
26
- # todo/fix: check how to differentiate between founding year and capacity if capcity islike year
26
+ # todo/fix: check how to differentiate between founding year
27
+ # and capacity if capcity islike year
28
+ # need to use _ e.g. 1_999 not 1999 and will get added as capacity !!!
27
29
  # - by position ?? year is first entry, capacity is second ??? -add/fix
28
30
 
29
- # skip capacity
30
- logger.info " found capacity #{value}; skipping for now"
31
+ logger.info " found capacity #{value}"
32
+ new_attributes[ :capacity ] = value.gsub('_', '').to_i
31
33
  elsif value =~ /^[A-Z]{1,3}$/ # assume; state/region code e-g B | TX etc.
32
34
  # skip region/state code
33
35
  logger.info " found region/state code #{value}; skipping for now"
34
36
  elsif value =~ /\/{2}/ # assume it's an address line e.g. xx // xx
35
- logger.info " found address line #{value}; skipping for now"
37
+ logger.info " found address line #{value}"
38
+ new_attributes[ :address ] = value
36
39
  elsif value =~ /^clubs:/ # assume it's clubs line e.g. clubs: Santos
37
40
  logger.info " found clubs line #{value}; skipping for now"
38
41
  elsif value =~ /^(?:[a-z]{2}\.)?wikipedia:/ # assume it's wikipedia e.g. [es.]wikipedia:
@@ -67,6 +70,8 @@ class Ground < ActiveRecord::Base
67
70
  #### try to auto-add city
68
71
 
69
72
  if city_title.present?
73
+
74
+ ### todo/fix: strip city_title subtitles e.g. Hamburg (Hafen) becomes Hamburg etc.
70
75
  city_values = [city_title]
71
76
  city_attributes = {
72
77
  country_id: rec.country_id,
@@ -54,9 +54,20 @@ class Team < ActiveRecord::Base
54
54
  logger.warn "city with key #{value_city_key} missing"
55
55
  ## todo: log errors to db log???
56
56
  end
57
+ elsif value =~ /^(18|19|20)[0-9]{2}$/ ## assume founding year -- allow 18|19|20
58
+ ## logger.info " founding/opening year #{value}"
59
+ new_attributes[ :since ] = value.to_i
60
+ elsif value =~ /\/{2}/ # assume it's an address line e.g. xx // xx
61
+ ## logger.info " found address line #{value}"
62
+ new_attributes[ :address ] = value
63
+ elsif value =~ /^(?:[a-z]{2}\.)?wikipedia:/ # assume it's wikipedia e.g. [es.]wikipedia:
64
+ logger.info " found wikipedia line #{value}; skipping for now"
65
+ elsif value =~ /(^www\.)|(\.com$)/ # FIX: !!!! use a better matcher not just www. and .com
66
+ new_attributes[ :web ] = value
57
67
  elsif value =~ /^[A-Z][A-Z0-9][A-Z0-9_]?$/ ## assume two or three-letter code e.g. FCB, RBS, etc.
58
68
  new_attributes[ :code ] = value
59
69
  elsif value =~ /^[a-z]{2}$/ ## assume two-letter country key e.g. at,de,mx,etc.
70
+ ## fix: allow country letter with three e.g. eng,sco,wal,nir, etc. !!!
60
71
  value_country = Country.find_by_key!( value )
61
72
  new_attributes[ :country_id ] = value_country.id
62
73
  else
@@ -107,9 +107,10 @@ class Reader
107
107
  load_leagues( name, club: true, country_id: country.id )
108
108
  end
109
109
  elsif name =~ /(?:^|\/)leagues/ # NB: ^leagues or also possible world!/leagues - NB: make sure goes after leagues_for_country!!
110
- if name =~ /-cup!?\// # NB: -cup/ or -cup!/
110
+ if name =~ /-cup!?\// || # NB: -cup/ or -cup!/
111
+ name =~ /copa-america!?\// # NB: copa-america/ or copa-america!/
111
112
  # e.g. national team tournaments/leagues (e.g. world-cup/ or euro-cup/)
112
- load_leagues( name )
113
+ load_leagues( name, club: false )
113
114
  else
114
115
  # e.g. leagues_club
115
116
  load_leagues( name, club: true )
@@ -121,10 +122,11 @@ class Reader
121
122
  load_teams( name, club: true, country_id: country.id )
122
123
  end
123
124
  elsif name =~ /(?:^|\/)teams/
124
- if name =~ /-cup!?\// # NB: -cup/ or -cup!/
125
+ if name =~ /-cup!?\// || # NB: -cup/ or -cup!/
126
+ name =~ /copa-america!?\// # NB: copa-america/ or copa-america!/
125
127
  # assume national teams
126
128
  # e.g. world-cup/teams amercia-cup/teams_northern
127
- load_teams( name, national: true )
129
+ load_teams( name, club: false )
128
130
  else
129
131
  # club teams (many countries)
130
132
  # e.g. club/europe/teams
@@ -15,6 +15,10 @@ create_table :teams do |t|
15
15
  t.references :city # NB: city is optional (should be required for clubs e.g. non-national teams)
16
16
  t.boolean :club, null: false, default: false # is it a club (not a national team)?
17
17
 
18
+ t.integer :since # founding year
19
+ t.string :address
20
+ t.string :web
21
+
18
22
  ### fix: remove and add virtual attribute in model instead
19
23
  t.boolean :national, null: false, default: false # is it a national selection team (not a club)?
20
24
  t.timestamps
@@ -31,6 +35,11 @@ create_table :grounds do |t|
31
35
  t.references :country, null: false
32
36
  t.references :city # todo: make city required ???
33
37
 
38
+ t.integer :since # founding year
39
+ t.integer :capacity # attentence capacity e.g. 10_000 or 50_000 etc.
40
+ t.string :address
41
+
42
+
34
43
  ### fix/todo: add since/founded/opened/build attrib eg. 2011 or 1987
35
44
  ## - add capacity e.g. 40_000
36
45
  ## fix: add address !!!! etc
@@ -1,6 +1,6 @@
1
1
 
2
2
  module SportDb
3
- VERSION = '1.8.2'
3
+ VERSION = '1.8.3'
4
4
  end
5
5
 
6
6
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.2
4
+ version: 1.8.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-12 00:00:00.000000000 Z
12
+ date: 2014-02-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: worlddb
16
- requirement: &5976588 !ruby/object:Gem::Requirement
16
+ requirement: &18821544 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.7'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *5976588
24
+ version_requirements: *18821544
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: fetcher
27
- requirement: &5974812 !ruby/object:Gem::Requirement
27
+ requirement: &18819840 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0.3'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *5974812
35
+ version_requirements: *18819840
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: gli
38
- requirement: &5973264 !ruby/object:Gem::Requirement
38
+ requirement: &18818232 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.5.6
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *5973264
46
+ version_requirements: *18818232
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rdoc
49
- requirement: &5987700 !ruby/object:Gem::Requirement
49
+ requirement: &18832080 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '4.0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *5987700
57
+ version_requirements: *18832080
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: hoe
60
- requirement: &5981688 !ruby/object:Gem::Requirement
60
+ requirement: &18826716 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,7 +65,7 @@ dependencies:
65
65
  version: '3.7'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *5981688
68
+ version_requirements: *18826716
69
69
  description: sportdb - sport.db command line tool
70
70
  email: opensport@googlegroups.com
71
71
  executables: