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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 462f64e48cea18e67436574ea602fb33b00c233f
4
- data.tar.gz: 547a07bb677135cbc245e317ddc2c30d619e5346
3
+ metadata.gz: f1db9521b6f1a63e9cfc9c1419561b9cbf40c109
4
+ data.tar.gz: 88f8af72961ab1b4eda1a7becf17eb45c8e60398
5
5
  SHA512:
6
- metadata.gz: 2640177ec4c7f3c9ff4743f365755adddaf915cb4b05772b2885e5c878c3a2fc70e375ba328226581c664efa0ee26cfcd4c4df05ada239a2608166337da8c440
7
- data.tar.gz: 4874fa7df01d41799af5ac192ba362f3136712e5ff594b2c0601fbf68d5bb4348f49e79c7842972d7d3f90d667b071f9eb554f32b433d148e5ef8b57b3582a20
6
+ metadata.gz: 172cf0501bf06b29023f227afc720d38b2f8af90b7b4152dc24f3a3011568f0f11f012a8f36583c00c5f5c67aeb1f45e242d7f81dc67464d3afcec6b0fa63a59
7
+ data.tar.gz: c6a30d0fb6a5bada0ed94c769c30dd2bebacaf1ebf52053638420e02bdcfceeeed0d76ab40541938bdfd79fb5d334465f6bb9a90e98484031075d121f0a75b0a
@@ -8,3 +8,5 @@ lib/sportdb/cli/main.rb
8
8
  lib/sportdb/cli/opts.rb
9
9
  lib/sportdb/cli/version.rb
10
10
  lib/sportdb/console.rb
11
+ test/helper.rb
12
+ test/test_commands.rb
@@ -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(ARGV)
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
- ## puts ' before sportdb/service'
37
+ ## require 'sportdb/update'
38
+
39
+ puts ' before sportdb/service'
38
40
  require 'sportdb/service'
39
- ## puts 'after auto-load (require) sportdb addons'
41
+ puts 'after auto-load (require) sportdb addons'
40
42
 
41
43
 
42
44
  SportDb.main if __FILE__ == $0
@@ -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?( './Datafile' ) ## note use file? (exist? will also check for directory/folder!!)
91
- datafile = Datafile::Datafile.load_file( './Datafile' )
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 ./Datafile found; try local build in >#{Dir.pwd}<"
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?( './Datafile' ) ## note use file? (exist? will also check for directory/folder!!)
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( './Datafile' )
129
+ datafile = Datafile::Datafile.load_file( opts.datafile )
124
130
  datafile.read
125
131
  else
126
- puts "no ./Datafile found; try local read in >#{Dir.pwd}<"
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( './Datafile' )
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
@@ -5,8 +5,9 @@ module SportDb
5
5
  class Opts
6
6
 
7
7
  def merge_gli_options!( options = {} )
8
- @db_path = options[:dbpath] if options[:dbpath].present?
9
- @db_name = options[:dbname] if options[:dbname].present?
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
- @db_path || '.'
27
- end
26
+ def db_path() @db_path || '.'; end
27
+ def db_name() @db_name || 'sport.db'; end
28
28
 
29
- def db_name
30
- @db_name || 'sport.db'
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
@@ -7,7 +7,7 @@ module SportDbCli # todo/check - rename to SportDbTool or SportDbCommands or
7
7
 
8
8
  MAJOR = 2 ## todo: namespace inside version or something - why? why not??
9
9
  MINOR = 1
10
- PATCH = 0
10
+ PATCH = 1
11
11
  VERSION = [MAJOR,MINOR,PATCH].join('.')
12
12
 
13
13
  def self.version
@@ -0,0 +1,9 @@
1
+ ## $:.unshift(File.dirname(__FILE__))
2
+
3
+ ## minitest setup
4
+
5
+ require 'minitest/autorun'
6
+
7
+
8
+ ## our own code
9
+ require 'sportdb'
@@ -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.0
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-24 00:00:00.000000000 Z
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