sportdb 1.2.0 → 1.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.
data/README.md CHANGED
@@ -1,8 +1,12 @@
1
- # sportdb
1
+ # sportdb - sport.db Command Line Tool in Ruby
2
2
 
3
- sport.db Command Line Tool in Ruby
3
+ [![Build Status](https://secure.travis-ci.org/geraldb/sport.db.ruby.png?branch=master)](http://travis-ci.org/geraldb/sport.db.ruby)
4
4
 
5
- * [geraldb.github.com/sport.db](http://geraldb.github.com/sport.db)
5
+ * home :: [github.com/geraldb/sport.db.ruby](https://github.com/geraldb/sport.db.ruby)
6
+ * bugs :: [github.com/geraldb/sport.db.ruby/issues](https://github.com/geraldb/sport.db.ruby/issues)
7
+ * gem :: [rubygems.org/gems/sportdb](https://rubygems.org/gems/sportdb)
8
+ * rdoc :: [rubydoc.info/gems/sportdb](http://rubydoc.info/gems/sportdb)
9
+ * forum :: [groups.google.com/group/opensport](https://groups.google.com/group/opensport)
6
10
 
7
11
 
8
12
  ## Usage
data/Rakefile CHANGED
@@ -23,7 +23,7 @@ Hoe.spec 'sportdb' do
23
23
  # self.history_file = 'History.md'
24
24
 
25
25
  self.extra_deps = [
26
- ['worlddb', '~> 1.2.0'], # NB: worlddb already includes
26
+ ['worlddb', '~> 1.3.0'], # NB: worlddb already includes
27
27
  # - commander
28
28
  # - logutils
29
29
  # - textutils
@@ -1,5 +1,14 @@
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
10
+
11
+
3
12
  require 'commander/import'
4
13
 
5
14
  # our own code / additional for cli only
@@ -7,6 +16,7 @@ require 'commander/import'
7
16
  require 'logutils/db'
8
17
  require 'sportdb/cli/opts'
9
18
 
19
+ LogUtils::Logger.root.level = :info # set logging level to info
10
20
 
11
21
  program :name, 'sportdb'
12
22
  program :version, SportDB::VERSION
@@ -46,6 +56,10 @@ global_option '-i', '--include PATH', String, "Data path (default is #{myopts.da
46
56
  global_option '-d', '--dbpath PATH', String, "Database path (default is #{myopts.db_path})"
47
57
  global_option '-n', '--dbname NAME', String, "Database name (datault is #{myopts.db_name})"
48
58
 
59
+ global_option '-q', '--quiet', "Only show warnings, errors and fatal messages"
60
+ ### todo/fix: just want --debug/--verbose flag (no single letter option wanted) - fix
61
+ global_option '-w', '--verbose', "Show debug messages"
62
+
49
63
 
50
64
  def connect_to_db( options )
51
65
  puts SportDB.banner
@@ -70,6 +84,10 @@ command :create do |c|
70
84
  c.syntax = 'sportdb create [options]'
71
85
  c.description = 'Create DB schema'
72
86
  c.action do |args, options|
87
+
88
+ LogUtils::Logger.root.level = :warn if options.quiet.present?
89
+ LogUtils::Logger.root.level = :debug if options.verbose.present?
90
+
73
91
  myopts.merge_commander_options!( options.__hash__ )
74
92
  connect_to_db( myopts )
75
93
 
@@ -92,6 +110,10 @@ command :setup do |c|
92
110
  c.option '--delete', 'Delete all records'
93
111
 
94
112
  c.action do |args, options|
113
+
114
+ LogUtils::Logger.root.level = :warn if options.quiet.present?
115
+ LogUtils::Logger.root.level = :debug if options.verbose.present?
116
+
95
117
  myopts.merge_commander_options!( options.__hash__ )
96
118
  connect_to_db( myopts )
97
119
 
@@ -134,6 +156,10 @@ command :load do |c|
134
156
  c.option '--delete', 'Delete all records'
135
157
 
136
158
  c.action do |args, options|
159
+
160
+ LogUtils::Logger.root.level = :warn if options.quiet.present?
161
+ LogUtils::Logger.root.level = :debug if options.verbose.present?
162
+
137
163
  myopts.merge_commander_options!( options.__hash__ )
138
164
  connect_to_db( myopts )
139
165
 
@@ -160,14 +186,56 @@ command :load do |c|
160
186
  end # command load
161
187
 
162
188
 
189
+ command :logs do |c|
190
+ c.syntax = 'sportdb logs [options]'
191
+ c.description = 'Show logs'
192
+ c.action do |args, options|
193
+
194
+ LogUtils::Logger.root.level = :warn if options.quiet.present?
195
+ LogUtils::Logger.root.level = :debug if options.verbose.present?
196
+
197
+ myopts.merge_commander_options!( options.__hash__ )
198
+ connect_to_db( myopts )
199
+
200
+ LogDB::Models::Log.all.each do |log|
201
+ puts "[#{log.level}] -- #{log.msg}"
202
+ end
203
+
204
+ puts 'Done.'
205
+ end
206
+ end
207
+
208
+
163
209
  command :stats do |c|
164
210
  c.syntax = 'sportdb stats [options]'
165
211
  c.description = 'Show stats'
166
212
  c.action do |args, options|
213
+
214
+ LogUtils::Logger.root.level = :warn if options.quiet.present?
215
+ LogUtils::Logger.root.level = :debug if options.verbose.present?
216
+
217
+ myopts.merge_commander_options!( options.__hash__ )
218
+ connect_to_db( myopts )
219
+
220
+ SportDB.tables
221
+
222
+ puts 'Done.'
223
+ end
224
+ end
225
+
226
+
227
+ command :props do |c|
228
+ c.syntax = 'sportdb props [options]'
229
+ c.description = 'Show props'
230
+ c.action do |args, options|
231
+
232
+ LogUtils::Logger.root.level = :warn if options.quiet.present?
233
+ LogUtils::Logger.root.level = :debug if options.verbose.present?
234
+
167
235
  myopts.merge_commander_options!( options.__hash__ )
168
236
  connect_to_db( myopts )
169
237
 
170
- SportDB.stats
238
+ SportDB.props
171
239
 
172
240
  puts 'Done.'
173
241
  end
@@ -178,6 +246,10 @@ command :test do |c|
178
246
  c.syntax = 'sportdb test [options]'
179
247
  c.description = 'Debug/test command suite'
180
248
  c.action do |args, options|
249
+
250
+ LogUtils::Logger.root.level = :warn if options.quiet.present?
251
+ LogUtils::Logger.root.level = :debug if options.verbose.present?
252
+
181
253
  puts "hello from test command"
182
254
  puts "args (#{args.class.name}):"
183
255
  pp args
@@ -185,6 +257,11 @@ command :test do |c|
185
257
  pp options
186
258
  puts "options.__hash__:"
187
259
  pp options.__hash__
260
+
261
+ LogUtils::Logger.root.debug 'test debug msg'
262
+ LogUtils::Logger.root.info 'test info msg'
263
+ LogUtils::Logger.root.warn 'test warn msg'
264
+
188
265
  puts 'Done.'
189
266
  end
190
267
  end
data/lib/sportdb/lang.rb CHANGED
@@ -4,9 +4,7 @@ module SportDB
4
4
 
5
5
  class Lang
6
6
 
7
- def logger
8
- @logger ||= LogUtils[ self ]
9
- end
7
+ include LogUtils::Logging
10
8
 
11
9
  def initialize
12
10
 
@@ -29,9 +27,9 @@ class Lang
29
27
  @words_de = fixtures_hash_to_words_ary( @fixtures_de )
30
28
  @words_es = fixtures_hash_to_words_ary( @fixtures_es )
31
29
 
32
- puts "en - #{@words_en.size} words: #{@words_en}"
33
- puts "de - #{@words_de.size} words: #{@words_de}"
34
- puts "es - #{@words_es.size} words: #{@words_es}"
30
+ logger.debug "en - #{@words_en.size} words: #{@words_en}"
31
+ logger.debug "de - #{@words_de.size} words: #{@words_de}"
32
+ logger.debug "es - #{@words_es.size} words: #{@words_es}"
35
33
 
36
34
  end
37
35
 
@@ -200,9 +198,7 @@ end # class Lang
200
198
 
201
199
  class LangChecker
202
200
 
203
- def logger
204
- @logger ||= LogUtils[ self ]
205
- end
201
+ include LogUtils::Logging
206
202
 
207
203
  def initialize
208
204
  end
@@ -234,13 +230,15 @@ class LangChecker
234
230
 
235
231
  # dump stats
236
232
 
237
- logger.info "****************************************"
233
+ logger.debug "lang checker:"
238
234
  lang_counts.each_with_index do |item,index|
239
235
  ## e.g. 1. en: 20 words
240
236
  ## 2. de: 2 words
241
- logger.info "#{index+1}. #{item[0]}: #{item[1]}"
237
+ logger.debug " #{index+1}. #{item[0]}: #{item[1]}"
242
238
  end
243
239
 
240
+ logger.info "lang checker - using lang >>#{lang_counts[0][0]}<<"
241
+
244
242
  ## return lang code w/ highest count
245
243
  lang_counts[0][0]
246
244
  end
@@ -68,7 +68,10 @@ class Event < ActiveRecord::Base
68
68
 
69
69
  known_teams << [ team.key, titles ]
70
70
 
71
- puts " Team[#{index+1}] #{team.key} >#{titles.join('|')}<"
71
+ ### fix:
72
+ ## plain logger
73
+
74
+ LogUtils::Logger.root.debug " Team[#{index+1}] #{team.key} >#{titles.join('|')}<"
72
75
  end
73
76
 
74
77
  known_teams
@@ -4,9 +4,7 @@ module SportDB
4
4
 
5
5
  class Reader
6
6
 
7
- def logger
8
- @logger ||= LogUtils[ self ]
9
- end
7
+ include LogUtils::Logging
10
8
 
11
9
  ## make models available in sportdb module by default with namespace
12
10
  # e.g. lets you use Team instead of Models::Team
@@ -64,8 +62,8 @@ class Reader
64
62
 
65
63
  end
66
64
 
67
- puts "[debug] fixture setup:"
68
- pp ary
65
+ logger.debug "fixture setup:"
66
+ logger.debug ary.to_json
69
67
 
70
68
  ary
71
69
 
@@ -74,8 +72,8 @@ class Reader
74
72
 
75
73
  def load( ary, include_path ) # convenience helper for all-in-one reader
76
74
 
77
- puts "[debug] enter load(include_path=>>#{include_path}<<):"
78
- pp ary
75
+ logger.debug "enter load(include_path=>>#{include_path}<<):"
76
+ logger.debug ary.to_json
79
77
 
80
78
  ary.each do |rec|
81
79
  if rec.kind_of?( String )
@@ -141,8 +139,7 @@ class Reader
141
139
 
142
140
  load_leagues_worker( reader )
143
141
 
144
- ### todo/fix: add prop
145
- ### Prop.create!( key: "db.#{fixture_name_to_prop_key(name)}.version", value: "file.txt.#{File.mtime(path).strftime('%Y.%m.%d')}" )
142
+ Prop.create_from_fixture!( name, path )
146
143
 
147
144
  end # load_leagues
148
145
 
@@ -160,7 +157,7 @@ class Reader
160
157
 
161
158
  if key == 'seasons'
162
159
 
163
- puts "#{value.class.name}: >>#{value}<<"
160
+ logger.debug "#{value.class.name}: >>#{value}<<"
164
161
 
165
162
  ## nb: assume value is an array
166
163
  value.each do |item|
@@ -190,8 +187,7 @@ class Reader
190
187
 
191
188
  end # each key,value
192
189
 
193
- ### todo/fix: add prop
194
- ### Prop.create_from_sportdb_fixture!( name, path )
190
+ Prop.create_from_fixture!( name, path )
195
191
 
196
192
  end # load_seasons
197
193
 
@@ -279,7 +275,7 @@ class Reader
279
275
 
280
276
  event.update_attributes!( event_attribs )
281
277
 
282
- ### todo/fix: add prop
278
+ Prop.create_from_fixture!( name, path )
283
279
 
284
280
  end # load_event
285
281
 
@@ -307,8 +303,7 @@ class Reader
307
303
 
308
304
  load_fixtures_worker( event_key, reader )
309
305
 
310
- ## fix add prop
311
- ## Prop.create!( key: "db.#{fixture_name_to_prop_key(name)}.version", value: "file.txt.#{File.mtime(path).strftime('%Y.%m.%d')}" )
306
+ Prop.create_from_fixture!( name, path )
312
307
  end
313
308
 
314
309
 
@@ -321,8 +316,7 @@ class Reader
321
316
 
322
317
  load_teams_worker( reader )
323
318
 
324
- ## todo/fix: add prop
325
- ## Prop.create!( key: "db.#{fixture_name_to_prop_key(name)}.version", value: "sport.txt.#{SportDB::VERSION}" )
319
+ Prop.create_from_fixture!( name, path )
326
320
  end # load_teams
327
321
 
328
322
  private
@@ -357,7 +351,7 @@ private
357
351
  rec = League.new
358
352
  end
359
353
 
360
- puts attribs.to_json
354
+ logger.debug attribs.to_json
361
355
 
362
356
  rec.update_attributes!( attribs )
363
357
 
@@ -402,7 +396,7 @@ private
402
396
  rec = Team.new
403
397
  end
404
398
 
405
- puts attribs.to_json
399
+ logger.debug attribs.to_json
406
400
 
407
401
  rec.update_attributes!( attribs )
408
402
 
@@ -422,7 +416,7 @@ private
422
416
 
423
417
  @event = Event.find_by_key!( event_key )
424
418
 
425
- logger.info "Event #{@event.key} >#{@event.title}<"
419
+ logger.debug "Event #{@event.key} >#{@event.title}<"
426
420
 
427
421
  @known_teams = @event.known_teams_table
428
422
 
@@ -1,4 +1,4 @@
1
1
 
2
2
  module SportDB
3
- VERSION = '1.2.0'
3
+ VERSION = '1.3.0'
4
4
  end
metadata CHANGED
@@ -1,93 +1,68 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: sportdb
3
- version: !ruby/object:Gem::Version
4
- hash: 31
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.3.0
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 2
9
- - 0
10
- version: 1.2.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Gerald Bauer
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2013-02-22 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2013-02-24 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: worlddb
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &75587880 !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
18
+ requirements:
26
19
  - - ~>
27
- - !ruby/object:Gem::Version
28
- hash: 31
29
- segments:
30
- - 1
31
- - 2
32
- - 0
33
- version: 1.2.0
20
+ - !ruby/object:Gem::Version
21
+ version: 1.3.0
34
22
  type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: commander
38
23
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *75587880
25
+ - !ruby/object:Gem::Dependency
26
+ name: commander
27
+ requirement: &75587650 !ruby/object:Gem::Requirement
40
28
  none: false
41
- requirements:
29
+ requirements:
42
30
  - - ~>
43
- - !ruby/object:Gem::Version
44
- hash: 61
45
- segments:
46
- - 4
47
- - 1
48
- - 3
31
+ - !ruby/object:Gem::Version
49
32
  version: 4.1.3
50
33
  type: :runtime
51
- version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- name: rdoc
54
34
  prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *75587650
36
+ - !ruby/object:Gem::Dependency
37
+ name: rdoc
38
+ requirement: &75587420 !ruby/object:Gem::Requirement
56
39
  none: false
57
- requirements:
40
+ requirements:
58
41
  - - ~>
59
- - !ruby/object:Gem::Version
60
- hash: 19
61
- segments:
62
- - 3
63
- - 10
64
- version: "3.10"
42
+ - !ruby/object:Gem::Version
43
+ version: '3.10'
65
44
  type: :development
66
- version_requirements: *id003
67
- - !ruby/object:Gem::Dependency
68
- name: hoe
69
45
  prerelease: false
70
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *75587420
47
+ - !ruby/object:Gem::Dependency
48
+ name: hoe
49
+ requirement: &75587190 !ruby/object:Gem::Requirement
71
50
  none: false
72
- requirements:
51
+ requirements:
73
52
  - - ~>
74
- - !ruby/object:Gem::Version
75
- hash: 1
76
- segments:
77
- - 3
78
- - 3
79
- version: "3.3"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.3'
80
55
  type: :development
81
- version_requirements: *id004
56
+ prerelease: false
57
+ version_requirements: *75587190
82
58
  description: sportdb - sport.db command line tool
83
59
  email: opensport@googlegroups.com
84
- executables:
60
+ executables:
85
61
  - sportdb
86
62
  extensions: []
87
-
88
- extra_rdoc_files:
63
+ extra_rdoc_files:
89
64
  - Manifest.txt
90
- files:
65
+ files:
91
66
  - History.md
92
67
  - Manifest.txt
93
68
  - README.md
@@ -128,47 +103,40 @@ files:
128
103
  - lib/sportdb/version.rb
129
104
  - tasks/test.rb
130
105
  homepage: https://github.com/geraldb/sport.db.ruby
131
- licenses:
106
+ licenses:
132
107
  - Public Domain
133
- post_install_message: |
134
- ******************************************************************************
135
-
108
+ post_install_message: ! '******************************************************************************
109
+
110
+
136
111
  Questions? Comments? Send them along to the mailing list.
112
+
137
113
  https://groups.google.com/group/opensport
138
-
114
+
115
+
139
116
  ******************************************************************************
140
117
 
141
- rdoc_options:
118
+ '
119
+ rdoc_options:
142
120
  - --main
143
121
  - README.md
144
- require_paths:
122
+ require_paths:
145
123
  - lib
146
- required_ruby_version: !ruby/object:Gem::Requirement
124
+ required_ruby_version: !ruby/object:Gem::Requirement
147
125
  none: false
148
- requirements:
149
- - - ">="
150
- - !ruby/object:Gem::Version
151
- hash: 55
152
- segments:
153
- - 1
154
- - 9
155
- - 2
126
+ requirements:
127
+ - - ! '>='
128
+ - !ruby/object:Gem::Version
156
129
  version: 1.9.2
157
- required_rubygems_version: !ruby/object:Gem::Requirement
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
158
131
  none: false
159
- requirements:
160
- - - ">="
161
- - !ruby/object:Gem::Version
162
- hash: 3
163
- segments:
164
- - 0
165
- version: "0"
132
+ requirements:
133
+ - - ! '>='
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
166
136
  requirements: []
167
-
168
137
  rubyforge_project: sportdb
169
- rubygems_version: 1.8.24
138
+ rubygems_version: 1.8.17
170
139
  signing_key:
171
140
  specification_version: 3
172
141
  summary: sportdb - sport.db command line tool
173
142
  test_files: []
174
-