Commit 8dd60ef9740042cf5e30e40a2ba2c87ebcad201b

New WorkingCopy#cat, #down and #up.

git-svn-id: svn+ssh://rubyforge.org/var/svn/piston/trunk@128 d6c2ea82-c31b-0410-8381-e9c44f9824c5

Commit diff

lib/piston/working_copy.rb

 
66module Piston
77 # Represents a Subversion working copy.
88 class WorkingCopy
9 class FileNotFound < StandardError
10 def initialize(path)
11 super "File #{path.inspect} could not found"
12 end
13 end
14
915 include Piston::SubversionClient
1016
1117 attr_reader :dir, :path
146146 @info ||= YAML.load(svn(:info, wc_path(self.dir)))
147147 end
148148
149 def parent
149 def down(folder) #:nodoc:
150 self.class.new(self.path + folder, :logger => self.logger)
151 end
152
153 def up #:nodoc:
150154 self.class.new(self.path + "..", :logger => self.logger)
151155 end
152156
172172 FileUtils.rm_rf(@dir)
173173 end
174174
175 # Reads the file at +path+ and returns the contents.
176 # Raises a FileNotFound exception unless the file is accessible.
177 def cat(path) #:nodoc:
178 file = wc_path(path)
179 raise FileNotFound.new(file) unless File.exist?(file)
180 File.read(file)
181 end
182
175183 # Ensures +repos_url+ is a URL string or URI object and raises an ArgumentError if not.
176184 def is_a_url?(repos_url) #:nodoc:
177185 case repos_url
toggle raw diff