<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/skating_system/ranking.rb</filename>
    </added>
    <added>
      <filename>spec/spec/ranking_spec.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,4 +1,5 @@
 require 'skating_system/performance_results'
+require 'skating_system/ranking'
 require 'skating_system/scorer'
 
 module SkatingSystem</diff>
      <filename>lib/skating_system.rb</filename>
    </modified>
    <modified>
      <diff>@@ -15,6 +15,22 @@ module SkatingSystem
       end
     end
     
+    def ranking
+      return @ranking if @ranking
+      @ranking =SkatingSystem::Ranking.new
+      @marks.each do |entree, data|
+         @ranking.add(data[:result], entree)
+      end
+      @ranking
+    end
+    
+    def [](key)
+      @marks[key]
+    end
+
+    
+    
+    private
     def sum_marks(entree, position)
       sum=0
       @marks[entree].each do |judge, place|
@@ -59,12 +75,7 @@ module SkatingSystem
       end
       candidates
     end
-
-    def [](key)
-      @marks[key]
-    end
-
-    private
+    
     #Tallys the number of judges who marked each entree in each place or heigher
     # and writes the results to @tally
     # eg given the results</diff>
      <filename>lib/skating_system/performance_results.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,12 +2,12 @@
 Gem::Specification.new do |s|
     s.platform  =   Gem::Platform::RUBY
     s.name      =   &quot;skating-system&quot;
-    s.version   =   &quot;0.0.1&quot;
+    s.version   =   &quot;0.0.2&quot;
     s.author    =   &quot;Laurie Young&quot;
     s.email     =   &quot;skating_system@wildfalcon.com&quot;
     s.summary   =   &quot;Implemetation of the skating system.&quot;
-    s.files     =   ['lib/skating_system.rb', 'lib/skating_system/scorer.rb', 'lib/skating_system/performance_results.rb',
-                    'spec/spec.opts', 'spec/spec_helper.rb', 'spec/spec/scorer_spec.rb', 'spec/spec/performance_results_spec.rb']
+    s.files     =   ['lib/skating_system.rb', 'lib/skating_system/scorer.rb', 'lib/skating_system/performance_results.rb', 'lib/skating_system/ranking.rb',
+                    'spec/spec.opts', 'spec/spec_helper.rb', 'spec/spec/scorer_spec.rb', 'spec/spec/performance_results_spec.rb', 'spec/spec/ranking_spec.rb']
     s.require_path  =   &quot;lib&quot;
     s.autorequire   =   &quot;skating_system&quot;
     s.has_rdoc  =   true</diff>
      <filename>skating-system.gemspec</filename>
    </modified>
    <modified>
      <diff>@@ -60,4 +60,48 @@ describe SkatingSystem::PerformanceResults, &quot;tallying the marks&quot; do
   end
 end
 
+describe SkatingSystem::PerformanceResults, &quot;getting the rankings&quot; do
+  before(:each) do
+    @performance_resuts = SkatingSystem::PerformanceResults.new
+    
+    @judge1 = mock(&quot;Judge&quot;)
+    @judge2 = mock(&quot;Judge&quot;)
+    @judge3 = mock(&quot;Judge&quot;)
+    
+    @entree1 = mock(&quot;Entree&quot;)
+    @entree2 = mock(&quot;Entree&quot;)
+    @entree3 = mock(&quot;Entree&quot;)
+    
+    #    A  B  C     1 2 3
+    # 1  1  1  3     2 2 3    1
+    # 2  2  3  2     0 2 3    2
+    # 3  3  2  3     0 1 3    3
+    @couples_marks = { @entree1=&gt;{@judge1=&gt;1, @judge2=&gt;1, @judge3=&gt;3 },
+      @entree2=&gt;{@judge1=&gt;2, @judge2=&gt;3, @judge3=&gt;2 },
+      @entree3=&gt;{@judge1=&gt;3, @judge2=&gt;2, @judge3=&gt;3 }} 
+
+    SkatingSystem::Ranking.stub!(:new).and_return(@ranking = mock(SkatingSystem::Ranking))
+    @ranking.stub!(:add) 
+
+              @performance_resuts.score(@couples_marks)
+  end
+
+  it &quot;should return a Ranking when asked for one&quot; do
+    @performance_resuts.ranking.should be(@ranking)
+  end
+
+  it &quot;should add couple 1 to the ranking in first place&quot; do
+    @ranking.should_receive(:add).with(1, @entree1)
+    @performance_resuts.ranking
+  end
 
+  it &quot;should add couple 2 to the ranking in second place&quot; do
+    @ranking.should_receive(:add).with(2, @entree2)
+    @performance_resuts.ranking
+  end
+
+  it &quot;should add couple 3 to the ranking in third place&quot; do
+    @ranking.should_receive(:add).with(3, @entree3)
+    @performance_resuts.ranking
+  end
+end</diff>
      <filename>spec/spec/performance_results_spec.rb</filename>
    </modified>
    <modified>
      <diff>@@ -2,7 +2,9 @@ dir = File.dirname(__FILE__)
 lib_path = File.expand_path(&quot;#{dir}/../lib&quot;)
 $LOAD_PATH.unshift lib_path unless $LOAD_PATH.include?(lib_path)
 
+require 'rubygems'
 require 'skating_system'
+require 'ruby-debug'
 
 Spec::Runner.configure do |config|
 </diff>
      <filename>spec/spec_helper.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>3356bef2367217512be5061596354eaa667ef840</id>
    </parent>
  </parents>
  <author>
    <name>Laurie Young</name>
    <email>laurie@wildfalcon.com</email>
  </author>
  <url>http://github.com/wildfalcon/skating-system/commit/f100ccfa6dd1869c7bc78eac54c7f9c32f53a87d</url>
  <id>f100ccfa6dd1869c7bc78eac54c7f9c32f53a87d</id>
  <committed-date>2008-07-03T14:31:08-07:00</committed-date>
  <authored-date>2008-07-03T14:31:08-07:00</authored-date>
  <message>Added a ranking return for performance results, and updated performance results to include first have of rules 7</message>
  <tree>8b7e07757d759fdf5e5935e103888ab80aefc013</tree>
  <committer>
    <name>Laurie Young</name>
    <email>laurie@wildfalcon.com</email>
  </committer>
</commit>
