Commit 31a54bdac65e2cc5ed188a3ebe52cee416424256
- Date: Fri Jun 29 03:26:12 +0000 2007
- Committer: fbos (fbos@d6c2ea82-c31b-0410-8381-e9c44f9824c5)
- Author: fbos (fbos@d6c2ea82-c31b-0410-8381-e9c44f9824c5)
- Commit SHA1: 31a54bdac65e2cc5ed188a3ebe52cee416424256
- Tree SHA1: e305b8c8a1b1678f5d2135d83457208bc1b2a4fa
New Piston::Repository#exists? to determine if the repository is accessible.
git-svn-id: svn+ssh://rubyforge.org/var/svn/piston/trunk@117 d6c2ea82-c31b-0410-8381-e9c44f9824c5
Commit diff
| |   |
| 34 | 34 | end |
| 35 | 35 | end |
| 36 | 36 | |
| 37 | def exist? |
| 38 | case self.info |
| 39 | when Hash |
| 40 | !!self.info["Repository UUID"] |
| 41 | else |
| 42 | false |
| 43 | end |
| 44 | end |
| 45 | |
| 46 | alias_method :exists?, :exist? |
| 47 | |
| 37 | 48 | def local_path |
| 38 | 49 | @url.to_s["file://".length .. -1] |
| 39 | 50 | end |
| toggle raw diff |
--- a/lib/piston/repository.rb
+++ b/lib/piston/repository.rb
@@ -34,6 +34,17 @@ module Piston
end
end
+ def exist?
+ case self.info
+ when Hash
+ !!self.info["Repository UUID"]
+ else
+ false
+ end
+ end
+
+ alias_method :exists?, :exist?
+
def local_path
@url.to_s["file://".length .. -1]
end
|
| |   |
| 14 | 14 | it "should NOT raise an error if the URL is a URI object" do |
| 15 | 15 | Piston::Repository.new(URI.parse("http://svn.repository.org/repos")) |
| 16 | 16 | end |
| 17 | |
| 18 | it "should report it does not exist when used on a repository which does not exist" do |
| 19 | Piston::Repository.new("file:///path/to/some/repos").should_not exist |
| 20 | end |
| 21 | |
| 22 | it "should report it exists when used on a repository which was created" do |
| 23 | @repos = Piston::Repository.new("file://#{File.expand_path(File.dirname(__FILE__))}/tmp/repos") |
| 24 | @repos.create! |
| 25 | @repos.should exist |
| 26 | end |
| 17 | 27 | end |
| 18 | 28 | |
| 19 | 29 | describe Piston::Repository, "with a file:/// URL" do |
| toggle raw diff |
--- a/spec/repository_spec.rb
+++ b/spec/repository_spec.rb
@@ -14,6 +14,16 @@ describe Piston::Repository do
it "should NOT raise an error if the URL is a URI object" do
Piston::Repository.new(URI.parse("http://svn.repository.org/repos"))
end
+
+ it "should report it does not exist when used on a repository which does not exist" do
+ Piston::Repository.new("file:///path/to/some/repos").should_not exist
+ end
+
+ it "should report it exists when used on a repository which was created" do
+ @repos = Piston::Repository.new("file://#{File.expand_path(File.dirname(__FILE__))}/tmp/repos")
+ @repos.create!
+ @repos.should exist
+ end
end
describe Piston::Repository, "with a file:/// URL" do
|