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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 361055fb9718783a779306c140fbc121d50bf73a
4
- data.tar.gz: 5f1a213576e4feb35f10661ef8f749c2b40240d6
3
+ metadata.gz: 4043964e61723b11820a2ee716fef6a2f16d37c5
4
+ data.tar.gz: 1d33700d72c60a7957af3b92ca5f8ac6d9715959
5
5
  SHA512:
6
- metadata.gz: d8cd365310ffe83f1c72c10bee222240f51b360dfcab600359cf200f386fdcdf1fa3525c8a6506c2535ad5dd7b0268c98556bebd29b0e5674656ca2987140e5a
7
- data.tar.gz: dd00d26a52350767c988ed9b3a6eb95fddd1136a778e756a2aaa122c5148b3201579d2ef380b8583fae3174fd4452f165c4495757e4d420cac09dc84b4775441
6
+ metadata.gz: b7aa02a5bd39c62067be9212879e8deb3ad617929c086a7ac4b8724389a27e02f885015b23272ef95280fb265875ecafb839569c51ec61c2c3e14e9a7ce1bb09
7
+ data.tar.gz: 172eda351be265567fa379c01a5e7477a2c5573a768188d125663d1c743e24969719efc5edb9dccd05a7bc376acd37a6b0e9756a9d9753bb792ab761d2687466
@@ -7,3 +7,4 @@ lib/sportdb.rb
7
7
  lib/sportdb/cli/main.rb
8
8
  lib/sportdb/cli/opts.rb
9
9
  lib/sportdb/cli/version.rb
10
+ lib/sportdb/console.rb
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.0'],
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
 
@@ -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
- ## Runner.new.run(ARGV) - old code
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
-
@@ -1,24 +1,50 @@
1
1
  # encoding: utf-8
2
2
 
3
- ##############
4
- # nb: for local testing use:
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
- program_desc 'sport.db command line tool'
9
+ class Tool
10
+ def initialize
11
+ LogUtils::Logger.root.level = :info # set logging level to info
12
+ end
16
13
 
17
- version SportDbCli::VERSION
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
@@ -7,7 +7,7 @@ module SportDbCli # todo/check - rename to SportDbTool or SportDbCommands or
7
7
 
8
8
  MAJOR = 1 ## todo: namespace inside version or something - why? why not??
9
9
  MINOR = 10
10
- PATCH = 1
10
+ PATCH = 2
11
11
  VERSION = [MAJOR,MINOR,PATCH].join('.')
12
12
 
13
13
  def self.version
@@ -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.1
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-05 00:00:00.000000000 Z
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.0
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.0
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