sportdb 1.10.1 → 1.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Manifest.txt +1 -0
- data/Rakefile +1 -2
- data/lib/sportdb.rb +2 -6
- data/lib/sportdb/cli/main.rb +42 -28
- data/lib/sportdb/cli/version.rb +1 -1
- data/lib/sportdb/console.rb +109 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4043964e61723b11820a2ee716fef6a2f16d37c5
|
4
|
+
data.tar.gz: 1d33700d72c60a7957af3b92ca5f8ac6d9715959
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7aa02a5bd39c62067be9212879e8deb3ad617929c086a7ac4b8724389a27e02f885015b23272ef95280fb265875ecafb839569c51ec61c2c3e14e9a7ce1bb09
|
7
|
+
data.tar.gz: 172eda351be265567fa379c01a5e7477a2c5573a768188d125663d1c743e24969719efc5edb9dccd05a7bc376acd37a6b0e9756a9d9753bb792ab761d2687466
|
data/Manifest.txt
CHANGED
data/Rakefile
CHANGED
@@ -20,14 +20,13 @@ Hoe.spec 'sportdb' do
|
|
20
20
|
self.history_file = 'HISTORY.md'
|
21
21
|
|
22
22
|
self.extra_deps = [
|
23
|
-
['sportdb-models', '>= 1.10.
|
23
|
+
['sportdb-models', '>= 1.10.1'],
|
24
24
|
|
25
25
|
['fetcher', '>= 0.4.4'], ## check if included already in datafil ??
|
26
26
|
['datafile', '>= 0.1.1'],
|
27
27
|
|
28
28
|
### sportdb addons
|
29
29
|
## ['sportdb-keys'],
|
30
|
-
## ['sportdb-console'],
|
31
30
|
['sportdb-update'],
|
32
31
|
['sportdb-service'],
|
33
32
|
|
data/lib/sportdb.rb
CHANGED
@@ -14,17 +14,14 @@ require 'gli'
|
|
14
14
|
# our own code
|
15
15
|
|
16
16
|
require 'sportdb/cli/version' # let version always go first
|
17
|
-
|
18
|
-
# additional for cli only
|
19
17
|
require 'sportdb/cli/opts'
|
20
|
-
|
18
|
+
require 'sportdb/cli/main'
|
21
19
|
|
22
20
|
|
23
21
|
module SportDb
|
24
22
|
|
25
23
|
def self.main
|
26
|
-
|
27
|
-
require 'sportdb/cli/main'
|
24
|
+
Tool.new.run(ARGV)
|
28
25
|
end
|
29
26
|
|
30
27
|
end # module SportDb
|
@@ -42,4 +39,3 @@ require 'sportdb/service'
|
|
42
39
|
|
43
40
|
|
44
41
|
SportDb.main if __FILE__ == $0
|
45
|
-
|
data/lib/sportdb/cli/main.rb
CHANGED
@@ -1,24 +1,50 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
#
|
6
|
-
# ruby -I ../../github/sport.db.ruby/lib
|
7
|
-
# ../../github/sport.db.ruby/lib/sportdb.rb
|
8
|
-
# setup --delete --sport
|
9
|
-
# --include ../../github/football.db
|
3
|
+
### NOTE: wrap gli config into a class
|
4
|
+
## see github.com/davetron5000/gli/issues/153
|
10
5
|
|
11
|
-
|
12
|
-
include GLI::App
|
13
6
|
|
7
|
+
module SportDb
|
14
8
|
|
15
|
-
|
9
|
+
class Tool
|
10
|
+
def initialize
|
11
|
+
LogUtils::Logger.root.level = :info # set logging level to info
|
12
|
+
end
|
16
13
|
|
17
|
-
|
14
|
+
def run( args )
|
15
|
+
puts SportDbCli.banner
|
16
|
+
Toolii.run( args )
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
class Toolii
|
22
|
+
extend GLI::App
|
23
|
+
|
24
|
+
def self.logger=(value) @@logger=value; end
|
25
|
+
def self.logger() @@logger; end
|
26
|
+
|
27
|
+
## todo: find a better name e.g. change to settings? config? safe_opts? why? why not?
|
28
|
+
def self.opts=(value) @@opts = value; end
|
29
|
+
def self.opts() @@opts; end
|
30
|
+
|
31
|
+
def self.connect_to_db( options )
|
32
|
+
puts "working directory: #{Dir.pwd}"
|
33
|
+
|
34
|
+
SportDb.connect( adapter: 'sqlite3',
|
35
|
+
database: "#{options.db_path}/#{options.db_name}" )
|
36
|
+
|
37
|
+
LogDb.setup # start logging to db (that is, save logs in logs table in db)
|
38
|
+
end
|
18
39
|
|
19
40
|
|
20
|
-
LogUtils::Logger.root.level = :info # set logging level to info
|
21
41
|
logger = LogUtils::Logger.root
|
42
|
+
opts = WorldDb::Opts.new
|
43
|
+
|
44
|
+
|
45
|
+
program_desc 'sport.db command line tool'
|
46
|
+
|
47
|
+
version SportDbCli::VERSION
|
22
48
|
|
23
49
|
|
24
50
|
=begin
|
@@ -37,9 +63,6 @@ Further information:
|
|
37
63
|
=end
|
38
64
|
|
39
65
|
|
40
|
-
## todo: find a better name e.g. change to settings? config? safe_opts? why? why not?
|
41
|
-
opts = SportDb::Opts.new
|
42
|
-
|
43
66
|
### global option (required)
|
44
67
|
## todo: add check that path is valid?? possible?
|
45
68
|
|
@@ -62,18 +85,6 @@ switch [:q, :quiet], negatable: false
|
|
62
85
|
|
63
86
|
|
64
87
|
|
65
|
-
def connect_to_db( options )
|
66
|
-
puts SportDbCli.banner
|
67
|
-
|
68
|
-
puts "working directory: #{Dir.pwd}"
|
69
|
-
|
70
|
-
SportDb.connect( adapter: 'sqlite3',
|
71
|
-
database: "#{options.db_path}/#{options.db_name}" )
|
72
|
-
|
73
|
-
LogDb.setup # start logging to db (that is, save logs in logs table in db)
|
74
|
-
end
|
75
|
-
|
76
|
-
|
77
88
|
desc 'Create DB schema'
|
78
89
|
command [:create] do |c|
|
79
90
|
c.action do |g,o,args|
|
@@ -413,4 +424,7 @@ on_error do |e|
|
|
413
424
|
end
|
414
425
|
|
415
426
|
|
416
|
-
exit run(ARGV)
|
427
|
+
### exit run(ARGV) ## note: use Toolii.run( ARGV ) outside of class
|
428
|
+
|
429
|
+
end # class Toolii
|
430
|
+
end # module SportDb
|
data/lib/sportdb/cli/version.rb
CHANGED
@@ -0,0 +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
|
+
|
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: 1.10.
|
4
|
+
version: 1.10.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: 2014-12-
|
11
|
+
date: 2014-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sportdb-models
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.10.
|
19
|
+
version: 1.10.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.10.
|
26
|
+
version: 1.10.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: fetcher
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -155,6 +155,7 @@ files:
|
|
155
155
|
- lib/sportdb/cli/main.rb
|
156
156
|
- lib/sportdb/cli/opts.rb
|
157
157
|
- lib/sportdb/cli/version.rb
|
158
|
+
- lib/sportdb/console.rb
|
158
159
|
homepage: https://github.com/sportdb/sport.db.ruby
|
159
160
|
licenses:
|
160
161
|
- Public Domain
|