sportdb 2.1.1 → 2.3.2

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: f1db9521b6f1a63e9cfc9c1419561b9cbf40c109
4
- data.tar.gz: 88f8af72961ab1b4eda1a7becf17eb45c8e60398
3
+ metadata.gz: 9a2eaeb80608f85c3e56cd97938b203aabd55a53
4
+ data.tar.gz: 875947bbad6d080c900a4e04eb0007a52e75dc3e
5
5
  SHA512:
6
- metadata.gz: 172cf0501bf06b29023f227afc720d38b2f8af90b7b4152dc24f3a3011568f0f11f012a8f36583c00c5f5c67aeb1f45e242d7f81dc67464d3afcec6b0fa63a59
7
- data.tar.gz: c6a30d0fb6a5bada0ed94c769c30dd2bebacaf1ebf52053638420e02bdcfceeeed0d76ab40541938bdfd79fb5d334465f6bb9a90e98484031075d121f0a75b0a
6
+ metadata.gz: c4952c8d6e193084214b07917bc58b9fd655f68e888cb545a1de14cdb40318b6de9141cbd35643609209a8d9a5a07155df10d7d6b745319c259c2fa335116733
7
+ data.tar.gz: f9f123cdb8bc3313d610a0b756d2d92e5ef3f1ac7985e8e61f283be1e8b1ea57ec9f53e1ddcbc61ab87b216a8e640535b0f5b525e224bed353f6c710a26f70e2
@@ -1,4 +1,4 @@
1
-
2
- ### 0.1.0 / 2014-12-05
3
-
4
- * Everything is new. First release
1
+
2
+ ### 0.1.0 / 2014-12-05
3
+
4
+ * Everything is new. First release
data/README.md CHANGED
@@ -1,123 +1,123 @@
1
- # sportdb - sport.db Command Line Tool
2
-
3
-
4
- <!--
5
- [![Build Status](https://secure.travis-ci.org/geraldb/sport.db.ruby.png?branch=master)](http://travis-ci.org/geraldb/sport.db.ruby)
6
- -->
7
-
8
- * home :: [github.com/sportdb/sport.db](https://github.com/sportdb/sport.db)
9
- * bugs :: [github.com/sportdb/sport.db/issues](https://github.com/sportdb/sport.db/issues)
10
- * gem :: [rubygems.org/gems/sportdb](https://rubygems.org/gems/sportdb)
11
- * rdoc :: [rubydoc.info/gems/sportdb](http://rubydoc.info/gems/sportdb)
12
- * forum :: [groups.google.com/group/opensport](https://groups.google.com/group/opensport)
13
-
14
-
15
- ## Usage
16
-
17
- The sportdb tool lets you read in (parse) datasets (e.g. leagues, clubs, match schedules, etc.)
18
- in plain text into your sports SQL database of choice (e.g. SQLite, PostgreSQL, etc.)
19
-
20
- ```
21
- SYNOPSIS
22
- sportdb [global options] command [command options] [arguments...]
23
-
24
- VERSION
25
- 2.0
26
-
27
- GLOBAL OPTIONS
28
- -d, --dbpath=PATH - Database path (default: .)
29
- -n, --dbname=NAME - Database name (default: sport.db)
30
- --verbose - (Debug) Show debug messages
31
- --version - Show version
32
-
33
- COMMANDS
34
- new, n - Build DB w/ quick starter Datafile templates
35
- build, b - Build DB (download/create/read); use ./Datafile - zips get downloaded to ./tmp
36
- serve, server - Start web service (HTTP JSON API)
37
-
38
- MORE COMMANDS
39
- create - Create DB schema
40
- download, dl - Download datasets; use ./Datafile - zips get downloaded to ./tmp
41
- read, r - Read datasets; use ./Datafile - zips required in ./tmp
42
- logs - Show logs
43
- props - Show props
44
- stats - Show stats
45
- test - (Debug) Test command suite
46
- help - Shows a list of commands or help for one command
47
- ```
48
-
49
-
50
- ### `new` Command
51
-
52
- ```
53
- NAME
54
- new - Build DB w/ quick starter Datafile templates
55
- SYNOPSIS
56
- sportdb [global options] new NAME
57
-
58
- EXAMPLES
59
- sportdb new eng2019-20
60
- sportdb new eng
61
- ```
62
-
63
-
64
- ### `build` Command
65
-
66
- ```
67
- NAME
68
- build - Build DB (download/create/read); use ./Datafile - zips get downloaded to ./tmp
69
-
70
- SYNOPSIS
71
- sportdb [global options] build
72
-
73
- EXAMPLES
74
- sportdb build
75
- ```
76
-
77
-
78
- ### `serve` Command
79
-
80
- ```
81
- NAME
82
- serve - Start web service (HTTP JSON API)
83
-
84
- SYNOPSIS
85
- sportdb [global options] serve
86
-
87
- EXAMPLES
88
- sportdb serve
89
- ```
90
-
91
-
92
- ## Install
93
-
94
- Just install the gem:
95
-
96
- $ gem install sportdb
97
-
98
-
99
-
100
- ## More Documentation / Getting Started Guides
101
-
102
- See the **[football.db League Starter Sample - Mauritius Premier League](https://github.com/openfootball/league-starter)**
103
- if you want to start from scratch (zero) with your very own league.
104
-
105
- See the **[football.db Quick Starter Datafile Templates](https://github.com/openfootball/quick-starter)** if you want to read in ready-to-use /
106
- ready-to-fork dataset packages incl. the English Premier League, the German
107
- Bundesliga, the Spanish Primera División and some more.
108
-
109
-
110
-
111
- ## License
112
-
113
- ![](https://publicdomainworks.github.io/buttons/zero88x31.png)
114
-
115
- The `sportdb` scripts are dedicated to the public domain.
116
- Use it as you please with no restrictions whatsoever.
117
-
118
-
119
- ## Questions? Comments?
120
-
121
- Send them along to the
122
- [Open Sports & Friends Forum/Mailing List](http://groups.google.com/group/opensport).
123
- Thanks!
1
+ # sportdb - sport.db Command Line Tool
2
+
3
+
4
+ <!--
5
+ [![Build Status](https://secure.travis-ci.org/geraldb/sport.db.ruby.png?branch=master)](http://travis-ci.org/geraldb/sport.db.ruby)
6
+ -->
7
+
8
+ * home :: [github.com/sportdb/sport.db](https://github.com/sportdb/sport.db)
9
+ * bugs :: [github.com/sportdb/sport.db/issues](https://github.com/sportdb/sport.db/issues)
10
+ * gem :: [rubygems.org/gems/sportdb](https://rubygems.org/gems/sportdb)
11
+ * rdoc :: [rubydoc.info/gems/sportdb](http://rubydoc.info/gems/sportdb)
12
+ * forum :: [groups.google.com/group/opensport](https://groups.google.com/group/opensport)
13
+
14
+
15
+ ## Usage
16
+
17
+ The sportdb tool lets you read in (parse) datasets (e.g. leagues, clubs, match schedules, etc.)
18
+ in plain text into your sports SQL database of choice (e.g. SQLite, PostgreSQL, etc.)
19
+
20
+ ```
21
+ SYNOPSIS
22
+ sportdb [global options] command [command options] [arguments...]
23
+
24
+ VERSION
25
+ 2.0
26
+
27
+ GLOBAL OPTIONS
28
+ -d, --dbpath=PATH - Database path (default: .)
29
+ -n, --dbname=NAME - Database name (default: sport.db)
30
+ --verbose - (Debug) Show debug messages
31
+ --version - Show version
32
+
33
+ COMMANDS
34
+ new, n - Build DB w/ quick starter Datafile templates
35
+ build, b - Build DB (download/create/read); use ./Datafile - zips get downloaded to ./tmp
36
+ serve, server - Start web service (HTTP JSON API)
37
+
38
+ MORE COMMANDS
39
+ create - Create DB schema
40
+ download, dl - Download datasets; use ./Datafile - zips get downloaded to ./tmp
41
+ read, r - Read datasets; use ./Datafile - zips required in ./tmp
42
+ logs - Show logs
43
+ props - Show props
44
+ stats - Show stats
45
+ test - (Debug) Test command suite
46
+ help - Shows a list of commands or help for one command
47
+ ```
48
+
49
+
50
+ ### `new` Command
51
+
52
+ ```
53
+ NAME
54
+ new - Build DB w/ quick starter Datafile templates
55
+ SYNOPSIS
56
+ sportdb [global options] new NAME
57
+
58
+ EXAMPLES
59
+ sportdb new eng2019-20
60
+ sportdb new eng
61
+ ```
62
+
63
+
64
+ ### `build` Command
65
+
66
+ ```
67
+ NAME
68
+ build - Build DB (download/create/read); use ./Datafile - zips get downloaded to ./tmp
69
+
70
+ SYNOPSIS
71
+ sportdb [global options] build
72
+
73
+ EXAMPLES
74
+ sportdb build
75
+ ```
76
+
77
+
78
+ ### `serve` Command
79
+
80
+ ```
81
+ NAME
82
+ serve - Start web service (HTTP JSON API)
83
+
84
+ SYNOPSIS
85
+ sportdb [global options] serve
86
+
87
+ EXAMPLES
88
+ sportdb serve
89
+ ```
90
+
91
+
92
+ ## Install
93
+
94
+ Just install the gem:
95
+
96
+ $ gem install sportdb
97
+
98
+
99
+
100
+ ## More Documentation / Getting Started Guides
101
+
102
+ See the **[football.db League Starter Sample - Mauritius Premier League](https://github.com/openfootball/league-starter)**
103
+ if you want to start from scratch (zero) with your very own league.
104
+
105
+ See the **[football.db Quick Starter Datafile Templates](https://github.com/openfootball/quick-starter)** if you want to read in ready-to-use /
106
+ ready-to-fork dataset packages incl. the English Premier League, the German
107
+ Bundesliga, the Spanish Primera División and some more.
108
+
109
+
110
+
111
+ ## License
112
+
113
+ ![](https://publicdomainworks.github.io/buttons/zero88x31.png)
114
+
115
+ The `sportdb` scripts are dedicated to the public domain.
116
+ Use it as you please with no restrictions whatsoever.
117
+
118
+
119
+ ## Questions? Comments?
120
+
121
+ Send them along to the
122
+ [Open Sports & Friends Forum/Mailing List](http://groups.google.com/group/opensport).
123
+ Thanks!
data/Rakefile CHANGED
@@ -1,58 +1,58 @@
1
- require 'hoe'
2
- require './lib/sportdb/cli/version.rb'
3
-
4
-
5
- Hoe.spec 'sportdb' do
6
-
7
- self.version = SportDbCli::VERSION
8
-
9
- self.summary = 'sportdb - sport.db Command Line Tool'
10
- self.description = summary
11
-
12
- self.urls = ['https://github.com/sportdb/sport.db']
13
-
14
- self.author = 'Gerald Bauer'
15
- self.email = 'opensport@googlegroups.com'
16
-
17
- # switch extension to .markdown for gihub formatting
18
- # -- Note: auto-changed when included in manifest
19
- self.readme_file = 'README.md'
20
- self.history_file = 'CHANGELOG.md'
21
-
22
- self.extra_deps = [
23
- ['sportdb-models', '>= 1.18.2'],
24
- ['sportdb-readers', '>= 0.3.6'],
25
- ['footballdb-leagues', '>= 2019.11.22' ], ## add minimum for datasets
26
- ['footballdb-clubs', '>= 2019.11.22' ],
27
-
28
- ['fetcher', '>= 0.4.5'], ## check if included already in datafil ??
29
- ['datafile', '>= 0.3.1'],
30
-
31
- ### sportdb addons
32
- ## ['sportdb-keys'],
33
- ## ['sportdb-update'],
34
- ['sportdb-service'],
35
-
36
- ## 3rd party
37
- ['gli', '>= 2.12.2'],
38
-
39
- ## ['activerecord'], # Note: will include activesupport,etc.
40
- ['sqlite3']
41
- ]
42
-
43
- self.licenses = ['Public Domain']
44
-
45
- self.spec_extras = {
46
- required_ruby_version: '>= 2.2.2'
47
- }
48
-
49
- self.post_install_message =<<TXT
50
- ******************************************************************************
51
-
52
- Questions? Comments? Send them along to the mailing list.
53
- https://groups.google.com/group/opensport
54
-
55
- ******************************************************************************
56
- TXT
57
-
58
- end
1
+ require 'hoe'
2
+ require './lib/sportdb/cli/version.rb'
3
+
4
+
5
+ Hoe.spec 'sportdb' do
6
+
7
+ self.version = SportDbCli::VERSION
8
+
9
+ self.summary = 'sportdb - sport.db Command Line Tool'
10
+ self.description = summary
11
+
12
+ self.urls = { home: 'https://github.com/sportdb/sport.db' }
13
+
14
+ self.author = 'Gerald Bauer'
15
+ self.email = 'opensport@googlegroups.com'
16
+
17
+ # switch extension to .markdown for gihub formatting
18
+ # -- Note: auto-changed when included in manifest
19
+ self.readme_file = 'README.md'
20
+ self.history_file = 'CHANGELOG.md'
21
+
22
+ self.extra_deps = [
23
+ ['sportdb-readers', '>= 1.1.2'],
24
+
25
+ ['fetcher', '>= 0.4.5'], ## check if included already in datafil ??
26
+ ['datafile', '>= 0.3.1'],
27
+ ['webservice', '>= 0.7.0'],
28
+
29
+ ### incl. sportdb addons - why? why not?
30
+ ## ['sportdb-keys'],
31
+ ## ['sportdb-update'],
32
+
33
+ ## 3rd party
34
+ ['gli', '>= 2.19.0'],
35
+
36
+ ## ['activerecord'], # Note: will include activesupport,etc.
37
+ ['sqlite3'],
38
+
39
+ ## more tools
40
+ ['football-to-sqlite'],
41
+ ]
42
+
43
+ self.licenses = ['Public Domain']
44
+
45
+ self.spec_extras = {
46
+ required_ruby_version: '>= 2.2.2'
47
+ }
48
+
49
+ self.post_install_message =<<TXT
50
+ ******************************************************************************
51
+
52
+ Questions? Comments? Send them along to the mailing list.
53
+ https://groups.google.com/group/opensport
54
+
55
+ ******************************************************************************
56
+ TXT
57
+
58
+ end
@@ -1,5 +1,5 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'sportdb'
4
-
5
- SportDb.main
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'sportdb'
4
+
5
+ SportDb.main
@@ -1,44 +1,97 @@
1
- # encoding: utf-8
2
-
3
-
4
- require 'sportdb/models'
5
- require 'sportdb/readers'
6
-
7
- require 'logutils/activerecord' ## NOTE: check - add to/include in/move to sportdb/models
8
-
9
- ## check if already included in datafile gem ??
10
- require 'fetcher' # for fetching/downloading fixtures via HTTP/HTTPS etc.
11
- require 'datafile' ## lets us use Datafile::Builder,Datafile etc.
12
-
13
- require 'gli'
14
-
15
- # our own code
16
-
17
- require 'sportdb/cli/version' # let version always go first
18
- require 'sportdb/cli/opts'
19
- require 'sportdb/cli/main'
20
-
21
-
22
-
23
- module SportDb
24
-
25
- def self.main( args=ARGV )
26
- Tool.new.run( args )
27
- end
28
-
29
- end # module SportDb
30
-
31
-
32
- #####
33
- # auto-load/require some addons
34
-
35
- ## puts 'before auto-load (require) sportdb addons'
36
- ## puts ' before sportdb/update'
37
- ## require 'sportdb/update'
38
-
39
- puts ' before sportdb/service'
40
- require 'sportdb/service'
41
- puts 'after auto-load (require) sportdb addons'
42
-
43
-
44
- SportDb.main if __FILE__ == $0
1
+ # encoding: utf-8
2
+
3
+ require 'sportdb/readers'
4
+
5
+ require 'logutils/activerecord' ## NOTE: check - add to/include in/move to sportdb/models
6
+
7
+ ## check if already included in datafile gem ??
8
+ require 'fetcher' # for fetching/downloading fixtures via HTTP/HTTPS etc.
9
+ require 'datafile' ## lets us use Datafile::Builder,Datafile etc.
10
+
11
+ require 'gli'
12
+
13
+ # our own code
14
+
15
+ require 'sportdb/cli/version' # let version always go first
16
+ require 'sportdb/cli/opts'
17
+ require 'sportdb/cli/main'
18
+
19
+
20
+
21
+ module SportDb
22
+
23
+ def self.main( args=ARGV )
24
+ Tool.new.run( args )
25
+ end
26
+
27
+ end # module SportDb
28
+
29
+
30
+
31
+ ##################
32
+ # add web service support / machinery
33
+
34
+ require 'webservice'
35
+
36
+ ####
37
+ ## used for server/service command
38
+ ## "preconfigured" base class for webservice
39
+ class SportDbService < Webservice::Base
40
+ include SportDb::Models # e.g. League, Season, Team, etc.
41
+
42
+ ## (auto-)add some (built-in) routes
43
+
44
+ get '/version(s)?' do
45
+ {
46
+ "sportdb": SportDbCli::VERSION, ## todo/fix: change to DbTool!!!
47
+ "sportdb/models": SportDb::VERSION,
48
+ ## todo/fix: add beerdb/note version - if present
49
+ ## todo/fix: add worlddb/models version
50
+ ## todo/fix: add some more libs - why? why not??
51
+ "activerecord": [ActiveRecord::VERSION::MAJOR,ActiveRecord::VERSION::MINOR,ActiveRecord::VERSION::TINY].join('.'),
52
+ "webservice": Webservice::VERSION,
53
+ "rack": "#{Rack::RELEASE} (#{Rack::VERSION.join('.')})", ## note: VERSION is the protocoll version as an array e.g.[1,2]
54
+ "ruby": "#{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]",
55
+ }
56
+ end
57
+
58
+ get '/(stats|tables)' do
59
+ {
60
+ "teams": SportDb::Model::Team.count,
61
+ "games": SportDb::Model::Game.count,
62
+ "events": SportDb::Model::Event.count,
63
+ "leagues": SportDb::Model::League.count,
64
+ "seasons": SportDb::Model::Season.count,
65
+ "countries": WorldDb::Model::Country.count,
66
+ "system": {
67
+ "props": ConfDb::Models::Prop.count,
68
+ "logs": LogDb::Models::Log.count,
69
+ }
70
+ }
71
+ end
72
+
73
+ get '/props(.:format)?' do # note: add format - lets you use props.csv and props.html
74
+ ConfDb::Models::Prop.all
75
+ end
76
+
77
+ get '/logs(.:format)?' do
78
+ LogDb::Models::Log.all
79
+ end
80
+
81
+
82
+ ## add favicon support
83
+ # get '/favicon.ico' do
84
+ ## use 302 to redirect
85
+ ## note: use strg+F5 to refresh page (clear cache for favicon.ico)
86
+ # redirect '/webservice-sportdb-32x32.png'
87
+ # end
88
+
89
+ # get '/webservice-beerdb-32x32.png' do
90
+ # send_file "#{SportDbCli.root}/assets/webservice-sportdb-32x32.png"
91
+ # end
92
+
93
+ end # class SportDbService
94
+
95
+
96
+
97
+ SportDb.main if __FILE__ == $0
@@ -65,6 +65,17 @@ arg_name 'FILE'
65
65
  default_value opts.datafile
66
66
  flag [:f, :datafile]
67
67
 
68
+ desc 'Leagues dir'
69
+ arg_name 'PATH'
70
+ default_value nil
71
+ flag [:'leagues-dir', :leaguesdir]
72
+
73
+ desc 'Clubs dir'
74
+ arg_name 'PATH'
75
+ default_value nil
76
+ flag [:'clubs-dir', :clubsdir]
77
+
78
+
68
79
 
69
80
  desc '(Debug) Show debug messages'
70
81
  switch [:verbose], negatable: false ## todo: use -w for short form? check ruby interpreter if in use too?
@@ -186,38 +197,40 @@ command [:new,:n] do |c|
186
197
  end # command setup
187
198
 
188
199
 
189
-
190
200
  desc 'Start web service (HTTP JSON API)'
191
- command [:serve,:server] do |c|
201
+ arg_name 'NAME' # optional setup profile name
202
+ command [:serve,:server,:s] do |c|
192
203
 
193
204
  c.action do |g,o,args|
194
205
 
195
- connect_to_db( opts )
206
+ ## todo: document optional script arg (defaults to service)
207
+ script = args[0] || 'service'
208
+
209
+ ## todo/fix: add support for (default) Service (with no extension)
196
210
 
197
- # note: server (HTTP service) not included in standard default require
198
- ## -- note - now included!!!
199
- ## require 'sportdb/service'
200
-
201
- # make sure connections get closed after every request e.g.
202
- #
203
- # after do
204
- # ActiveRecord::Base.connection.close
205
- # end
206
- #
207
-
208
- puts 'before add middleware ConnectionManagement'
209
- SportDb::Service::Server.use ActiveRecord::ConnectionAdapters::ConnectionManagement
210
- puts 'after add middleware ConnectionManagement'
211
- ## todo: check if we can check on/dump middleware stack
212
-
213
- ## rack middleware might not work with multi-threaded thin web server; close it ourselfs
214
- SportDb::Service::Server.after do
215
- puts " #{Thread.current.object_id} -- make sure db connections gets closed after request"
216
- # todo: check if connection is open - how?
217
- ActiveRecord::Base.connection.close
211
+ script_path = "#{script}.rb" ## auto-add .rb extension
212
+
213
+ unless File.exist?( script_path ) ## if file doesn't exist try to fetch service script
214
+ script_path = "./#{script}.rb" ## use / save script in local (current) working dir/folder
215
+ worker = Fetcher::Worker.new
216
+ ## note: lets use http:// instead of https:// for now - lets us use person proxy (NOT working w/ https for now)
217
+ worker.copy( "http://github.com/sportdb/sport.db.service/raw/master/#{script}.rb", script_path )
218
218
  end
219
219
 
220
- SportDb::Service::Server.run!
220
+
221
+ code = File.open( script_path, 'r:utf-8' ) { |f| f.read }
222
+
223
+ connect_to_db( opts )
224
+
225
+ SportDb.tables ## print table stats
226
+
227
+ SportDbService.class_eval( code ) ## note: MUST use class_eval (do NOT use instance_eval) !!!
228
+
229
+ puts "dump routes:"
230
+ pp SportDbService.routes
231
+
232
+ puts "starting server..."
233
+ SportDbService.run!
221
234
 
222
235
  puts 'Done.'
223
236
  end
@@ -225,6 +238,7 @@ end # command serve
225
238
 
226
239
 
227
240
 
241
+
228
242
  desc 'Show logs'
229
243
  command :logs do |c|
230
244
  c.action do |g,o,args|
@@ -301,6 +315,18 @@ pre do |g,c,o,args|
301
315
  LogUtils::Logger.root.level = :debug
302
316
  end
303
317
 
318
+
319
+ if opts.clubs_dir?
320
+ puts " setting clubs_dir to >#{opts.clubs_dir}<"
321
+ SportDb::Import.config.clubs_dir = opts.clubs_dir
322
+ end
323
+
324
+ if opts.leagues_dir?
325
+ puts " setting leagues_dir to >#{opts.leagues_dir}<"
326
+ SportDb::Import.config.leagues_dir = opts.leagues_dir
327
+ end
328
+
329
+
304
330
  logger.debug "Executing #{c.name}"
305
331
  true
306
332
  end
@@ -1,33 +1,43 @@
1
- # encoding: utf-8
2
-
3
- module SportDb
4
-
5
- class Opts
6
-
7
- def merge_gli_options!( options = {} )
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?
11
-
12
- @verbose = true if options[:verbose] == true
13
- end
14
-
15
-
16
- def verbose=(boolean) # add: alias for debug ??
17
- @verbose = boolean
18
- end
19
-
20
- def verbose?
21
- return false if @verbose.nil? # default verbose/debug flag is false
22
- @verbose == true
23
- end
24
-
25
-
26
- def db_path() @db_path || '.'; end
27
- def db_name() @db_name || 'sport.db'; end
28
-
29
- def datafile() @datafile || './Datafile'; end
30
- def datafile?() @datafile; end ## note: let's you check if datafile is set (or "untouched")
31
- end # class Opts
32
-
33
- end # module SportDb
1
+ # encoding: utf-8
2
+
3
+ module SportDb
4
+
5
+ class Opts
6
+
7
+ def merge_gli_options!( options = {} )
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?
11
+
12
+ @verbose = true if options[:verbose] == true
13
+
14
+ @leagues_dir = options[:'leagues-dir'] if options[:'leagues-dir'].present?
15
+ @clubs_dir = options[:'clubs-dir'] if options[:'clubs-dir'].present?
16
+ end
17
+
18
+
19
+ def verbose=(boolean) # add: alias for debug ??
20
+ @verbose = boolean
21
+ end
22
+
23
+ def verbose?
24
+ return false if @verbose.nil? # default verbose/debug flag is false
25
+ @verbose == true
26
+ end
27
+
28
+
29
+ def db_path() @db_path || '.'; end
30
+ def db_name() @db_name || 'sport.db'; end
31
+
32
+ def datafile() @datafile || './Datafile'; end
33
+ def datafile?() @datafile; end ## note: let's you check if datafile is set (or "untouched")
34
+
35
+
36
+ def clubs_dir() @clubs_dir; end
37
+ def clubs_dir?() @clubs_dir.nil? == false; end ## note: let's you check if clubs_dir set (by default it's NOT set)
38
+
39
+ def leagues_dir() @leagues_dir; end
40
+ def leagues_dir?() @leagues_dir.nil? == false; end
41
+ end # class Opts
42
+
43
+ end # module SportDb
@@ -1,25 +1,25 @@
1
- # encoding: utf-8
2
-
3
- # Note: SportDb::VERSION gets used by core, that is, sportdb-models
4
-
5
- ## todo/fix: yes, rename to SportDbTool
6
- module SportDbCli # todo/check - rename to SportDbTool or SportDbCommands or SportDbShell ??
7
-
8
- MAJOR = 2 ## todo: namespace inside version or something - why? why not??
9
- MINOR = 1
10
- PATCH = 1
11
- VERSION = [MAJOR,MINOR,PATCH].join('.')
12
-
13
- def self.version
14
- VERSION
15
- end
16
-
17
- def self.banner
18
- "sportdb/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
19
- end
20
-
21
- def self.root
22
- "#{File.expand_path( File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) )}"
23
- end
24
-
25
- end # module SportDbCli
1
+ # encoding: utf-8
2
+
3
+ # Note: SportDb::VERSION gets used by core, that is, sportdb-models
4
+
5
+ ## todo/fix: yes, rename to SportDbTool
6
+ module SportDbCli # todo/check - rename to SportDbTool or SportDbCommands or SportDbShell ??
7
+
8
+ MAJOR = 2 ## todo: namespace inside version or something - why? why not??
9
+ MINOR = 3
10
+ PATCH = 2
11
+ VERSION = [MAJOR,MINOR,PATCH].join('.')
12
+
13
+ def self.version
14
+ VERSION
15
+ end
16
+
17
+ def self.banner
18
+ "sportdb/#{VERSION} on Ruby #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) [#{RUBY_PLATFORM}]"
19
+ end
20
+
21
+ def self.root
22
+ "#{File.expand_path( File.dirname(File.dirname(File.dirname(File.dirname(__FILE__)))) )}"
23
+ end
24
+
25
+ end # module SportDbCli
@@ -1,109 +1,109 @@
1
-
2
- require 'logger'
3
- require 'sportdb/models'
4
-
5
-
6
- ## shortcuts for models
7
-
8
- ##
9
- ## todo/fix: just use include SportDb::Models - why? why not? is it possible/working?
10
-
11
- Badge = SportDb::Model::Badge
12
- Event = SportDb::Model::Event
13
- Game = SportDb::Model::Game
14
- Goal = SportDb::Model::Goal
15
- Group = SportDb::Model::Group
16
- League = SportDb::Model::League
17
- Person = SportDb::Model::Person
18
- Roster = SportDb::Model::Roster
19
- Round = SportDb::Model::Round
20
- Season = SportDb::Model::Season
21
- Team = SportDb::Model::Team
22
-
23
-
24
- ### todo: check for racing.db extension if present??
25
- ## only add if present
26
- Race = SportDb::Model::Race
27
- Record = SportDb::Model::Record
28
- Run = SportDb::Model::Run
29
- Track = SportDb::Model::Track
30
-
31
-
32
-
33
- Tag = WorldDb::Model::Tag
34
- Tagging = WorldDb::Model::Tagging
35
- Continent = WorldDb::Model::Continent
36
- Country = WorldDb::Model::Country
37
- Region = WorldDb::Model::Region
38
- City = WorldDb::Model::City
39
- Prop = WorldDb::Model::Prop
40
-
41
-
42
- ## connect to db
43
-
44
- DB_CONFIG = {
45
- adapter: 'sqlite3',
46
- database: './sport.db'
47
- }
48
-
49
- pp DB_CONFIG
50
- ActiveRecord::Base.establish_connection( DB_CONFIG )
51
-
52
- ## test drive
53
-
54
- puts "Welcome to sport.db, version #{SportDb::VERSION} (world.db, version #{WorldDb::VERSION})!"
55
-
56
- ## print tables stats (e.g. no of records)
57
- puts 'sport.db'
58
- puts '--------'
59
- SportDb.tables
60
-
61
- puts 'world.db'
62
- puts '--------'
63
- WorldDb.tables
64
-
65
- puts 'Ready.'
66
-
67
-
68
- ## add some predefined shortcuts
69
-
70
- ##### some countries
71
-
72
- AT = Country.find_by_key( 'at' )
73
- DE = Country.find_by_key( 'de' )
74
- EN = Country.find_by_key( 'en' )
75
-
76
- US = Country.find_by_key( 'us' )
77
- CA = Country.find_by_key( 'ca' )
78
- MX = Country.find_by_key( 'mx' )
79
-
80
- #### some events
81
-
82
- EURO2008 = Event.find_by_key( 'euro.2008' )
83
- EURO2012 = Event.find_by_key( 'euro.2012' )
84
- EURO = EURO2012 # add alias
85
-
86
- BL = Event.find_by_key( 'de.2013/14' )
87
- PL = Event.find_by_key( 'en.2013/14' )
88
-
89
- ### some club teams
90
-
91
- BARCA = Team.find_by_key( 'barcelona' )
92
- MANU = Team.find_by_key( 'manunited' )
93
- MUN = MANUNITED = MANU # add alias
94
- BAYERN = Team.find_by_key( 'bayern' )
95
- AUSTRIA = Team.find_by_key( 'austria' )
96
-
97
- ### some national teams (three letter fifa codes)
98
-
99
- ESP = Team.find_by_key( 'esp' )
100
- GER = Team.find_by_key( 'ger' )
101
- AUT = Team.find_by_key( 'aut' )
102
-
103
- MEX = Team.find_by_key( 'mex' )
104
- ARG = Team.find_by_key( 'arg' )
105
-
106
- ## turn on activerecord logging to console
107
-
108
- ActiveRecord::Base.logger = Logger.new( STDOUT )
109
-
1
+
2
+ require 'logger'
3
+ require 'sportdb/models'
4
+
5
+
6
+ ## shortcuts for models
7
+
8
+ ##
9
+ ## todo/fix: just use include SportDb::Models - why? why not? is it possible/working?
10
+
11
+ Badge = SportDb::Model::Badge
12
+ Event = SportDb::Model::Event
13
+ Game = SportDb::Model::Game
14
+ Goal = SportDb::Model::Goal
15
+ Group = SportDb::Model::Group
16
+ League = SportDb::Model::League
17
+ Person = SportDb::Model::Person
18
+ Roster = SportDb::Model::Roster
19
+ Round = SportDb::Model::Round
20
+ Season = SportDb::Model::Season
21
+ Team = SportDb::Model::Team
22
+
23
+
24
+ ### todo: check for racing.db extension if present??
25
+ ## only add if present
26
+ Race = SportDb::Model::Race
27
+ Record = SportDb::Model::Record
28
+ Run = SportDb::Model::Run
29
+ Track = SportDb::Model::Track
30
+
31
+
32
+
33
+ Tag = WorldDb::Model::Tag
34
+ Tagging = WorldDb::Model::Tagging
35
+ Continent = WorldDb::Model::Continent
36
+ Country = WorldDb::Model::Country
37
+ Region = WorldDb::Model::Region
38
+ City = WorldDb::Model::City
39
+ Prop = WorldDb::Model::Prop
40
+
41
+
42
+ ## connect to db
43
+
44
+ DB_CONFIG = {
45
+ adapter: 'sqlite3',
46
+ database: './sport.db'
47
+ }
48
+
49
+ pp DB_CONFIG
50
+ ActiveRecord::Base.establish_connection( DB_CONFIG )
51
+
52
+ ## test drive
53
+
54
+ puts "Welcome to sport.db, version #{SportDb::VERSION} (world.db, version #{WorldDb::VERSION})!"
55
+
56
+ ## print tables stats (e.g. no of records)
57
+ puts 'sport.db'
58
+ puts '--------'
59
+ SportDb.tables
60
+
61
+ puts 'world.db'
62
+ puts '--------'
63
+ WorldDb.tables
64
+
65
+ puts 'Ready.'
66
+
67
+
68
+ ## add some predefined shortcuts
69
+
70
+ ##### some countries
71
+
72
+ AT = Country.find_by_key( 'at' )
73
+ DE = Country.find_by_key( 'de' )
74
+ EN = Country.find_by_key( 'en' )
75
+
76
+ US = Country.find_by_key( 'us' )
77
+ CA = Country.find_by_key( 'ca' )
78
+ MX = Country.find_by_key( 'mx' )
79
+
80
+ #### some events
81
+
82
+ EURO2008 = Event.find_by_key( 'euro.2008' )
83
+ EURO2012 = Event.find_by_key( 'euro.2012' )
84
+ EURO = EURO2012 # add alias
85
+
86
+ BL = Event.find_by_key( 'de.2013/14' )
87
+ PL = Event.find_by_key( 'en.2013/14' )
88
+
89
+ ### some club teams
90
+
91
+ BARCA = Team.find_by_key( 'barcelona' )
92
+ MANU = Team.find_by_key( 'manunited' )
93
+ MUN = MANUNITED = MANU # add alias
94
+ BAYERN = Team.find_by_key( 'bayern' )
95
+ AUSTRIA = Team.find_by_key( 'austria' )
96
+
97
+ ### some national teams (three letter fifa codes)
98
+
99
+ ESP = Team.find_by_key( 'esp' )
100
+ GER = Team.find_by_key( 'ger' )
101
+ AUT = Team.find_by_key( 'aut' )
102
+
103
+ MEX = Team.find_by_key( 'mex' )
104
+ ARG = Team.find_by_key( 'arg' )
105
+
106
+ ## turn on activerecord logging to console
107
+
108
+ ActiveRecord::Base.logger = Logger.new( STDOUT )
109
+
metadata CHANGED
@@ -1,101 +1,87 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.1
4
+ version: 2.3.2
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-26 00:00:00.000000000 Z
11
+ date: 2020-10-17 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: sportdb-models
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 1.18.2
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ">="
25
- - !ruby/object:Gem::Version
26
- version: 1.18.2
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: sportdb-readers
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - ">="
32
18
  - !ruby/object:Gem::Version
33
- version: 0.3.6
19
+ version: 1.1.2
34
20
  type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
24
  - - ">="
39
25
  - !ruby/object:Gem::Version
40
- version: 0.3.6
26
+ version: 1.1.2
41
27
  - !ruby/object:Gem::Dependency
42
- name: footballdb-leagues
28
+ name: fetcher
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
31
  - - ">="
46
32
  - !ruby/object:Gem::Version
47
- version: 2019.11.22
33
+ version: 0.4.5
48
34
  type: :runtime
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
38
  - - ">="
53
39
  - !ruby/object:Gem::Version
54
- version: 2019.11.22
40
+ version: 0.4.5
55
41
  - !ruby/object:Gem::Dependency
56
- name: footballdb-clubs
42
+ name: datafile
57
43
  requirement: !ruby/object:Gem::Requirement
58
44
  requirements:
59
45
  - - ">="
60
46
  - !ruby/object:Gem::Version
61
- version: 2019.11.22
47
+ version: 0.3.1
62
48
  type: :runtime
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
52
  - - ">="
67
53
  - !ruby/object:Gem::Version
68
- version: 2019.11.22
54
+ version: 0.3.1
69
55
  - !ruby/object:Gem::Dependency
70
- name: fetcher
56
+ name: webservice
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
59
  - - ">="
74
60
  - !ruby/object:Gem::Version
75
- version: 0.4.5
61
+ version: 0.7.0
76
62
  type: :runtime
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
66
  - - ">="
81
67
  - !ruby/object:Gem::Version
82
- version: 0.4.5
68
+ version: 0.7.0
83
69
  - !ruby/object:Gem::Dependency
84
- name: datafile
70
+ name: gli
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
73
  - - ">="
88
74
  - !ruby/object:Gem::Version
89
- version: 0.3.1
75
+ version: 2.19.0
90
76
  type: :runtime
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
80
  - - ">="
95
81
  - !ruby/object:Gem::Version
96
- version: 0.3.1
82
+ version: 2.19.0
97
83
  - !ruby/object:Gem::Dependency
98
- name: sportdb-service
84
+ name: sqlite3
99
85
  requirement: !ruby/object:Gem::Requirement
100
86
  requirements:
101
87
  - - ">="
@@ -109,21 +95,7 @@ dependencies:
109
95
  - !ruby/object:Gem::Version
110
96
  version: '0'
111
97
  - !ruby/object:Gem::Dependency
112
- name: gli
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: 2.12.2
118
- type: :runtime
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - ">="
123
- - !ruby/object:Gem::Version
124
- version: 2.12.2
125
- - !ruby/object:Gem::Dependency
126
- name: sqlite3
98
+ name: football-to-sqlite
127
99
  requirement: !ruby/object:Gem::Requirement
128
100
  requirements:
129
101
  - - ">="
@@ -140,30 +112,36 @@ dependencies:
140
112
  name: rdoc
141
113
  requirement: !ruby/object:Gem::Requirement
142
114
  requirements:
143
- - - "~>"
115
+ - - ">="
144
116
  - !ruby/object:Gem::Version
145
117
  version: '4.0'
118
+ - - "<"
119
+ - !ruby/object:Gem::Version
120
+ version: '7'
146
121
  type: :development
147
122
  prerelease: false
148
123
  version_requirements: !ruby/object:Gem::Requirement
149
124
  requirements:
150
- - - "~>"
125
+ - - ">="
151
126
  - !ruby/object:Gem::Version
152
127
  version: '4.0'
128
+ - - "<"
129
+ - !ruby/object:Gem::Version
130
+ version: '7'
153
131
  - !ruby/object:Gem::Dependency
154
132
  name: hoe
155
133
  requirement: !ruby/object:Gem::Requirement
156
134
  requirements:
157
135
  - - "~>"
158
136
  - !ruby/object:Gem::Version
159
- version: '3.16'
137
+ version: '3.22'
160
138
  type: :development
161
139
  prerelease: false
162
140
  version_requirements: !ruby/object:Gem::Requirement
163
141
  requirements:
164
142
  - - "~>"
165
143
  - !ruby/object:Gem::Version
166
- version: '3.16'
144
+ version: '3.22'
167
145
  description: sportdb - sport.db Command Line Tool
168
146
  email: opensport@googlegroups.com
169
147
  executables: