sportdb 2.2.1 → 2.3.0
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/Rakefile +4 -4
- data/lib/sportdb.rb +63 -8
- data/lib/sportdb/cli/main.rb +28 -27
- data/lib/sportdb/cli/version.rb +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8451fab0cbb5df17ec44d2b7a2f4d615a94386d8
|
|
4
|
+
data.tar.gz: 0d2d22268defa874b937e8e647c1a9716484a71a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b00d40e1a4f71ffe3ba277e12f560987e62302210356fd2ede3918a58c2062fb60c36369d3eb94231fbd5a6348424a22459b39f74502a9e0dc05e24ef50fde70
|
|
7
|
+
data.tar.gz: 1c9fc7b21bca4f53de2fc8267b7d87cd5a9a6804099e8080ad161047b6380688199cf847308863fac4e20d9b0d20205b616d23513d6c3248232902bff360c425
|
data/Rakefile
CHANGED
|
@@ -22,13 +22,13 @@ Hoe.spec 'sportdb' do
|
|
|
22
22
|
self.extra_deps = [
|
|
23
23
|
['sportdb-readers', '>= 1.0.2'],
|
|
24
24
|
|
|
25
|
-
['fetcher',
|
|
26
|
-
['datafile',
|
|
25
|
+
['fetcher', '>= 0.4.5'], ## check if included already in datafil ??
|
|
26
|
+
['datafile', '>= 0.3.1'],
|
|
27
|
+
['webservice', '>= 0.7.0'],
|
|
27
28
|
|
|
28
|
-
### sportdb addons
|
|
29
|
+
### incl. sportdb addons - why? why not?
|
|
29
30
|
## ['sportdb-keys'],
|
|
30
31
|
## ['sportdb-update'],
|
|
31
|
-
['sportdb-service', '>= 0.4.1'],
|
|
32
32
|
|
|
33
33
|
## 3rd party
|
|
34
34
|
['gli', '>= 2.19.0'],
|
data/lib/sportdb.rb
CHANGED
|
@@ -27,16 +27,71 @@ module SportDb
|
|
|
27
27
|
end # module SportDb
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
#####
|
|
31
|
-
# auto-load/require some addons
|
|
32
30
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
|
36
94
|
|
|
37
|
-
puts ' before sportdb/service'
|
|
38
|
-
require 'sportdb/service'
|
|
39
|
-
puts 'after auto-load (require) sportdb addons'
|
|
40
95
|
|
|
41
96
|
|
|
42
97
|
SportDb.main if __FILE__ == $0
|
data/lib/sportdb/cli/main.rb
CHANGED
|
@@ -186,40 +186,40 @@ command [:new,:n] do |c|
|
|
|
186
186
|
end # command setup
|
|
187
187
|
|
|
188
188
|
|
|
189
|
-
|
|
190
189
|
desc 'Start web service (HTTP JSON API)'
|
|
191
|
-
|
|
190
|
+
arg_name 'NAME' # optional setup profile name
|
|
191
|
+
command [:serve,:server,:s] do |c|
|
|
192
192
|
|
|
193
193
|
c.action do |g,o,args|
|
|
194
194
|
|
|
195
|
-
|
|
195
|
+
## todo: document optional script arg (defaults to service)
|
|
196
|
+
script = args[0] || 'service'
|
|
197
|
+
|
|
198
|
+
## todo/fix: add support for (default) Service (with no extension)
|
|
196
199
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
##
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
# ActiveRecord::Base.connection.close
|
|
205
|
-
# end
|
|
206
|
-
#
|
|
207
|
-
|
|
208
|
-
## note: ConnectionManagement removed from ActiveRecord 4+
|
|
209
|
-
## see github.com/rails/rails/issues/26947
|
|
210
|
-
## puts 'before add middleware ConnectionManagement'
|
|
211
|
-
## SportDb::Service::Server.use ActiveRecord::ConnectionAdapters::ConnectionManagement
|
|
212
|
-
## puts 'after add middleware ConnectionManagement'
|
|
213
|
-
## todo: check if we can check on/dump middleware stack
|
|
214
|
-
|
|
215
|
-
## rack middleware might not work with multi-threaded thin web server; close it ourselfs
|
|
216
|
-
SportDb::Service::Server.after do
|
|
217
|
-
puts " #{Thread.current.object_id} -- make sure db connections gets closed after request"
|
|
218
|
-
# todo: check if connection is open - how?
|
|
219
|
-
ActiveRecord::Base.connection.close
|
|
200
|
+
script_path = "#{script}.rb" ## auto-add .rb extension
|
|
201
|
+
|
|
202
|
+
unless File.exist?( script_path ) ## if file doesn't exist try to fetch service script
|
|
203
|
+
script_path = "./#{script}.rb" ## use / save script in local (current) working dir/folder
|
|
204
|
+
worker = Fetcher::Worker.new
|
|
205
|
+
## note: lets use http:// instead of https:// for now - lets us use person proxy (NOT working w/ https for now)
|
|
206
|
+
worker.copy( "http://github.com/sportdb/sport.db.service/raw/master/#{script}.rb", script_path )
|
|
220
207
|
end
|
|
221
208
|
|
|
222
|
-
|
|
209
|
+
|
|
210
|
+
code = File.open( script_path, 'r:utf-8' ) { |f| f.read }
|
|
211
|
+
|
|
212
|
+
connect_to_db( opts )
|
|
213
|
+
|
|
214
|
+
SportDb.tables ## print table stats
|
|
215
|
+
|
|
216
|
+
SportDbService.class_eval( code ) ## note: MUST use class_eval (do NOT use instance_eval) !!!
|
|
217
|
+
|
|
218
|
+
puts "dump routes:"
|
|
219
|
+
pp SportDbService.routes
|
|
220
|
+
|
|
221
|
+
puts "starting server..."
|
|
222
|
+
SportDbService.run!
|
|
223
223
|
|
|
224
224
|
puts 'Done.'
|
|
225
225
|
end
|
|
@@ -227,6 +227,7 @@ end # command serve
|
|
|
227
227
|
|
|
228
228
|
|
|
229
229
|
|
|
230
|
+
|
|
230
231
|
desc 'Show logs'
|
|
231
232
|
command :logs do |c|
|
|
232
233
|
c.action do |g,o,args|
|
data/lib/sportdb/cli/version.rb
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
module SportDbCli # todo/check - rename to SportDbTool or SportDbCommands or SportDbShell ??
|
|
7
7
|
|
|
8
8
|
MAJOR = 2 ## todo: namespace inside version or something - why? why not??
|
|
9
|
-
MINOR =
|
|
10
|
-
PATCH =
|
|
9
|
+
MINOR = 3
|
|
10
|
+
PATCH = 0
|
|
11
11
|
VERSION = [MAJOR,MINOR,PATCH].join('.')
|
|
12
12
|
|
|
13
13
|
def self.version
|
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.
|
|
4
|
+
version: 2.3.0
|
|
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-05-
|
|
11
|
+
date: 2020-05-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: sportdb-readers
|
|
@@ -53,19 +53,19 @@ dependencies:
|
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: 0.3.1
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
56
|
+
name: webservice
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
59
|
- - ">="
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: 0.
|
|
61
|
+
version: 0.7.0
|
|
62
62
|
type: :runtime
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
66
|
- - ">="
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: 0.
|
|
68
|
+
version: 0.7.0
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: gli
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|