sportdb-readers 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +30 -3
- data/lib/sportdb/readers/version.rb +1 -1
- data/lib/sportdb/readers.rb +28 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 571eb048edc2298d0c059f6af8bd572b9926631c
|
4
|
+
data.tar.gz: 7dc563726f8c82a2fa03327e7b51ba99bff29f20
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1319dcf78797f4a04f766c190cfbea4f2a6777a2925638f63092ab21a073304659e449c7d0443f01addfbf496df61e4cd21112d3ca14b333abbc9a1aba23557
|
7
|
+
data.tar.gz: 8817b8cdf55bb7df0afafd3a8abadc62ac01e05fd82b18e3e6a6cd0bb9228da6662ec49e114b74225a3f41f30c65b23d361c8cdde8ed3c7b7e33faad63745651
|
data/README.md
CHANGED
@@ -37,19 +37,46 @@ ActiveRecord::Base.logger = Logger.new( STDOUT )
|
|
37
37
|
|
38
38
|
## assumes football.db datasets for England in ./england directory
|
39
39
|
## see github.com/openfootball/england
|
40
|
-
SportDb::
|
40
|
+
SportDb::ConfReaderV2.read( './england/2015-16/.conf.txt' )
|
41
41
|
SportDb::MatchReaderV2.read( './england/2015-16/1-premierleague-i.txt' )
|
42
42
|
SportDb::MatchReaderV2.read( './england/2015-16/1-premierleague-ii.txt' )
|
43
43
|
|
44
44
|
## let's try another season
|
45
|
-
SportDb::
|
45
|
+
SportDb::ConfReaderV2.read( './england/2019-20/.conf.txt' )
|
46
46
|
SportDb::MatchReaderV2.read( './england/2019-20/1-premierleague.txt' )
|
47
47
|
```
|
48
48
|
|
49
|
-
|
49
|
+
All leagues, seasons, clubs, match days and rounds, match fixtures and results,
|
50
50
|
and more are now in your (SQL) database of choice.
|
51
51
|
|
52
52
|
|
53
|
+
Or as an alternative use the `read` convenience all-in-one shortcut helper:
|
54
|
+
|
55
|
+
``` ruby
|
56
|
+
## assumes football.db datasets for England in ./england directory
|
57
|
+
## see github.com/openfootball/england
|
58
|
+
SportDb.read( './england/2015-16/.conf.txt' )
|
59
|
+
SportDb.read( './england/2015-16/1-premierleague-i.txt' )
|
60
|
+
SportDb.read( './england/2015-16/1-premierleague-ii.txt' )
|
61
|
+
|
62
|
+
## let's try another season
|
63
|
+
SportDb.read( './england/2019-20/.conf.txt' )
|
64
|
+
SportDb.read( './england/2019-20/1-premierleague.txt' )
|
65
|
+
```
|
66
|
+
|
67
|
+
Or as an alternative pass in the "package" directory and let `read` figure
|
68
|
+
out what datafiles to read:
|
69
|
+
|
70
|
+
``` ruby
|
71
|
+
## assumes football.db datasets for England in ./england directory
|
72
|
+
## see github.com/openfootball/england
|
73
|
+
SportDb.read( './england' )
|
74
|
+
```
|
75
|
+
|
76
|
+
That's it.
|
77
|
+
|
78
|
+
|
79
|
+
|
53
80
|
## License
|
54
81
|
|
55
82
|
The `sportdb-readers` scripts are dedicated to the public domain.
|
data/lib/sportdb/readers.rb
CHANGED
@@ -16,6 +16,34 @@ require 'sportdb/readers/match_parser'
|
|
16
16
|
require 'sportdb/readers/match_reader'
|
17
17
|
|
18
18
|
|
19
|
+
##
|
20
|
+
## add convenience shortcut helpers
|
21
|
+
module SportDb
|
22
|
+
|
23
|
+
def self.read( path )
|
24
|
+
## step 1: collect all datafiles
|
25
|
+
if File.directory?( path ) ## if directory read complete package
|
26
|
+
datafiles_conf = Datafile.find_conf( path )
|
27
|
+
datafiles = Datafile.find( path, %r{/\d{4}-\d{2} ## season folder e.g. /2019-20
|
28
|
+
/[a-z0-9_-]+\.txt$ ## txt e.g /1-premierleague.txt
|
29
|
+
}x )
|
30
|
+
|
31
|
+
datafiles_conf.each { |datafile| EventReaderV2.read( datafile ) }
|
32
|
+
datafiles.each { |datafile| MatchReaderV2.read( datafile ) }
|
33
|
+
else
|
34
|
+
## check if datafile matches configuration naming (e.g. .conf.txt)
|
35
|
+
if Datafile::CONF_REGEX.match( path ) ## fix: use Datafile.match_conf
|
36
|
+
EventReaderV2.read( path )
|
37
|
+
else ## assume "regular" match datafile
|
38
|
+
MatchReaderV2.read( path )
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end # method read
|
42
|
+
|
43
|
+
########################################
|
44
|
+
## more convenience alias
|
45
|
+
ConfReaderV2 = EventReaderV2 ## add why? why not?
|
46
|
+
end # module SportDb
|
19
47
|
|
20
48
|
|
21
49
|
|