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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0bb0a6a7c3690ca023fec024bc3a1126ee97899
4
- data.tar.gz: 15d4d25225734b4931d47cbb727e02c291c4d887
3
+ metadata.gz: 571eb048edc2298d0c059f6af8bd572b9926631c
4
+ data.tar.gz: 7dc563726f8c82a2fa03327e7b51ba99bff29f20
5
5
  SHA512:
6
- metadata.gz: 8b0e884cf228c6d7982a452985004984b1e427db31fad1ccd4dee18586d89aae03732bceeb152541d0ede5976bd6f079a1d4021c0d0ef9243757cd36da4ab558
7
- data.tar.gz: 57cc903ae9fd50aa346c98dc3025a44c8d6723bdca91329c8606c3cf9f1fdb3ddc5480c5e1ba6dfa401bb8ff57191f44883036aec15afb62060edccb2205dee4
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::EventReaderV2.read( './england/2015-16/.conf.txt' )
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::EventReaderV2.read( './england/2019-20/.conf.txt' )
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
- That's it. All leagues, seasons, clubs, match days and rounds, match fixtures and results,
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.
@@ -6,7 +6,7 @@ module Readers
6
6
 
7
7
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
8
8
  MINOR = 1
9
- PATCH = 0
9
+ PATCH = 1
10
10
  VERSION = [MAJOR,MINOR,PATCH].join('.')
11
11
 
12
12
  def self.version
@@ -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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportdb-readers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer