Class: FileFeeder
- Inherits:
-
Object
- Object
- FileFeeder
- Includes:
- Enumerable
- Defined in:
- lib/ruby_diff/file_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 --file old_version.rb --file new_version.rb
ruby_diff --file old_dir/ --file new_dir
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) ⇒ FileFeeder
constructor
Expects something in the form of PATH –file [PATH].
Constructor Details
#initialize(path) ⇒ FileFeeder
Expects something in the form of PATH
--file [PATH]
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ruby_diff/file_feeder.rb', line 15 def initialize(path) @path = path if path =~ /^\s+$/ @file_pattern = "**/*.rb" elsif File.file? path @file_pattern = path else @file_pattern = File.join(path, "**/*.rb") end @files = Dir[@file_pattern] end |
Instance Attribute Details
#files ⇒ Object
Returns the value of attribute files.
8 9 10 |
# File 'lib/ruby_diff/file_feeder.rb', line 8 def files @files end |
#path ⇒ Object
Returns the value of attribute path.
9 10 11 |
# File 'lib/ruby_diff/file_feeder.rb', line 9 def path @path end |
Instance Method Details
#each ⇒ Object
28 29 30 31 32 |
# File 'lib/ruby_diff/file_feeder.rb', line 28 def each @files.each do |file| yield(open(file, 'r'){|io| io.read}, file) end end |