Skip to content

Commit

Permalink
implement and tests for walker.each
Browse files Browse the repository at this point in the history
  • Loading branch information
schacon committed Dec 7, 2010
1 parent ad27cf2 commit 4c9dcdb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/rugged.rb
Expand Up @@ -5,3 +5,4 @@
require 'rugged/tree'
require 'rugged/tree_entry'
require 'rugged/version'
require 'rugged/walker'
12 changes: 12 additions & 0 deletions lib/rugged/walker.rb
@@ -0,0 +1,12 @@
module Rugged
class Walker
include Enumerable

def each
while commit = self.next
yield commit
end
end

end
end
6 changes: 6 additions & 0 deletions test/walker_test.rb
Expand Up @@ -45,6 +45,12 @@
assert_equal sha, @walker.next.sha
end

test "can enumerable" do
@walker.push("9fd738e8f7967c078dceed8190330fc8648ee56a")
enum = @walker.sort { |a, b| a.sha <=> b.sha }.map { |a| a.sha[0, 4] }.join('.')
assert_equal "4a20.5b5b.8496.9fd7", enum
end

def do_sort(sorting)
sha = "a4a7dce85cf63874e984719f4fdd239f5145052f"
@walker.sorting(sorting)
Expand Down

0 comments on commit 4c9dcdb

Please sign in to comment.