sportdb 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -109,7 +109,42 @@ module SportDB
109
109
  Deleter.new.run
110
110
  end # method delete!
111
111
 
112
+ def self.load_plugins
113
+
114
+ @found ||= []
115
+ @loaded ||= {}
116
+ @files ||= Gem.find_files( 'sportdb_plugin.rb' )
117
+
118
+ puts "#{@files.size} plugin files found:"
119
+ @files.each do |file|
120
+ puts " >#{file}<"
121
+ end
122
+
123
+ ## todo: extract version and name of gem?
124
+ puts "normalized/match pattern:"
125
+ @files.each do |file|
126
+ if file =~ /sportdb-([a-z]+)-(\d\.\d.\d)/
127
+ puts " >#{$1}< | >#{$2}<"
128
+ @found << file
129
+ else
130
+ puts "*** error: ignoring plugin script >#{file}< not matching gem naming pattern"
131
+ end
132
+ end
133
+
134
+ @found.each do |file|
135
+ begin
136
+ puts "loading plugin script #{file}"
137
+ require file
138
+ rescue LoadError => e
139
+ puts "*** error loading plugin script #{file.inspect}: #{e.message}. skipping..."
140
+ end
141
+ end
142
+
143
+ end
144
+
112
145
  end # module SportDB
113
146
 
114
147
 
148
+ SportDB::load_plugins
149
+
115
150
  SportDB.main if __FILE__ == $0
@@ -17,7 +17,6 @@ class Runner
17
17
 
18
18
  attr_reader :logger, :opts
19
19
 
20
-
21
20
  def run( args )
22
21
  opt=OptionParser.new do |cmd|
23
22
 
@@ -141,6 +141,8 @@ class Game < ActiveRecord::Base
141
141
  game2.save!
142
142
  end # each pair
143
143
  end
144
+
145
+
144
146
 
145
147
  def calc_toto12x
146
148
  if score1.nil? || score2.nil?
@@ -153,6 +155,41 @@ class Game < ActiveRecord::Base
153
155
  self.toto12x = '2'
154
156
  end
155
157
  end
158
+
159
+
160
+ def over? # game over?
161
+ play_at <= Time.now
162
+ end
163
+
164
+ ## fix/todo: already added by ar magic ??? remove code
165
+ def knockout?
166
+ knockout == true
167
+ end
168
+
169
+ def complete?
170
+ score1.present? && score2.present?
171
+ end
172
+
173
+ ############# convenience helpers for styling
174
+ ##
175
+
176
+ def team1_style_class
177
+ buf = ''
178
+ ## NB: remove if calc?
179
+ buf << 'game-team-winner ' if complete? && (score1 > score2)
180
+ buf << 'game-team-draw ' if complete? && (score1 == score2)
181
+ buf
182
+ end
183
+
184
+ def team2_style_class
185
+ buf = ''
186
+ ## NB: remove if calc?
187
+ buf << 'game-team-winner ' if complete? && (score2 > score1)
188
+ buf << 'game-team-draw ' if complete? && (score2 == score1)
189
+ buf
190
+ end
191
+
192
+
156
193
 
157
194
  end # class Game
158
195
 
@@ -1,4 +1,4 @@
1
1
 
2
2
  module SportDB
3
- VERSION = '0.7.1'
3
+ VERSION = '0.7.2'
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: 1
4
+ hash: 7
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 7
9
- - 1
10
- version: 0.7.1
9
+ - 2
10
+ version: 0.7.2
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: 2012-11-07 00:00:00 Z
18
+ date: 2012-11-15 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: activerecord