sportdb 2.3.1 → 2.3.2
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/CHANGELOG.md +4 -4
- data/README.md +123 -123
- data/Rakefile +58 -55
- data/bin/sportdb +5 -5
- data/lib/sportdb.rb +97 -97
- data/lib/sportdb/cli/opts.rb +43 -43
- data/lib/sportdb/cli/version.rb +25 -25
- data/lib/sportdb/console.rb +109 -109
- metadata +26 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a2eaeb80608f85c3e56cd97938b203aabd55a53
|
4
|
+
data.tar.gz: 875947bbad6d080c900a4e04eb0007a52e75dc3e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4952c8d6e193084214b07917bc58b9fd655f68e888cb545a1de14cdb40318b6de9141cbd35643609209a8d9a5a07155df10d7d6b745319c259c2fa335116733
|
7
|
+
data.tar.gz: f9f123cdb8bc3313d610a0b756d2d92e5ef3f1ac7985e8e61f283be1e8b1ea57ec9f53e1ddcbc61ab87b216a8e640535b0f5b525e224bed353f6c710a26f70e2
|
data/CHANGELOG.md
CHANGED
@@ -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
|
-
[](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
|
-

|
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
|
+
[](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
|
+

|
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,55 +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 =
|
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
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
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
|
data/bin/sportdb
CHANGED
@@ -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
|
data/lib/sportdb.rb
CHANGED
@@ -1,97 +1,97 @@
|
|
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
|
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
|
data/lib/sportdb/cli/opts.rb
CHANGED
@@ -1,43 +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
|
-
|
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
|
+
# 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
|
data/lib/sportdb/cli/version.rb
CHANGED
@@ -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 = 3
|
10
|
-
PATCH =
|
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
|
data/lib/sportdb/console.rb
CHANGED
@@ -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,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sportdb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
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: 2020-
|
11
|
+
date: 2020-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sportdb-readers
|
@@ -94,34 +94,54 @@ dependencies:
|
|
94
94
|
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: football-to-sqlite
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: rdoc
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
100
114
|
requirements:
|
101
|
-
- - "
|
115
|
+
- - ">="
|
102
116
|
- !ruby/object:Gem::Version
|
103
117
|
version: '4.0'
|
118
|
+
- - "<"
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '7'
|
104
121
|
type: :development
|
105
122
|
prerelease: false
|
106
123
|
version_requirements: !ruby/object:Gem::Requirement
|
107
124
|
requirements:
|
108
|
-
- - "
|
125
|
+
- - ">="
|
109
126
|
- !ruby/object:Gem::Version
|
110
127
|
version: '4.0'
|
128
|
+
- - "<"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '7'
|
111
131
|
- !ruby/object:Gem::Dependency
|
112
132
|
name: hoe
|
113
133
|
requirement: !ruby/object:Gem::Requirement
|
114
134
|
requirements:
|
115
135
|
- - "~>"
|
116
136
|
- !ruby/object:Gem::Version
|
117
|
-
version: '3.
|
137
|
+
version: '3.22'
|
118
138
|
type: :development
|
119
139
|
prerelease: false
|
120
140
|
version_requirements: !ruby/object:Gem::Requirement
|
121
141
|
requirements:
|
122
142
|
- - "~>"
|
123
143
|
- !ruby/object:Gem::Version
|
124
|
-
version: '3.
|
144
|
+
version: '3.22'
|
125
145
|
description: sportdb - sport.db Command Line Tool
|
126
146
|
email: opensport@googlegroups.com
|
127
147
|
executables:
|