From a6015edab44b9c7e72fb381b6ca84e2232873469 Mon Sep 17 00:00:00 2001 From: Voker57 Date: Tue, 17 Feb 2009 23:52:15 +0300 Subject: [PATCH 1/3] Fixed gem builing --- Rakefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Rakefile b/Rakefile index ba94b12..a59b002 100644 --- a/Rakefile +++ b/Rakefile @@ -3,6 +3,7 @@ require 'rake/testtask' require 'rake/rdoctask' begin + require 'rubygems' require 'jeweler' Jeweler::Tasks.new do |s| s.name = "grit" @@ -51,4 +52,4 @@ end desc "Upload site to Rubyforge" task :site do sh "scp -r doc/* mojombo@grit.rubyforge.org:/var/www/gforge-projects/grit" -end \ No newline at end of file +end From dbfeb5ce9b997a15cd6d13e11dccd7c274f56855 Mon Sep 17 00:00:00 2001 From: Voker57 Date: Tue, 17 Feb 2009 23:54:45 +0300 Subject: [PATCH 2/3] Added two shortcut methods, for picking trees/blobs only --- lib/grit/tree.rb | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/lib/grit/tree.rb b/lib/grit/tree.rb index 832ba28..2fe7083 100644 --- a/lib/grit/tree.rb +++ b/lib/grit/tree.rb @@ -94,11 +94,26 @@ module Grit self.contents.find { |c| c.name == file } end end - + # Pretty object inspection def inspect %Q{#} end + + # Find only Tree objects from contents + def trees + contents.select {|v| v.kind_of? Tree} + end + + # Find only Blob objects from contents + def blobs + contents.select {|v| v.kind_of? Blob} + end + + # Compares trees by name + def <=>(other) + name <=> other.name + end end # Tree - + end # Grit From d34d5300bc1955d93928b6b2544fb79e89aaa06a Mon Sep 17 00:00:00 2001 From: Voker57 Date: Tue, 17 Feb 2009 23:55:18 +0300 Subject: [PATCH 3/3] Added <=> method, needed for sorting tree --- lib/grit/blob.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/grit/blob.rb b/lib/grit/blob.rb index 3fb4076..dd161c1 100644 --- a/lib/grit/blob.rb +++ b/lib/grit/blob.rb @@ -104,14 +104,19 @@ module Grit info = nil end end - + blames end - + # Pretty object inspection def inspect %Q{#} end + + # Compares blobs by name + def <=>(other) + name <=> other.name + end end # Blob - + end # Grit \ No newline at end of file