sportdb 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +2 -0
- data/lib/sportdb.rb +7 -5
- data/lib/sportdb/cli/main.rb +15 -7
- data/lib/sportdb/cli/opts.rb +7 -8
- data/lib/sportdb/cli/version.rb +1 -1
- data/test/helper.rb +9 -0
- data/test/test_commands.rb +17 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1db9521b6f1a63e9cfc9c1419561b9cbf40c109
|
4
|
+
data.tar.gz: 88f8af72961ab1b4eda1a7becf17eb45c8e60398
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 172cf0501bf06b29023f227afc720d38b2f8af90b7b4152dc24f3a3011568f0f11f012a8f36583c00c5f5c67aeb1f45e242d7f81dc67464d3afcec6b0fa63a59
|
7
|
+
data.tar.gz: c6a30d0fb6a5bada0ed94c769c30dd2bebacaf1ebf52053638420e02bdcfceeeed0d76ab40541938bdfd79fb5d334465f6bb9a90e98484031075d121f0a75b0a
|
data/Manifest.txt
CHANGED
data/lib/sportdb.rb
CHANGED
@@ -19,10 +19,11 @@ require 'sportdb/cli/opts'
|
|
19
19
|
require 'sportdb/cli/main'
|
20
20
|
|
21
21
|
|
22
|
+
|
22
23
|
module SportDb
|
23
24
|
|
24
|
-
def self.main
|
25
|
-
Tool.new.run(
|
25
|
+
def self.main( args=ARGV )
|
26
|
+
Tool.new.run( args )
|
26
27
|
end
|
27
28
|
|
28
29
|
end # module SportDb
|
@@ -33,10 +34,11 @@ end # module SportDb
|
|
33
34
|
|
34
35
|
## puts 'before auto-load (require) sportdb addons'
|
35
36
|
## puts ' before sportdb/update'
|
36
|
-
require 'sportdb/update'
|
37
|
-
|
37
|
+
## require 'sportdb/update'
|
38
|
+
|
39
|
+
puts ' before sportdb/service'
|
38
40
|
require 'sportdb/service'
|
39
|
-
|
41
|
+
puts 'after auto-load (require) sportdb addons'
|
40
42
|
|
41
43
|
|
42
44
|
SportDb.main if __FILE__ == $0
|
data/lib/sportdb/cli/main.rb
CHANGED
@@ -60,6 +60,12 @@ arg_name 'NAME'
|
|
60
60
|
default_value opts.db_name
|
61
61
|
flag [:n, :dbname]
|
62
62
|
|
63
|
+
desc 'Datafile'
|
64
|
+
arg_name 'FILE'
|
65
|
+
default_value opts.datafile
|
66
|
+
flag [:f, :datafile]
|
67
|
+
|
68
|
+
|
63
69
|
desc '(Debug) Show debug messages'
|
64
70
|
switch [:verbose], negatable: false ## todo: use -w for short form? check ruby interpreter if in use too?
|
65
71
|
|
@@ -87,8 +93,8 @@ command [:build,:b] do |c|
|
|
87
93
|
c.action do |g,o,args|
|
88
94
|
|
89
95
|
## check if datafile exists, if NOT assume working dir (./) is a package
|
90
|
-
if File.file?(
|
91
|
-
datafile = Datafile::Datafile.load_file(
|
96
|
+
if File.file?( opts.datafile ) ## note use file? (exist? will also check for directory/folder!!)
|
97
|
+
datafile = Datafile::Datafile.load_file( opts.datafile )
|
92
98
|
datafile.download # datafile step 1 - download all datasets/zips
|
93
99
|
|
94
100
|
connect_to_db( opts )
|
@@ -97,7 +103,7 @@ command [:build,:b] do |c|
|
|
97
103
|
|
98
104
|
datafile.read # datafile step 2 - read all datasets
|
99
105
|
else
|
100
|
-
puts "no
|
106
|
+
puts "no datafile >#{opts.datafile}< found; trying local build in >#{Dir.pwd}<"
|
101
107
|
|
102
108
|
connect_to_db( opts )
|
103
109
|
|
@@ -117,13 +123,13 @@ command [:read,:r] do |c|
|
|
117
123
|
c.action do |g,o,args|
|
118
124
|
|
119
125
|
## check if datafile exists, if NOT assume working dir (./) is a package
|
120
|
-
if File.file?(
|
126
|
+
if File.file?( opts.datafile ) ## note use file? (exist? will also check for directory/folder!!)
|
121
127
|
connect_to_db( opts )
|
122
128
|
|
123
|
-
datafile = Datafile::Datafile.load_file(
|
129
|
+
datafile = Datafile::Datafile.load_file( opts.datafile )
|
124
130
|
datafile.read
|
125
131
|
else
|
126
|
-
puts "no
|
132
|
+
puts "no datafile >#{opts.datafile}< found; trying local read in >#{Dir.pwd}<"
|
127
133
|
|
128
134
|
connect_to_db( opts )
|
129
135
|
|
@@ -143,7 +149,7 @@ command [:download,:dl] do |c|
|
|
143
149
|
|
144
150
|
# note: no database connection needed (check - needed for logs?? - not setup by default???)
|
145
151
|
|
146
|
-
datafile = Datafile::Datafile.load_file(
|
152
|
+
datafile = Datafile::Datafile.load_file( opts.datafile )
|
147
153
|
datafile.download
|
148
154
|
|
149
155
|
puts 'Done.'
|
@@ -163,6 +169,8 @@ command [:new,:n] do |c|
|
|
163
169
|
worker = Fetcher::Worker.new
|
164
170
|
worker.copy( "https://github.com/openfootball/datafile/raw/master/#{setup}.rb", './Datafile' )
|
165
171
|
|
172
|
+
## todo/check: use custom datafile (opts.datafile) if present? why? why not?
|
173
|
+
|
166
174
|
## step 2: same as command build (todo - reuse code)
|
167
175
|
datafile = Datafile::Datafile.load_file( './Datafile' )
|
168
176
|
datafile.download # datafile step 1 - download all datasets/zips
|
data/lib/sportdb/cli/opts.rb
CHANGED
@@ -5,8 +5,9 @@ module SportDb
|
|
5
5
|
class Opts
|
6
6
|
|
7
7
|
def merge_gli_options!( options = {} )
|
8
|
-
@db_path = options[:dbpath]
|
9
|
-
@db_name = options[:dbname]
|
8
|
+
@db_path = options[:dbpath] if options[:dbpath].present?
|
9
|
+
@db_name = options[:dbname] if options[:dbname].present?
|
10
|
+
@datafile = options[:datafile] if options[:datafile].present?
|
10
11
|
|
11
12
|
@verbose = true if options[:verbose] == true
|
12
13
|
end
|
@@ -22,13 +23,11 @@ class Opts
|
|
22
23
|
end
|
23
24
|
|
24
25
|
|
25
|
-
def db_path
|
26
|
-
|
27
|
-
end
|
26
|
+
def db_path() @db_path || '.'; end
|
27
|
+
def db_name() @db_name || 'sport.db'; end
|
28
28
|
|
29
|
-
def
|
30
|
-
|
31
|
-
end
|
29
|
+
def datafile() @datafile || './Datafile'; end
|
30
|
+
def datafile?() @datafile; end ## note: let's you check if datafile is set (or "untouched")
|
32
31
|
end # class Opts
|
33
32
|
|
34
33
|
end # module SportDb
|
data/lib/sportdb/cli/version.rb
CHANGED
data/test/helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
###
|
4
|
+
# to run use
|
5
|
+
# ruby -I ./lib -I ./test test/test_commands.rb
|
6
|
+
|
7
|
+
|
8
|
+
require 'helper'
|
9
|
+
|
10
|
+
class TestCommands < MiniTest::Test
|
11
|
+
|
12
|
+
def test_help
|
13
|
+
args = ['help']
|
14
|
+
SportDb.main( args )
|
15
|
+
end
|
16
|
+
|
17
|
+
end # class TestCommands
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sportdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
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-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sportdb-models
|
@@ -184,6 +184,8 @@ files:
|
|
184
184
|
- lib/sportdb/cli/opts.rb
|
185
185
|
- lib/sportdb/cli/version.rb
|
186
186
|
- lib/sportdb/console.rb
|
187
|
+
- test/helper.rb
|
188
|
+
- test/test_commands.rb
|
187
189
|
homepage: https://github.com/sportdb/sport.db
|
188
190
|
licenses:
|
189
191
|
- Public Domain
|