sportdb-sync 1.1.2 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: cdadfa4b00e61764c6b7b1f62ffb983f89c4a1ff
4
- data.tar.gz: 3721087e4b6ff6bf0e604a00cce8658df1cb05bb
2
+ SHA256:
3
+ metadata.gz: b73ed85dddf1c7c27f9b7e4d5bbcc6989d9e032c44f5458053da0d4adbdafe5a
4
+ data.tar.gz: ca78db4bdc48da80911d8b33c06e8e87a708d19f8dc02856c2a7d6683b8fb719
5
5
  SHA512:
6
- metadata.gz: 18c37a874743c779fabc931f8e09c14a30e3e13609242a82cc0d2d5f14319092d103f470a8541eabfef95b0f83c0c98849b54d652fc3f9ff5615299be8e7bc17
7
- data.tar.gz: 2dd81facb4bbcd8a36c09d66d894288660724f058121799f5a6c29a64ece00c115eb6c257ef3075b2b8231a01e8e5a70afc6c4cb7f793e61752113acbf577344
6
+ metadata.gz: 4162570a44409f4b020196a1050ffb5bd78bbf509db6475c73e55bd419a54c8e5ca3996477ca93595ac0822ace0cf82e6ef9d9d99683a5f1bdbb8aef363877f6
7
+ data.tar.gz: 0ddacac8500613b4649a27aeb7a77e502cc1e31858f3c6fa4e66dc5d175aca78a3d6f9bdd4cff1a9ee04dc00f72a0286cf9722481d9a85356b433387824585f1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,5 @@
1
+ ### 1.2.0
2
+
1
3
  ### 0.0.1 / 2019-11-04
2
4
 
3
5
  * Everything is new. First release.
data/Manifest.txt CHANGED
@@ -10,7 +10,3 @@ lib/sportdb/sync/league.rb
10
10
  lib/sportdb/sync/season.rb
11
11
  lib/sportdb/sync/sync.rb
12
12
  lib/sportdb/sync/version.rb
13
- test/helper.rb
14
- test/test_country.rb
15
- test/test_league.rb
16
- test/test_misc.rb
data/README.md CHANGED
@@ -5,7 +5,6 @@
5
5
  * bugs :: [github.com/sportdb/sport.db/issues](https://github.com/sportdb/sport.db/issues)
6
6
  * gem :: [rubygems.org/gems/sportdb-sync](https://rubygems.org/gems/sportdb-sync)
7
7
  * rdoc :: [rubydoc.info/gems/sportdb-sync](http://rubydoc.info/gems/sportdb-sync)
8
- * forum :: [opensport](http://groups.google.com/group/opensport)
9
8
 
10
9
 
11
10
 
@@ -21,8 +20,10 @@ The `sportdb-sync` scripts are dedicated to the public domain.
21
20
  Use it as you please with no restrictions whatsoever.
22
21
 
23
22
 
23
+
24
+
24
25
  ## Questions? Comments?
25
26
 
26
- Send them along to the
27
- [Open Sports & Friends Forum/Mailing List](http://groups.google.com/group/opensport).
28
- Thanks!
27
+ Yes, you can. More than welcome.
28
+ See [Help & Support »](https://github.com/openfootball/help)
29
+
data/Rakefile CHANGED
@@ -11,7 +11,7 @@ Hoe.spec 'sportdb-sync' do
11
11
  self.urls = { home: 'https://github.com/sportdb/sport.db' }
12
12
 
13
13
  self.author = 'Gerald Bauer'
14
- self.email = 'opensport@googlegroups.com'
14
+ self.email = 'gerald.bauer@gmail.com'
15
15
 
16
16
  # switch extension to .markdown for gihub formatting
17
17
  self.readme_file = 'README.md'
@@ -20,8 +20,8 @@ Hoe.spec 'sportdb-sync' do
20
20
  self.licenses = ['Public Domain']
21
21
 
22
22
  self.extra_deps = [
23
- ['sportdb-catalogs', '>= 1.0.0'],
24
- ['sportdb-models', '>= 2.0.2'],
23
+ ['sportdb-catalogs', '>= 1.2.0'],
24
+ ['sportdb-models', '>= 2.1.0'],
25
25
  ]
26
26
 
27
27
  self.spec_extras = {
@@ -9,7 +9,7 @@ module SportDb
9
9
 
10
10
  def self.country( q )
11
11
  ## note: use built-in countries for mapping country keys/codes
12
- country = Import.catalog.countries.find( q )
12
+ country = Import.world.countries.find( q )
13
13
  if country
14
14
  ## todo/check: keep key mapping warning - useful? why? why not?
15
15
  if country.key != q.to_s
@@ -24,6 +24,9 @@ module SportDb
24
24
 
25
25
  ########################
26
26
  # searchers
27
+ #
28
+ # - fix!!!! - remove searchers - why? why not?
29
+ # check if used anywhere ????
27
30
 
28
31
  def self.search!( q )
29
32
  country = country( q )
@@ -2,7 +2,7 @@ module SportDb
2
2
  module Sync
3
3
  class Season
4
4
  def self.season( q ) ## helper for season key (rename to norm_key ???)
5
- Import::Season.new( q )
5
+ ::Season.parse( q )
6
6
  end
7
7
 
8
8
 
@@ -192,7 +192,12 @@ module SportDb
192
192
  end
193
193
 
194
194
  ### todo/check: what happens if there's more than one match? exception raised??
195
- rec = if round_rec
195
+ rec = if ['N. N.'].include?( team1_name ) && ## some special cases - always assume new record for now (to avoid ambigious update conflict)
196
+ ['N. N.'].include?( team2_name )
197
+ ## always assume new record for now
198
+ ## check for date or such - why? why not?
199
+ nil
200
+ elsif round_rec
196
201
  ## add match status too? allows [abandoned] and [replay] in same round
197
202
  find_attributes = { round_id: round_rec.id,
198
203
  team1_id: team1_rec.id,
@@ -217,7 +222,9 @@ module SportDb
217
222
  team1_id: team1_rec.id,
218
223
  team2_id: team2_rec.id,
219
224
  pos: max_pos,
220
- date: match.date.to_date, ## todo/fix: split and add date & time!!!!
225
+ # date: match.date.to_date, ## todo/fix: split and add date & time!!!!
226
+ date: match.date, # assume iso format as string e.g. 2021-07-10 !!!
227
+ time: match.time, # assume iso format as string e.g. 21:00 !!!
221
228
  score1: match.score1,
222
229
  score2: match.score2,
223
230
  score1i: match.score1i,
@@ -233,6 +240,34 @@ module SportDb
233
240
  attribs[ :stage_id ] = stage_rec.id if stage_rec
234
241
 
235
242
  rec = Model::Match.create!( attribs )
243
+
244
+
245
+ #############################################
246
+ ### try to update goals
247
+ #### quick & dirty v0 - redo !!!!
248
+ goals = match.goals
249
+ if goals && goals.size > 0
250
+ goals.each do |goal|
251
+ person_rec = Model::Person.find_by(
252
+ name: goal.name )
253
+ if person_rec.nil?
254
+ person_rec = Model::Person.create!(
255
+ key: goal.name.downcase.gsub( /[^a-z]/, '' ),
256
+ name: goal.name
257
+ )
258
+ end
259
+ Model::Goal.create!(
260
+ match_id: rec.id,
261
+ person_id: person_rec.id,
262
+ team_id: goal.team == 1 ? rec.team1.id
263
+ : rec.team2.id,
264
+ minute: goal.minute,
265
+ offset: goal.offset,
266
+ penalty: goal.penalty,
267
+ owngoal: goal.owngoal,
268
+ )
269
+ end
270
+ end
236
271
  else
237
272
  # update - todo
238
273
  puts "!! ERROR - match updates not yet supported (only inserts); sorry"
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
 
3
2
 
4
3
  module SportDb
@@ -6,8 +5,8 @@ module Module
6
5
  module Sync
7
6
 
8
7
  MAJOR = 1 ## todo: namespace inside version or something - why? why not??
9
- MINOR = 1
10
- PATCH = 2
8
+ MINOR = 2
9
+ PATCH = 0
11
10
  VERSION = [MAJOR,MINOR,PATCH].join('.')
12
11
 
13
12
  def self.version
@@ -15,7 +14,7 @@ module Sync
15
14
  end
16
15
 
17
16
  def self.banner
18
- "sportdb-sync/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
17
+ "sportdb-sync/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}] in (#{root})"
19
18
  end
20
19
 
21
20
  def self.root
data/lib/sportdb/sync.rb CHANGED
@@ -1,5 +1,3 @@
1
- # encoding: utf-8
2
-
3
1
  require 'sportdb/catalogs'
4
2
  require 'sportdb/models' ## add sql database support
5
3
 
@@ -7,13 +5,13 @@ require 'sportdb/models' ## add sql database support
7
5
 
8
6
  ###
9
7
  # our own code
10
- require 'sportdb/sync/version' # let version always go first
11
- require 'sportdb/sync/country'
12
- require 'sportdb/sync/league'
13
- require 'sportdb/sync/season'
14
- require 'sportdb/sync/event'
15
- require 'sportdb/sync/club'
16
- require 'sportdb/sync/sync'
8
+ require_relative 'sync/version' # let version always go first
9
+ require_relative 'sync/country'
10
+ require_relative 'sync/league'
11
+ require_relative 'sync/season'
12
+ require_relative 'sync/event'
13
+ require_relative 'sync/club'
14
+ require_relative 'sync/sync'
17
15
 
18
16
 
19
17
  puts SportDb::Module::Sync.banner # say hello
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportdb-sync
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-09-15 00:00:00.000000000 Z
11
+ date: 2024-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sportdb-catalogs
@@ -16,59 +16,65 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.0
19
+ version: 1.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.0
26
+ version: 1.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sportdb-models
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 2.0.2
33
+ version: 2.1.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 2.0.2
40
+ version: 2.1.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rdoc
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: '4.0'
48
+ - - "<"
49
+ - !ruby/object:Gem::Version
50
+ version: '7'
48
51
  type: :development
49
52
  prerelease: false
50
53
  version_requirements: !ruby/object:Gem::Requirement
51
54
  requirements:
52
- - - "~>"
55
+ - - ">="
53
56
  - !ruby/object:Gem::Version
54
57
  version: '4.0'
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: '7'
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: hoe
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
65
  - - "~>"
60
66
  - !ruby/object:Gem::Version
61
- version: '3.16'
67
+ version: '4.1'
62
68
  type: :development
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
72
  - - "~>"
67
73
  - !ruby/object:Gem::Version
68
- version: '3.16'
74
+ version: '4.1'
69
75
  description: sportdb-sync - sport.db sync helpers for leagues, seasons, clubs, match
70
76
  schedules and results, and more
71
- email: opensport@googlegroups.com
77
+ email: gerald.bauer@gmail.com
72
78
  executables: []
73
79
  extensions: []
74
80
  extra_rdoc_files:
@@ -88,15 +94,11 @@ files:
88
94
  - lib/sportdb/sync/season.rb
89
95
  - lib/sportdb/sync/sync.rb
90
96
  - lib/sportdb/sync/version.rb
91
- - test/helper.rb
92
- - test/test_country.rb
93
- - test/test_league.rb
94
- - test/test_misc.rb
95
97
  homepage: https://github.com/sportdb/sport.db
96
98
  licenses:
97
99
  - Public Domain
98
100
  metadata: {}
99
- post_install_message:
101
+ post_install_message:
100
102
  rdoc_options:
101
103
  - "--main"
102
104
  - README.md
@@ -113,9 +115,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
115
  - !ruby/object:Gem::Version
114
116
  version: '0'
115
117
  requirements: []
116
- rubyforge_project:
117
- rubygems_version: 2.5.2
118
- signing_key:
118
+ rubygems_version: 3.4.10
119
+ signing_key:
119
120
  specification_version: 4
120
121
  summary: sportdb-sync - sport.db sync helpers for leagues, seasons, clubs, match schedules
121
122
  and results, and more
data/test/helper.rb DELETED
@@ -1,32 +0,0 @@
1
- ## note: use the local version of sportdb gems
2
- $LOAD_PATH.unshift( File.expand_path( '../sportdb-formats/lib' ))
3
- $LOAD_PATH.unshift( File.expand_path( '../sportdb-catalogs/lib' ))
4
- $LOAD_PATH.unshift( File.expand_path( '../sportdb-models/lib' ))
5
-
6
-
7
- ## minitest setup
8
- require 'minitest/autorun'
9
-
10
-
11
- ## our own code
12
- require 'sportdb/sync'
13
-
14
-
15
- ## use (switch to) "external" datasets
16
- SportDb::Import.config.leagues_dir = "../../../openfootball/leagues"
17
- SportDb::Import.config.clubs_dir = "../../../openfootball/clubs"
18
-
19
-
20
- COUNTRIES = SportDb::Import.catalog.countries
21
- LEAGUES = SportDb::Import.catalog.leagues
22
- CLUBS = SportDb::Import.catalog.clubs
23
-
24
-
25
- SportDb.connect( adapter: 'sqlite3', database: ':memory:' )
26
- SportDb.create_all ## build schema
27
-
28
- ## turn on logging to console
29
- ## ActiveRecord::Base.logger = Logger.new(STDOUT)
30
-
31
-
32
-
data/test/test_country.rb DELETED
@@ -1,50 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # to run use
5
- # ruby -I ./lib -I ./test test/test_country.rb
6
-
7
-
8
- require 'helper'
9
-
10
-
11
- class TestCountry < MiniTest::Test
12
-
13
- Country = SportDb::Sync::Country
14
-
15
- def test_find # note: find uses "data" structs
16
- at = SportDb::Import::Country.new( key: 'at', name: 'Austria', code: 'AUT' )
17
- eng = SportDb::Import::Country.new( key: 'eng', name: 'England', code: 'ENG' )
18
-
19
- rec = Country.find_or_create( at )
20
- rec2 = Country.find_or_create( at )
21
-
22
- rec = Country.find_or_create( eng )
23
- rec2 = Country.find_or_create( eng )
24
- end # method test_find
25
-
26
-
27
- def test_search # note: search uses query strings
28
- rec = Country.search_or_create!( 'at' ) ## try (iso-alpha2) key
29
- assert_equal 'Austria', rec.name
30
- assert_equal 'at', rec.key
31
- assert_equal 'AUT', rec.code
32
-
33
- rec = Country.search_or_create!( 'aut' ) ## try fifa code
34
- assert_equal 'Austria', rec.name
35
- assert_equal 'at', rec.key
36
- assert_equal 'AUT', rec.code
37
-
38
-
39
- rec = Country.search_or_create!( 'eng' )
40
- assert_equal 'England', rec.name
41
- assert_equal 'eng', rec.key
42
- assert_equal 'ENG', rec.code
43
-
44
- rec = Country.search_or_create!( 'eng' )
45
- assert_equal 'England', rec.name
46
- assert_equal 'eng', rec.key
47
- assert_equal 'ENG', rec.code
48
- end
49
-
50
- end # class TestCountry
data/test/test_league.rb DELETED
@@ -1,38 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # to run use
5
- # ruby -I ./lib -I ./test test/test_league.rb
6
-
7
-
8
- require 'helper'
9
-
10
- class TestLeague < MiniTest::Test
11
-
12
- League = SportDb::Sync::League
13
-
14
-
15
- def test_search
16
- rec = League.search_or_create!( 'eng' )
17
- assert_equal 'Premier League', rec.name
18
- assert_equal 'eng.1', rec.key
19
- assert_equal 'eng', rec.country.key
20
- assert_equal 'England', rec.country.name
21
- # assert_equal true, rec.clubs
22
-
23
- rec = League.search!( 'eng' )
24
- assert_equal 'Premier League', rec.name
25
- assert_equal 'eng.1', rec.key
26
- assert_equal 'eng', rec.country.key
27
- assert_equal 'England', rec.country.name
28
- ## assert_equal true, rec.clubs
29
-
30
- ## try 2nd call (just lookup)
31
- rec = League.search_or_create!( 'eng' )
32
- assert_equal 'Premier League', rec.name
33
- assert_equal 'eng.1', rec.key
34
- assert_equal 'eng', rec.country.key
35
- assert_equal 'England', rec.country.name
36
- ## assert_equal true, rec.clubs
37
- end
38
- end # class TestLeague
data/test/test_misc.rb DELETED
@@ -1,29 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ###
4
- # to run use
5
- # ruby -I ./lib -I ./test test/test_misc.rb
6
-
7
-
8
- require 'helper'
9
-
10
- class TestMisc < MiniTest::Test
11
-
12
- Season = SportDb::Sync::Season
13
-
14
-
15
- def test_season
16
- rec = Season.search_or_create( '2017-18' )
17
- assert_equal '2017/18', rec.name
18
- assert_equal '2017/18', rec.key
19
-
20
- rec = Season.search_or_create( '2017/2018' )
21
- assert_equal '2017/18', rec.name
22
- assert_equal '2017/18', rec.key
23
-
24
- rec = Season.search_or_create( '2017/8' )
25
- assert_equal '2017/18', rec.name
26
- assert_equal '2017/18', rec.key
27
- end
28
-
29
- end # class TestMisc