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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2b15f6d3dbaef2a2d05eca174b86731092ba54b6
4
- data.tar.gz: 265e5151c0e81d1beaf5b7cad751f4abfef484e5
3
+ metadata.gz: a75121e5975c7428ee0ca635b90a1103d455d784
4
+ data.tar.gz: 80531e6bc8e447dc191527f0c2368cac99620b63
5
5
  SHA512:
6
- metadata.gz: b943c21d84d36738e562e68a73f2a5de58e7ec693361ad74a96aa04d9ed0f9b5201c876cea62fae0d8daa532f090a6556ade2f78abfac3d12282c987f6710ef5
7
- data.tar.gz: 66ee60adbd4ed8bfc34718d3520b24b5840e11193ffeb9f0fab83bc1fec9e7947febc0bc09bfa06123df0b310d1435d74310f5e9a422d3b0a4d0c25f689a5da2
6
+ metadata.gz: eb47f23f83386d6f3bcd9df958ca0e05379c23de572312fa8889ea5066afd9f8c94158b8dc3ad275704c7e557f930f23ffe2cbd0fd814a1357b5627086b964c2
7
+ data.tar.gz: e8ec9a04a9b2d6190924588206cb9e3ffe625e61a280825bdc79c5faa616a1ef3e717bffdcc722b73866dc2b4a0e68133380f773b3e1a0d45a16ad3a52e892b4
@@ -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
- Package.new( path )
63
+ DirPackage.new( path )
64
64
  elsif File.file?( path ) && Datafile.match_zip( path ) ## check if file is a .zip (archive) file
65
- Package.new( path )
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( path )
14
- if !File.exist?( path ) ## file or directory
15
- puts "** !!! ERROR !!! file NOT found >#{path}<; cannot open package"
16
- exit 1
17
- end
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
- if File.directory?( path )
20
- @pack = Datafile::DirPackage.new( path ) ## delegate to "generic" package
21
- elsif File.file?( path ) && File.extname( path ) == '.zip' # note: includes dot (.) eg .zip
22
- @pack = Datafile::ZipPackage.new( path )
23
- else
24
- puts "** !!! ERROR !!! cannot open package - directory or file with .zip extension required"
25
- exit 1
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
@@ -6,7 +6,7 @@ module Readers
6
6
 
7
7
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
8
8
  MINOR = 3
9
- PATCH = 3
9
+ PATCH = 4
10
10
  VERSION = [MAJOR,MINOR,PATCH].join('.')
11
11
 
12
12
  def self.version
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.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-19 00:00:00.000000000 Z
11
+ date: 2019-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sportdb-config