sportdb-sync 1.1.3 → 1.2.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 +5 -5
- data/CHANGELOG.md +2 -0
- data/Manifest.txt +0 -4
- data/README.md +5 -4
- data/Rakefile +3 -3
- data/lib/sportdb/sync/country.rb +4 -1
- data/lib/sportdb/sync/season.rb +1 -1
- data/lib/sportdb/sync/sync.rb +32 -1
- data/lib/sportdb/sync/version.rb +3 -4
- data/lib/sportdb/sync.rb +7 -9
- metadata +21 -20
- data/test/helper.rb +0 -32
- data/test/test_country.rb +0 -50
- data/test/test_league.rb +0 -38
- data/test/test_misc.rb +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3bdf919dce7808af99d9c66bf40176532535fecdb8545a03217451a872b6671f
|
4
|
+
data.tar.gz: f8f4274d7155b6685bfdf023fd9c1a9de204786d1bbbdb615dbbc11ecb0639fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d81a3eae0228f7e21914eb203a5fec6b300299c8b3fdbeef2fb549d81f48c2f0c73400440fbf9eda1171e22298f9c9f40730daf3ff27c57b153d894f162b61ca
|
7
|
+
data.tar.gz: ae09a9f1d26a09318d37e12e4857defcef1ce9b030ec9d46f9307a6b77db5d3097f1aed8c5596bf498655db1a7bc17a757f06a87e263db58511d92e72e636b7e
|
data/CHANGELOG.md
CHANGED
data/Manifest.txt
CHANGED
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
|
-
|
27
|
-
[
|
28
|
-
|
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 = '
|
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.
|
24
|
-
['sportdb-models', '>= 2.0
|
23
|
+
['sportdb-catalogs', '>= 1.2.0'],
|
24
|
+
['sportdb-models', '>= 2.1.0'],
|
25
25
|
]
|
26
26
|
|
27
27
|
self.spec_extras = {
|
data/lib/sportdb/sync/country.rb
CHANGED
@@ -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.
|
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 )
|
data/lib/sportdb/sync/season.rb
CHANGED
data/lib/sportdb/sync/sync.rb
CHANGED
@@ -222,7 +222,10 @@ module SportDb
|
|
222
222
|
team1_id: team1_rec.id,
|
223
223
|
team2_id: team2_rec.id,
|
224
224
|
pos: max_pos,
|
225
|
-
|
225
|
+
num: match.num, ## note - might be nil (not nil for euro, world cup, etc.)
|
226
|
+
# date: match.date.to_date, ## todo/fix: split and add date & time!!!!
|
227
|
+
date: match.date, # assume iso format as string e.g. 2021-07-10 !!!
|
228
|
+
time: match.time, # assume iso format as string e.g. 21:00 !!!
|
226
229
|
score1: match.score1,
|
227
230
|
score2: match.score2,
|
228
231
|
score1i: match.score1i,
|
@@ -238,6 +241,34 @@ module SportDb
|
|
238
241
|
attribs[ :stage_id ] = stage_rec.id if stage_rec
|
239
242
|
|
240
243
|
rec = Model::Match.create!( attribs )
|
244
|
+
|
245
|
+
|
246
|
+
#############################################
|
247
|
+
### try to update goals
|
248
|
+
#### quick & dirty v0 - redo !!!!
|
249
|
+
goals = match.goals
|
250
|
+
if goals && goals.size > 0
|
251
|
+
goals.each do |goal|
|
252
|
+
person_rec = Model::Person.find_by(
|
253
|
+
name: goal.name )
|
254
|
+
if person_rec.nil?
|
255
|
+
person_rec = Model::Person.create!(
|
256
|
+
key: goal.name.downcase.gsub( /[^a-z]/, '' ),
|
257
|
+
name: goal.name
|
258
|
+
)
|
259
|
+
end
|
260
|
+
Model::Goal.create!(
|
261
|
+
match_id: rec.id,
|
262
|
+
person_id: person_rec.id,
|
263
|
+
team_id: goal.team == 1 ? rec.team1.id
|
264
|
+
: rec.team2.id,
|
265
|
+
minute: goal.minute,
|
266
|
+
offset: goal.offset,
|
267
|
+
penalty: goal.penalty,
|
268
|
+
owngoal: goal.owngoal,
|
269
|
+
)
|
270
|
+
end
|
271
|
+
end
|
241
272
|
else
|
242
273
|
# update - todo
|
243
274
|
puts "!! ERROR - match updates not yet supported (only inserts); sorry"
|
data/lib/sportdb/sync/version.rb
CHANGED
@@ -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 =
|
10
|
-
PATCH =
|
8
|
+
MINOR = 2
|
9
|
+
PATCH = 1
|
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
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
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
|
4
|
+
version: 1.2.1
|
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:
|
11
|
+
date: 2024-06-27 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.
|
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.
|
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
|
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
|
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: '
|
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: '
|
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:
|
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
|
-
|
117
|
-
|
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
|