sportdb-readers 0.3.3 → 0.3.4
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 +4 -4
- data/lib/sportdb/readers.rb +2 -2
- data/lib/sportdb/readers/package.rb +28 -12
- data/lib/sportdb/readers/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a75121e5975c7428ee0ca635b90a1103d455d784
|
4
|
+
data.tar.gz: 80531e6bc8e447dc191527f0c2368cac99620b63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eb47f23f83386d6f3bcd9df958ca0e05379c23de572312fa8889ea5066afd9f8c94158b8dc3ad275704c7e557f930f23ffe2cbd0fd814a1357b5627086b964c2
|
7
|
+
data.tar.gz: e8ec9a04a9b2d6190924588206cb9e3ffe625e61a280825bdc79c5faa616a1ef3e717bffdcc722b73866dc2b4a0e68133380f773b3e1a0d45a16ad3a52e892b4
|
data/lib/sportdb/readers.rb
CHANGED
@@ -60,9 +60,9 @@ module SportDb
|
|
60
60
|
|
61
61
|
def self.read( path, season: nil, sync: true )
|
62
62
|
pack = if File.directory?( path ) ## if directory assume "unzipped" package
|
63
|
-
|
63
|
+
DirPackage.new( path )
|
64
64
|
elsif File.file?( path ) && Datafile.match_zip( path ) ## check if file is a .zip (archive) file
|
65
|
-
|
65
|
+
ZipPackage.new( path )
|
66
66
|
else ## no package; assume single (standalone) datafile
|
67
67
|
nil
|
68
68
|
end
|
@@ -10,19 +10,25 @@ module SportDb
|
|
10
10
|
/[a-z0-9_-]+\.txt$ ## txt e.g /1-premierleague.txt
|
11
11
|
}x
|
12
12
|
|
13
|
-
def initialize(
|
14
|
-
if
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
def initialize( path_or_pack )
|
14
|
+
if path_or_pack.is_a?( Datafile::DirPackage ) ||
|
15
|
+
path_or_pack.is_a?( Datafile::ZipPackage )
|
16
|
+
@pack = path_or_pack
|
17
|
+
else ## assume it's a (string) path
|
18
|
+
path = path_or_pack
|
19
|
+
if !File.exist?( path ) ## file or directory
|
20
|
+
puts "** !!! ERROR !!! file NOT found >#{path}<; cannot open package"
|
21
|
+
exit 1
|
22
|
+
end
|
18
23
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
24
|
+
if File.directory?( path )
|
25
|
+
@pack = Datafile::DirPackage.new( path ) ## delegate to "generic" package
|
26
|
+
elsif File.file?( path ) && File.extname( path ) == '.zip' # note: includes dot (.) eg .zip
|
27
|
+
@pack = Datafile::ZipPackage.new( path )
|
28
|
+
else
|
29
|
+
puts "** !!! ERROR !!! cannot open package - directory or file with .zip extension required"
|
30
|
+
exit 1
|
31
|
+
end
|
26
32
|
end
|
27
33
|
end
|
28
34
|
|
@@ -87,4 +93,14 @@ module SportDb
|
|
87
93
|
end
|
88
94
|
end
|
89
95
|
end # class Package
|
96
|
+
|
97
|
+
|
98
|
+
class DirPackage < Package
|
99
|
+
def initialize( path ) super( Datafile::DirPackage.new( path ) ); end
|
100
|
+
end
|
101
|
+
|
102
|
+
class ZipPackage < Package
|
103
|
+
def initialize( path ) super( Datafile::ZipPackage.new( path ) ); end
|
104
|
+
end
|
105
|
+
|
90
106
|
end # module SportDb
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sportdb-readers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gerald Bauer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sportdb-config
|