Class: SVNFeeder
- Inherits:
-
Object
- Object
- SVNFeeder
- Includes:
- Enumerable
- Defined in:
- lib/ruby_diff/svn_feeder.rb
Overview
A Feeder reads in files for RubyDiff’s processor to run over. FileFeeder reads them from the file system.
Example Usage:
ruby_diff --svn PREV:file.rb --svn new_version.rb
ruby_diff --svn http://project.server.org/lib --svn .
Instance Attribute Summary collapse
-
#files ⇒ Object
Returns the value of attribute files.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(path) ⇒ SVNFeeder
constructor
Expects something in the form of PATH –file [PATH].
-
#svn(command) ⇒ Object
issues a command to svn.
Constructor Details
#initialize(path) ⇒ SVNFeeder
Expects something in the form of PATH
--file [PATH]
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ruby_diff/svn_feeder.rb', line 15 def initialize(path) @path = path # TODO: Add support for SVN date format if @path =~ /^(\d+)|HEAD|BASE|COMMITTED|PREV\:/ parts = path.split(":",2) svn_path = parts.pop rev = parts.shift else svn_path = @path rev = nil end @svn_options = (rev ? "-r #{rev} " : " ")+svn_path @file_pattern = "**/*.rb" @files = [] svn("ls -R #{@svn_options}").each_line do |file| file.chomp! @files << file if File.fnmatch(@file_pattern, file) end end |
Instance Attribute Details
#files ⇒ Object
Returns the value of attribute files.
8 9 10 |
# File 'lib/ruby_diff/svn_feeder.rb', line 8 def files @files end |
#path ⇒ Object
Returns the value of attribute path.
9 10 11 |
# File 'lib/ruby_diff/svn_feeder.rb', line 9 def path @path end |
Instance Method Details
#each ⇒ Object
40 41 42 43 44 45 |
# File 'lib/ruby_diff/svn_feeder.rb', line 40 def each @files.each do |file| cat_path = File.join(@svn_options, file) yield(svn("cat #{cat_path}"), file) end end |
#svn(command) ⇒ Object
issues a command to svn
49 50 51 52 53 54 55 |
# File 'lib/ruby_diff/svn_feeder.rb', line 49 def svn command output = `svn #{command} 2>&1`.chomp unless $?.success? raise RuntimeError, output end output end |