<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/ruby-poker/card.rb</filename>
    </added>
    <added>
      <filename>lib/ruby-poker/poker_hand.rb</filename>
    </added>
    <added>
      <filename>test/test_helper.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,4 +1,5 @@
-2009-06-21 (0.3.2)
+2009-07-12 (0.3.2)
+    * Reorganized ruby-poker's lib folder to match the standard layout for gems. This makes ruby-poker compatible with Rip.
     * Bug [#26276] improper two_pair? behavior. Applied patch by Uro.
     * Changed protected methods in PokerHand to private
     * Added natural_value method to Card</diff>
      <filename>CHANGELOG</filename>
    </modified>
    <modified>
      <diff>@@ -1,19 +1,13 @@
-#!/usr/bin/env ruby
-
-require 'rake/rdoctask'
-require &quot;rake/testtask&quot;
-require 'rake/gempackagetask'
+require 'rubygems'
+require 'rake'
 
 begin
-  require &quot;rubygems&quot;
+  require 'metric_fu'
 rescue LoadError
-  nil
 end
 
 RUBYPOKER_VERSION = &quot;0.3.1&quot;
 
-task :default =&gt; [:test]
-
 spec = Gem::Specification.new do |s|
   s.name     = &quot;ruby-poker&quot;
   s.version  = RUBYPOKER_VERSION
@@ -29,13 +23,14 @@ spec = Gem::Specification.new do |s|
   s.files    = [&quot;CHANGELOG&quot;, 
                 &quot;examples/deck.rb&quot;, 
                 &quot;examples/quick_example.rb&quot;, 
-                &quot;lib/card.rb&quot;, 
-                &quot;lib/ruby-poker.rb&quot;, 
+                &quot;lib/ruby-poker.rb&quot;,
+                &quot;lib/ruby-poker/card.rb&quot;, 
+                &quot;lib/ruby-poker/poker_hand.rb&quot;, 
                 &quot;LICENSE&quot;, 
                 &quot;Rakefile&quot;, 
                 &quot;README.rdoc&quot;, 
                 &quot;ruby-poker.gemspec&quot;]
-  s.test_files = [&quot;test/test_card.rb&quot;, &quot;test/test_poker_hand.rb&quot;]
+  s.test_files = [&quot;test/test_helper.rb&quot;, &quot;test/test_card.rb&quot;, &quot;test/test_poker_hand.rb&quot;]
   s.require_paths &lt;&lt; 'lib'
 
   s.extra_rdoc_files = [&quot;README.rdoc&quot;, &quot;CHANGELOG&quot;, &quot;LICENSE&quot;]
@@ -46,14 +41,15 @@ spec = Gem::Specification.new do |s|
   # s.add_dependency(&quot;thoughtbot-shoulda&quot;, [&quot;&gt; 2.0.0&quot;])
 end
 
+require 'rake/gempackagetask'
 Rake::GemPackageTask.new(spec) do |pkg| 
   pkg.need_tar = true 
   pkg.need_zip = true
 end
 
-Rake::TestTask.new do |test|
-  test.libs &lt;&lt; &quot;test&quot;
-  test.test_files = Dir[ &quot;test/test_*.rb&quot; ]
+require 'rake/testtask'
+Rake::TestTask.new(:test) do |test|
+  test.libs &lt;&lt; 'lib' &lt;&lt; 'test'
   test.verbose = true
   test.warning = true
 end
@@ -63,10 +59,12 @@ task :autotest do
   ruby &quot;-I lib -w /usr/bin/autotest&quot;
 end
 
+require 'rake/rdoctask'
 Rake::RDocTask.new(:docs) do |rdoc|
-  rdoc.rdoc_files.include('README.rdoc', 'CHANGELOG', 'LICENSE', 'lib/')
   rdoc.main     = 'README.rdoc'
-  rdoc.rdoc_dir = 'doc/html'
-  rdoc.title    = 'Ruby Poker Documentation'
-  rdoc.options &lt;&lt; '--inline-source'
+  rdoc.rdoc_dir = 'rdoc'
+  rdoc.title    = &quot;Ruby Poker #{RUBYPOKER_VERSION}&quot;
+  rdoc.rdoc_files.include('README.rdoc', 'CHANGELOG', 'LICENSE', 'lib/**/*.rb')
 end
+
+task :default =&gt; :test
\ No newline at end of file</diff>
      <filename>Rakefile</filename>
    </modified>
    <modified>
      <diff>@@ -1,409 +1,3 @@
-require 'card.rb'
-
-class PokerHand
-  include Comparable
-  attr_reader :hand
-  
-  @@allow_duplicates = true    # true by default
-  def self.allow_duplicates; @@allow_duplicates; end
-  def self.allow_duplicates=(v); @@allow_duplicates = v; end
-  
-  # Returns a new PokerHand object. Accepts the cards represented
-  # in a string or an array
-  #
-  #     PokerHand.new(&quot;3d 5c 8h Ks&quot;)   # =&gt; #&lt;PokerHand:0x5c673c ...
-  #     PokerHand.new([&quot;3d&quot;, &quot;5c&quot;, &quot;8h&quot;, &quot;Ks&quot;])  # =&gt; #&lt;PokerHand:0x5c2d6c ...
-  def initialize(cards = [])
-    if cards.is_a? Array
-      @hand = cards.map do |card|
-        if card.is_a? Card
-          card
-        else
-          Card.new(card.to_s)
-        end
-      end
-    elsif cards.respond_to?(:to_str)
-      @hand = cards.scan(/\S{2,3}/).map { |str| Card.new(str) }
-    else
-      @hand = cards
-    end
-    
-    check_for_duplicates if !@@allow_duplicates
-  end
-
-  # Returns a new PokerHand object with the cards sorted by suit
-  # The suit order is spades, hearts, diamonds, clubs
-  #
-  #     PokerHand.new(&quot;3d 5c 8h Ks&quot;).by_suit.just_cards   # =&gt; &quot;Ks 8h 3d 5c&quot;
-  def by_suit
-    PokerHand.new(@hand.sort_by { |c| [c.suit, c.face] }.reverse)
-  end
-
-  # Returns a new PokerHand object with the cards sorted by value
-  # with the highest value first.
-  #
-  #     PokerHand.new(&quot;3d 5c 8h Ks&quot;).by_face.just_cards   # =&gt; &quot;Ks 8h 5c 3d&quot;
-  def by_face
-    PokerHand.new(@hand.sort_by { |c| [c.face, c.suit] }.reverse)
-  end
-  
-  # Returns string representation of the hand without the rank
-  #
-  #     PokerHand.new([&quot;3c&quot;, &quot;Kh&quot;]).just_cards     # =&gt; &quot;3c Kh&quot;
-  def just_cards
-    @hand.join(&quot; &quot;)
-  end
-  alias :cards :just_cards
-  
-  # Returns an array of the card values in the hand.
-  # The values returned are 1 less than the value on the card.
-  # For example: 2's will be shown as 1.
-  #
-  #     PokerHand.new([&quot;3c&quot;, &quot;Kh&quot;]).face_values     # =&gt; [2, 12]
-  def face_values
-    @hand.map { |c| c.face }
-  end
-
-  # The =~ method does a regular expression match on the cards in this hand.
-  # This can be useful for many purposes. A common use is the check if a card
-  # exists in a hand.
-  #
-  #     PokerHand.new(&quot;3d 4d 5d&quot;) =~ /8h/           # =&gt; nil
-  #     PokerHand.new(&quot;3d 4d 5d&quot;) =~ /4d/           # =&gt; #&lt;MatchData:0x615e18&gt;
-  def =~ (re)
-    re.match(just_cards)
-  end
-
-  def royal_flush?
-    if (md = (by_suit =~ /A(.) K\1 Q\1 J\1 T\1/))
-      [[10], arrange_hand(md)]
-    else
-      false
-    end
-  end
-
-  def straight_flush?
-    if (md = (/.(.)(.)(?: 1.\2){4}/.match(delta_transform(true))))
-      high_card = Card::face_value(md[1])
-      arranged_hand = fix_low_ace_display(md[0] + ' ' +
-          md.pre_match + ' ' + md.post_match)
-      [[9, high_card], arranged_hand]
-    else
-      false
-    end
-  end
-
-  def four_of_a_kind?
-    if (md = (by_face =~ /(.). \1. \1. \1./))
-      # get kicker
-      (md.pre_match + md.post_match).match(/(\S)/)
-      [
-        [8, Card::face_value(md[1]), Card::face_value($1)],
-        arrange_hand(md)
-      ]
-    else
-      false
-    end
-  end
-
-  def full_house?
-    if (md = (by_face =~ /(.). \1. \1. (.*)(.). \3./))
-      arranged_hand = arrange_hand(md[0] + ' ' +
-          md.pre_match + ' ' + md[2] + ' ' + md.post_match)
-      [
-        [7, Card::face_value(md[1]), Card::face_value(md[3])],
-        arranged_hand
-      ]
-    elsif (md = (by_face =~ /((.). \2.) (.*)((.). \5. \5.)/))
-      arranged_hand = arrange_hand(md[4] + ' '  + md[1] + ' ' +
-          md.pre_match + ' ' + md[3] + ' ' + md.post_match)
-      [
-        [7, Card::face_value(md[5]), Card::face_value(md[2])],
-        arranged_hand
-      ]
-    else
-      false
-    end
-  end
-
-  def flush?
-    if (md = (by_suit =~ /(.)(.) (.)\2 (.)\2 (.)\2 (.)\2/))
-      [
-        [
-          6,
-          Card::face_value(md[1]),
-          *(md[3..6].map { |f| Card::face_value(f) })
-        ],
-        arrange_hand(md)
-      ]
-    else
-      false
-    end
-  end
-
-  def straight?
-    result = false
-    if hand.size &gt;= 5
-      transform = delta_transform
-      # note we can have more than one delta 0 that we
-      # need to shuffle to the back of the hand
-      i = 0
-      until transform.match(/^\S{3}( [1-9x]\S\S)+( 0\S\S)*$/) or i &gt;= hand.size  do
-        # only do this once per card in the hand to avoid entering an
-        # infinite loop if all of the cards in the hand are the same
-        transform.gsub!(/(\s0\S\S)(.*)/, &quot;\\2\\1&quot;)    # moves the front card to the back of the string
-        i += 1
-      end
-      if (md = (/.(.). 1.. 1.. 1.. 1../.match(transform)))
-        high_card = Card::face_value(md[1])
-        arranged_hand = fix_low_ace_display(md[0] + ' ' + md.pre_match + ' ' + md.post_match)
-        result = [[5, high_card], arranged_hand]
-      end
-    end
-  end
-
-  def three_of_a_kind?
-    if (md = (by_face =~ /(.). \1. \1./))
-      # get kicker
-      arranged_hand = arrange_hand(md)
-      arranged_hand.match(/(?:\S\S ){3}(\S)\S (\S)/)
-      [
-        [
-          4,
-          Card::face_value(md[1]),
-          Card::face_value($1),
-          Card::face_value($2)
-        ],
-        arranged_hand
-      ]
-    else
-      false
-    end
-  end
-
-  def two_pair?
-    # \1 is the face value of the first pair
-    # \2 is the card in between the first pair and the second pair
-    # \3 is the face value of the second pair
-    if (md = (by_face =~ /(.). \1.(.*?) (.). \3./))
-      # to get the kicker this does the following
-      # md[0] is the regex matched above which includes the first pair and
-      # the second pair but also some cards in the middle so we sub them out
-      # then we add on the cards that came before the first pair, the cards
-      # that were in-between, and the cards that came after.
-      arranged_hand = arrange_hand(md[0].sub(md[2], '') + ' ' +
-          md.pre_match + ' ' + md[2] + ' ' + md.post_match)
-      arranged_hand.match(/(?:\S\S ){4}(\S)/)
-      [
-        [
-          3,
-          Card::face_value(md[1]),    # face value of the first pair
-          Card::face_value(md[3]),    # face value of the second pair
-          Card::face_value($1)        # face value of the kicker
-        ],
-        arranged_hand
-      ]
-    else
-      false
-    end
-  end
-
-  def pair?
-    if (md = (by_face =~ /(.). \1./))
-      # get kicker
-      arranged_hand = arrange_hand(md)
-      arranged_hand.match(/(?:\S\S ){2}(\S)\S\s+(\S)\S\s+(\S)/)
-      [
-        [
-          2,
-          Card::face_value(md[1]),
-          Card::face_value($1),
-          Card::face_value($2),
-          Card::face_value($3)
-        ],
-        arranged_hand
-      ]
-    else
-      false
-    end
-  end
-
-  def highest_card?
-    result = by_face
-    [[1, *result.face_values[0..4]], result.hand.join(' ')]
-  end
-
-  OPS = [
-    ['Royal Flush',     :royal_flush? ],
-    ['Straight Flush',  :straight_flush? ],
-    ['Four of a kind',  :four_of_a_kind? ],
-    ['Full house',      :full_house? ],
-    ['Flush',           :flush? ],
-    ['Straight',        :straight? ],
-    ['Three of a kind', :three_of_a_kind?],
-    ['Two pair',        :two_pair? ],
-    ['Pair',            :pair? ],
-    ['Highest Card',    :highest_card? ],
-  ]
-
-  # Returns the verbose hand rating
-  #
-  #     PokerHand.new(&quot;4s 5h 6c 7d 8s&quot;).hand_rating     # =&gt; &quot;Straight&quot;
-  def hand_rating
-    OPS.map { |op|
-      (method(op[1]).call()) ? op[0] : false
-    }.find { |v| v }
-  end
-  
-  alias :rank :hand_rating
-  
-  def score
-    # OPS.map returns an array containing the result of calling each OPS method again
-    # the poker hand. The non-nil cell closest to the front of the array represents
-    # the highest ranking.
-    # find([0]) returns [0] instead of nil if the hand does not match any of the rankings
-    # which is not likely to occur since every hand should at least have a highest card
-    OPS.map { |op|
-      method(op[1]).call()
-    }.find([0]) { |score| score }
-  end
-
-  # Returns a string of the hand arranged based on its rank. Usually this will be the
-  # same as by_face but there are some cases where it makes a difference.
-  #
-  #     ph = PokerHand.new(&quot;As 3s 5s 2s 4s&quot;)
-  #     ph.sort_using_rank        # =&gt; &quot;5s 4s 3s 2s As&quot;
-  #     ph.by_face.just_cards       # =&gt; &quot;As 5s 4s 3s 2s&quot;   
-  def sort_using_rank
-    score[1]
-  end
-  
-  # Returns string with a listing of the cards in the hand followed by the hand's rank.
-  #
-  #     h = PokerHand.new(&quot;8c 8s&quot;)
-  #     h.to_s                      # =&gt; &quot;8c 8s (Pair)&quot;
-  def to_s
-    just_cards + &quot; (&quot; + hand_rating + &quot;)&quot;
-  end
-  
-  # Returns an array of `Card` objects that make up the `PokerHand`.
-  def to_a
-    @hand
-  end
-  
-  alias :to_ary :to_a
-  
-  def &lt;=&gt; other_hand
-    self.score[0].compact &lt;=&gt; other_hand.score[0].compact
-  end
-  
-  # Add a card to the hand
-  # 
-  #     hand = PokerHand.new(&quot;5d&quot;)
-  #     hand &lt;&lt; &quot;6s&quot;          # =&gt; Add a six of spades to the hand by passing a string
-  #     hand &lt;&lt; [&quot;7h&quot;, &quot;8d&quot;]  # =&gt; Add multiple cards to the hand using an array
-  def &lt;&lt; new_cards
-    if new_cards.is_a?(Card) || new_cards.is_a?(String)
-      new_cards = [new_cards]
-    end
-    
-    new_cards.each do |nc|
-      unless @@allow_duplicates
-        raise &quot;A card with the value #{nc} already exists in this hand. Set PokerHand.allow_duplicates to true if you want to be able to add a card more than once.&quot; if self =~ /#{nc}/
-      end
-      
-      @hand &lt;&lt; Card.new(nc)
-    end
-  end
-  
-  # Remove a card from the hand.
-  #
-  #     hand = PokerHand.new(&quot;5d Jd&quot;)
-  #     hand.delete(&quot;Jd&quot;)           # =&gt; #&lt;Card:0x5d0674 @value=23, @face=10, @suit=1&gt;
-  #     hand.just_cards             # =&gt; &quot;5d&quot;
-  def delete card
-    @hand.delete(Card.new(card))
-  end
-  
-  # Same concept as Array#uniq
-  def uniq
-    PokerHand.new(@hand.uniq)
-  end
-  
-  # Resolving methods are just passed directly down to the @hand array
-  RESOLVING_METHODS = [:size, :+, :-]
-  RESOLVING_METHODS.each do |method|
-    class_eval %{
-      def #{method}(*args, &amp;block)
-        @hand.#{method}(*args, &amp;block)
-      end
-    }
-  end
-  
-  private
-  
-  def check_for_duplicates
-    if @hand.size != @hand.uniq.size &amp;&amp; !@@allow_duplicates
-      raise &quot;Attempting to create a hand that contains duplicate cards. Set PokerHand.allow_duplicates to true if you do not want to ignore this error.&quot;
-    end
-  end
-  
-  # if md is a string, arrange_hand will remove extra white space
-  # if md is a MatchData, arrange_hand returns the matched segment
-  # followed by the pre_match and the post_match
-  def arrange_hand(md)
-      hand = if (md.respond_to?(:to_str))
-        md
-      else
-        md[0] + ' ' + md.pre_match + md.post_match
-      end
-      hand.strip.squeeze(&quot; &quot;)   # remove extra whitespace
-  end
-
-  # delta transform creates a version of the cards where the delta
-  # between card values is in the string, so a regexp can then match a
-  # straight and/or straight flush
-  def delta_transform(use_suit = false)
-    aces = @hand.select { |c| c.face == Card::face_value('A') }
-    aces.map! { |c| Card.new(1,c.suit) }
-
-    base = if (use_suit)
-      (@hand + aces).sort_by { |c| [c.suit, c.face] }.reverse
-    else
-      (@hand + aces).sort_by { |c| [c.face, c.suit] }.reverse
-    end
-
-    result = base.inject(['',nil]) do |(delta_hand, prev_card), card|
-      if (prev_card)
-        delta = prev_card - card.face
-      else
-        delta = 0
-      end
-      # does not really matter for my needs
-      delta = 'x' if (delta &gt; 9 || delta &lt; 0)
-      delta_hand += delta.to_s + card.to_s + ' '
-      [delta_hand, card.face]
-    end
-
-    # we just want the delta transform, not the last cards face too
-    result[0].chop
-  end
-
-  def fix_low_ace_display(arranged_hand)
-    # remove card deltas (this routine is only used for straights)
-    arranged_hand.gsub!(/\S(\S\S)\s*/, &quot;\\1 &quot;)
-
-    # Fix &quot;low aces&quot;
-    arranged_hand.gsub!(/L(\S)/, &quot;A\\1&quot;)
-
-    # Remove duplicate aces (this will not work if you have
-    # multiple decks or wild cards)
-    arranged_hand.gsub!(/((A\S).*)\2/, &quot;\\1&quot;)
-
-    # cleanup white space
-    arranged_hand.gsub!(/\s+/, ' ')
-    # careful to use gsub as gsub! can return nil here
-    arranged_hand.gsub(/\s+$/, '')
-  end
-  
-end
\ No newline at end of file
+$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__))   # For use/testing when no gem is installed
+require 'ruby-poker/card'
+require 'ruby-poker/poker_hand'
\ No newline at end of file</diff>
      <filename>lib/ruby-poker.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,4 @@
-require 'test/unit'
-require 'card.rb'
+require File.expand_path(File.dirname(__FILE__) + '/test_helper')
 
 class TestCard &lt; Test::Unit::TestCase
   def setup</diff>
      <filename>test/test_card.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,4 @@
-require 'ruby-poker.rb'
-require 'rubygems'
-require 'shoulda'
+require File.expand_path(File.dirname(__FILE__) + '/test_helper')
 
 class TestPokerHand &lt; Test::Unit::TestCase
   context &quot;A PokerHand instance&quot; do</diff>
      <filename>test/test_poker_hand.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>lib/card.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>1979f176afea0c3334bff23718649eceb68f6667</id>
    </parent>
  </parents>
  <author>
    <name>Robert Olson</name>
    <email>rob@thinkingdigitally.com</email>
  </author>
  <url>http://github.com/robolson/ruby-poker/commit/c8bc877890769af9674be05449da0b89eddd6c94</url>
  <id>c8bc877890769af9674be05449da0b89eddd6c94</id>
  <committed-date>2009-07-12T01:20:02-07:00</committed-date>
  <authored-date>2009-07-12T01:20:02-07:00</authored-date>
  <message>Reorganized ruby-poker's lib folder to match the standard layout for gems. This makes ruby-poker compatible with Rip.</message>
  <tree>afa17242a8cd0c64fa6af1d557b4a77b4d9283ab</tree>
  <committer>
    <name>Robert Olson</name>
    <email>rob@thinkingdigitally.com</email>
  </committer>
</commit>
