sportdb 1.0.1 → 1.1.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/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.0.1'], # NB: worlddb already includes
26
+ ['worlddb', '~> 1.1.0'], # NB: worlddb already includes
27
27
  # - commander
28
28
  # - logutils
29
29
  # - textutils
@@ -99,7 +99,7 @@ module SportDB
99
99
 
100
100
  def self.read_setup( setup, include_path )
101
101
  reader = Reader.new
102
- reader.load_setup_with_include_path( setup, include_path )
102
+ reader.load_setup( setup, include_path )
103
103
  end
104
104
 
105
105
  def self.read_all( include_path ) # convenience helper
@@ -114,7 +114,7 @@ module SportDB
114
114
 
115
115
  def self.read( ary, include_path )
116
116
  reader = Reader.new
117
- reader.load_with_include_path( ary, include_path )
117
+ reader.load( ary, include_path )
118
118
  end
119
119
 
120
120
 
@@ -136,21 +136,19 @@ command :load do |c|
136
136
 
137
137
  SportDB.delete! if options.delete.present?
138
138
 
139
- logger = LogUtils::Logger.new
139
+ reader = SportDB::Reader.new
140
140
 
141
- reader = SportDB::Reader.new( logger )
142
-
143
141
  args.each do |arg|
144
142
  name = arg # File.basename( arg, '.*' )
145
143
 
146
144
  if myopts.event.present?
147
145
  ## fix: rename to load_event_fixtures_w... or similar
148
- reader.load_fixtures_with_include_path( myopts.event, name, myopts.data_path )
146
+ reader.load_fixtures( myopts.event, name, myopts.data_path )
149
147
  else
150
148
  ## fix> add a convenience method for loading single fixture
151
149
  ary = []
152
150
  ary << name
153
- reader.load_with_include_path( ary, myopts.data_path )
151
+ reader.load( ary, myopts.data_path )
154
152
  end
155
153
  end # each arg
156
154
 
@@ -9,26 +9,20 @@ class Reader
9
9
  include SportDB::Models
10
10
 
11
11
 
12
- def initialize( logger=nil )
13
- if logger.nil?
14
- @logger = LogUtils::Logger.new
15
- ## @logger = Logger.new(STDOUT)
16
- ## @logger.level = Logger::INFO
17
- else
18
- @logger = logger
19
- end
12
+ def initialize( opts={} )
13
+ @logger = LogUtils::Logger.new
20
14
  end
21
15
 
22
16
  attr_reader :logger
23
17
 
24
- def load_setup_with_include_path( setup, include_path )
25
- ary = load_fixture_setup_with_include_path( setup, include_path )
26
- load_with_include_path( ary, include_path )
27
- end # method load_setup_with_include_path
18
+ def load_setup( setup, include_path )
19
+ ary = load_fixture_setup( setup, include_path )
20
+ load( ary, include_path )
21
+ end # method load_setup
28
22
 
29
23
 
30
24
  ## fix/todo: rename ??
31
- def load_fixture_setup_with_include_path( name, include_path )
25
+ def load_fixture_setup( name, include_path )
32
26
 
33
27
  ## todo/fix: cleanup quick and dirty code
34
28
 
@@ -74,12 +68,12 @@ class Reader
74
68
 
75
69
  ary
76
70
 
77
- end # load_fixture_setup_with_include_path
71
+ end # load_fixture_setup
78
72
 
79
73
 
80
- def load_with_include_path( ary, include_path ) # convenience helper for all-in-one reader
74
+ def load( ary, include_path ) # convenience helper for all-in-one reader
81
75
 
82
- puts "[debug] enter load_with_include_path (include_path=>>#{include_path}<<):"
76
+ puts "[debug] enter load(include_path=>>#{include_path}<<):"
83
77
  pp ary
84
78
 
85
79
  ary.each do |rec|
@@ -88,30 +82,30 @@ class Reader
88
82
  name = rec
89
83
 
90
84
  if name =~ /^seasons/
91
- load_seasons_with_include_path( name, include_path )
85
+ load_seasons( name, include_path )
92
86
  elsif name =~ /^leagues/
93
87
  if name =~ /club/
94
88
  # e.g. leagues_club
95
- load_leagues_with_include_path( name, include_path, { club: true } )
89
+ load_leagues( name, include_path, { club: true } )
96
90
  else
97
91
  # e.g. leagues
98
- load_leagues_with_include_path( name, include_path )
92
+ load_leagues( name, include_path )
99
93
  end
100
94
  elsif name =~ /^([a-z]{2})\/teams/
101
95
  # auto-add country code (from folder structure) for country-specific teams
102
96
  # e.g. at/teams at/teams2 de/teams etc.
103
97
  country_key = $1
104
98
  country = Country.find_by_key!( country_key )
105
- load_teams_with_include_path( name, include_path, { club: true, country_id: country.id } )
99
+ load_teams( name, include_path, { club: true, country_id: country.id } )
106
100
  elsif name =~ /\/teams/
107
101
  if name =~ /club/
108
102
  # club teams (many countries)
109
103
  # e.g. club/europe/teams
110
- load_teams_with_include_path( name, include_path, { club: true } )
104
+ load_teams( name, include_path, { club: true } )
111
105
  else
112
106
  # assume national teams
113
107
  # e.g. world/teams amercia/teams_n
114
- load_teams_with_include_path( name, include_path, { national: true } )
108
+ load_teams( name, include_path, { national: true } )
115
109
  end
116
110
  else
117
111
  logger.error "unknown sportdb fixture type >#{name}<"
@@ -126,17 +120,17 @@ class Reader
126
120
  event_name = rec[1] # e.g. at/2012_13/bl
127
121
  fixture_names = rec[1..-1] # e.g. at/2012_13/bl, at/2012_13/bl2
128
122
 
129
- load_event_with_include_path( event_name, include_path )
123
+ load_event( event_name, include_path )
130
124
  fixture_names.each do |fixture_name|
131
- load_fixtures_with_include_path( event_key, fixture_name, include_path )
125
+ load_fixtures( event_key, fixture_name, include_path )
132
126
  end
133
127
  end
134
128
 
135
129
  end # each ary
136
- end # method load_with_include_path
130
+ end # method load
137
131
 
138
132
 
139
- def load_leagues_with_include_path( name, include_path, more_values={} )
133
+ def load_leagues( name, include_path, more_values={} )
140
134
 
141
135
  path = "#{include_path}/#{name}.txt"
142
136
 
@@ -149,10 +143,10 @@ class Reader
149
143
  ### todo/fix: add prop
150
144
  ### Prop.create!( key: "db.#{fixture_name_to_prop_key(name)}.version", value: "file.txt.#{File.mtime(path).strftime('%Y.%m.%d')}" )
151
145
 
152
- end # load_leagues_with_include_path
146
+ end # load_leagues
153
147
 
154
148
 
155
- def load_seasons_with_include_path( name, include_path )
149
+ def load_seasons( name, include_path )
156
150
  path = "#{include_path}/#{name}.yml"
157
151
 
158
152
  puts "*** parsing data '#{name}' (#{path})..."
@@ -198,11 +192,11 @@ class Reader
198
192
  ### todo/fix: add prop
199
193
  ### Prop.create_from_sportdb_fixture!( name, path )
200
194
 
201
- end # load_seasons_with_include_path
195
+ end # load_seasons
202
196
 
203
197
 
204
198
 
205
- def load_event_with_include_path( name, include_path )
199
+ def load_event( name, include_path )
206
200
  path = "#{include_path}/#{name}.yml"
207
201
 
208
202
  logger.info "parsing data '#{name}' (#{path})..."
@@ -286,7 +280,7 @@ class Reader
286
280
 
287
281
  ### todo/fix: add prop
288
282
 
289
- end # load_event_with_include_path
283
+ end # load_event
290
284
 
291
285
 
292
286
  def load_fixtures_from_string( event_key, text ) # load from string (e.g. passed in via web form)
@@ -300,7 +294,7 @@ class Reader
300
294
  ### Prop.create!( key: "db.#{fixture_name_to_prop_key(name)}.version", value: "file.txt.#{File.mtime(path).strftime('%Y.%m.%d')}" )
301
295
  end
302
296
 
303
- def load_fixtures_with_include_path( event_key, name, include_path ) # load from file system
297
+ def load_fixtures( event_key, name, include_path ) # load from file system
304
298
 
305
299
  path = "#{include_path}/#{name}.txt"
306
300
 
@@ -317,7 +311,7 @@ class Reader
317
311
  end
318
312
 
319
313
 
320
- def load_teams_with_include_path( name, include_path, more_values={} )
314
+ def load_teams( name, include_path, more_values={} )
321
315
  path = "#{include_path}/#{name}.txt"
322
316
 
323
317
  puts "*** parsing data '#{name}' (#{path})..."
@@ -328,7 +322,7 @@ class Reader
328
322
 
329
323
  ## todo/fix: add prop
330
324
  ## Prop.create!( key: "db.#{fixture_name_to_prop_key(name)}.version", value: "sport.txt.#{SportDB::VERSION}" )
331
- end # load_teams_with_include_path
325
+ end # load_teams
332
326
 
333
327
  private
334
328
 
@@ -1,4 +1,4 @@
1
1
 
2
2
  module SportDB
3
- VERSION = '1.0.1'
3
+ VERSION = '1.1.0'
4
4
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sportdb
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 0
9
8
  - 1
10
- version: 1.0.1
9
+ - 0
10
+ version: 1.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Gerald Bauer
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2013-02-20 00:00:00 Z
18
+ date: 2013-02-21 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: worlddb
@@ -25,12 +25,12 @@ dependencies:
25
25
  requirements:
26
26
  - - ~>
27
27
  - !ruby/object:Gem::Version
28
- hash: 21
28
+ hash: 19
29
29
  segments:
30
30
  - 1
31
- - 0
32
31
  - 1
33
- version: 1.0.1
32
+ - 0
33
+ version: 1.1.0
34
34
  type: :runtime
35
35
  version_requirements: *id001
36
36
  - !ruby/object:Gem::Dependency