opensprints-core 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +5 -1
- data/VERSION +1 -1
- data/lib/migrations/006_add_for_fun_to_races.rb +14 -0
- data/lib/opensprints-core/racer.rb +3 -1
- data/lib/opensprints-core.rb +1 -0
- data/test/test_racer.rb +14 -0
- metadata +25 -13
data/README.rdoc
CHANGED
@@ -2,12 +2,16 @@
|
|
2
2
|
|
3
3
|
This is a library for interacting with the data recorded by opensprints. Racers, Speed, Events, best time, losses, speed, etc. are all encapsulated here. If you'd like to create a ruby application for goldsprints registration, conducting races, or analyzing performances "opensprints-core" is your gem.
|
4
4
|
|
5
|
-
This library was extracted from
|
5
|
+
This library was extracted from {http://github.com/evanfarrar/opensprints opensprints}. This is the "model" for opensprints's view. This portion of the application had good test coverage (the view portion has none). This portion of the app has kept a similar structure since the beginning of the project (opensprints' view has been completely rewritten with at least 4 different architectures and libraries). This gem is currently only used in the {http://github.com/evanfarrar/opensprints.org opensprints.org application} and the {http://github.com/evanfarrar/opensprints opensprints shoes application}. If you're using it in your project, let me know (evan (at) opensprints (period) org).
|
6
6
|
|
7
7
|
== Note on Patches/Pull Requests
|
8
8
|
|
9
9
|
OpenSprints has an aggressively liberal commit policy. If you follow or fork the project on github, we'll add you the project's collaborators list.
|
10
10
|
|
11
|
+
If you're intereseted in learning more about the structure of this application to modify, extend or fork it, read our API docs:
|
12
|
+
* {http://rdoc.info/projects/evanfarrar/opensprints}
|
13
|
+
* {http://rdoc.info/projects/evanfarrar/opensprints-core}
|
14
|
+
|
11
15
|
== Copyright
|
12
16
|
|
13
17
|
Copyright (c) 2009 Evan Farrar. See LICENSE for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'ruby-debug'
|
1
2
|
class Racer < Sequel::Model
|
2
3
|
one_to_many :categorizations
|
3
4
|
many_to_many :categories, :join_table => :categorizations
|
@@ -6,7 +7,8 @@ class Racer < Sequel::Model
|
|
6
7
|
end
|
7
8
|
|
8
9
|
def best_time
|
9
|
-
|
10
|
+
serious_races = self.db[:races].filter(:for_fun => false).select(:id)
|
11
|
+
best = self.db[:race_participations].filter(:racer_id => self.pk, :race_id => serious_races).order(:finish_time).select(:finish_time).first
|
10
12
|
best[:finish_time] if best
|
11
13
|
end
|
12
14
|
end
|
data/lib/opensprints-core.rb
CHANGED
@@ -10,6 +10,7 @@ if(defined? Shoes) #Real environment
|
|
10
10
|
Sequel::Migrator.apply(DB, 'lib/migrations/')
|
11
11
|
else #Test environment
|
12
12
|
DB = Sequel.connect("sqlite::memory:")
|
13
|
+
Sequel::Migrator.apply(DB, 'lib/migrations/')
|
13
14
|
end
|
14
15
|
Infinity = 1/0.0
|
15
16
|
require 'opensprints-core/tournament'
|
data/test/test_racer.rb
CHANGED
@@ -42,4 +42,18 @@ describe 'A racer' do
|
|
42
42
|
end
|
43
43
|
racer.best_time.should==(2.7)
|
44
44
|
end
|
45
|
+
|
46
|
+
it "should ignore best times from fun races" do
|
47
|
+
racer = Racer.create
|
48
|
+
[7.0, 12.0, 2.7, 10.0].each do |time|
|
49
|
+
race = Race.create(:for_fun => true)
|
50
|
+
RaceParticipation.create(:finish_time => time, :race => race, :racer => racer)
|
51
|
+
end
|
52
|
+
racer.best_time.should==nil
|
53
|
+
[7.0, 12.0, 10.0].each do |time|
|
54
|
+
race = Race.create
|
55
|
+
RaceParticipation.create(:finish_time => time, :race => race, :racer => racer)
|
56
|
+
end
|
57
|
+
racer.best_time.should==7.0
|
58
|
+
end
|
45
59
|
end
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opensprints-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 6
|
8
|
+
- 0
|
9
|
+
version: 0.6.0
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Evan Farrar
|
@@ -9,29 +14,33 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date:
|
17
|
+
date: 2010-09-06 00:00:00 -05:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: bacon
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
23
29
|
version: "0"
|
24
|
-
|
30
|
+
type: :development
|
31
|
+
version_requirements: *id001
|
25
32
|
- !ruby/object:Gem::Dependency
|
26
33
|
name: sequel
|
27
|
-
|
28
|
-
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
34
|
+
prerelease: false
|
35
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
37
|
- - ">="
|
32
38
|
- !ruby/object:Gem::Version
|
39
|
+
segments:
|
40
|
+
- 0
|
33
41
|
version: "0"
|
34
|
-
|
42
|
+
type: :runtime
|
43
|
+
version_requirements: *id002
|
35
44
|
description: "A lib for interacting with opensprints race records data. If you want to write a new application to display opensprints stats or run races, this is your gem. "
|
36
45
|
email: evanfarrar@gmail.com
|
37
46
|
executables: []
|
@@ -53,6 +62,7 @@ files:
|
|
53
62
|
- lib/migrations/003_create_categorizations.rb
|
54
63
|
- lib/migrations/004_create_races.rb
|
55
64
|
- lib/migrations/005_create_tournaments.rb
|
65
|
+
- lib/migrations/006_add_for_fun_to_races.rb
|
56
66
|
- lib/opensprints-core.rb
|
57
67
|
- lib/opensprints-core/categorization.rb
|
58
68
|
- lib/opensprints-core/category.rb
|
@@ -82,18 +92,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
82
92
|
requirements:
|
83
93
|
- - ">="
|
84
94
|
- !ruby/object:Gem::Version
|
95
|
+
segments:
|
96
|
+
- 0
|
85
97
|
version: "0"
|
86
|
-
version:
|
87
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
99
|
requirements:
|
89
100
|
- - ">="
|
90
101
|
- !ruby/object:Gem::Version
|
102
|
+
segments:
|
103
|
+
- 0
|
91
104
|
version: "0"
|
92
|
-
version:
|
93
105
|
requirements: []
|
94
106
|
|
95
107
|
rubyforge_project:
|
96
|
-
rubygems_version: 1.3.
|
108
|
+
rubygems_version: 1.3.6
|
97
109
|
signing_key:
|
98
110
|
specification_version: 3
|
99
111
|
summary: A lib for interacting with opensprints race records data
|