lib/buildmaster/svn_driver.rb in BuildMaster-0.7.0 vs lib/buildmaster/svn_driver.rb in BuildMaster-0.8.0
- old
+ new
@@ -1,22 +1,34 @@
+require 'stringio'
require 'rexml/document'
module BuildMaster
class SvnInfo
- attr_reader :path, :repository_root
-
- def initialize(path)
- @path = path
- analyze_entry_file(File.join(path, ".svn", "entries"))
+ attr_reader :path, :repository_root
+
+ def initialize(path)
+ @path = path
+ analyze_entry_file(File.join(path, ".svn", "entries"))
+ end
+
+ def analyze_entry_file(path)
+ content = load_content(path)
+ xml = REXML::Document.new(content)
+ xml.root.each_element_with_attribute('name', '', 1) do |element|
+ @repository_root = element.attributes['repos']
end
-
- def analyze_entry_file(file)
- xml = REXML::Document.new(File.open(file))
- xml.root.each_element_with_attribute('name', '', 1) do |element|
- @repository_root = element.attributes['repos']
- end
+ end
+
+ def load_content(path)
+ buffer = StringIO.new
+ File.open(path, 'r') do |file|
+ while (line = file.gets)
+ buffer.puts(line)
+ end
end
+ return buffer.string
+ end
end
class SvnDriver
include Shell
\ No newline at end of file