Class: Nbuild::FileFilter
- Inherits:
-
Object
- Object
- Nbuild::FileFilter
- Defined in:
- lib/nbuild/file_filter.rb
Instance Method Summary collapse
- #filter(from, to) ⇒ Object
-
#initialize(replacements) ⇒ FileFilter
constructor
A new instance of FileFilter.
Constructor Details
#initialize(replacements) ⇒ FileFilter
Returns a new instance of FileFilter.
5 6 7 |
# File 'lib/nbuild/file_filter.rb', line 5 def initialize replacements @replacements = replacements end |
Instance Method Details
#filter(from, to) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/nbuild/file_filter.rb', line 9 def filter from, to FileUtils.mkdir_p(File.dirname(to)) File.open(from) do |io_in| File.open(to, 'w') do |io_out| io_in.each do |line| @replacements.each {|k, v| line.gsub!(k, v)} io_out.puts line end end end end |