Sha256: 669b5ddba145d6bcac018ad22750058609305d70adf05b4d71c2c59157e3cbd6

Contents?: true

Size: 1000 Bytes

Versions: 51

Compression:

Stored size: 1000 Bytes

Contents

  module Sed

    def self.copy(source, target, pattern, replacement)
      if not File.file? source
        $log.writer.error "File #{source} does not exists"
        exit 1
      end
  
      File.open(source, "r:UTF-8") do |source_file|
        content = source_file.read
        content.gsub!(pattern, replacement)
        File.open(target, "w:UTF-8") do |target_file|
          target_file.write(content)
          target_file.close
        end
        source_file.close
      end

    end

    def self.patch(filename, pattern, replacement)
      if not File.file? filename
        $log.writer.error "File #{filename} does not exists"
        exit 1
      end

      content = ""
      File.open(filename, "r:UTF-8") do |source_file|
        content = source_file.read
        content.gsub!(pattern, replacement)
        source_file.close
      end
      File.open(filename, "w:UTF-8") do |target_file|
        target_file.write(content)
        target_file.close
      end

    end
    
  end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
depengine-3.0.20 lib/depengine/processor/sed.rb
depengine-3.0.19 lib/depengine/processor/sed.rb
depengine-3.0.18 lib/depengine/processor/sed.rb
depengine-3.0.17 lib/depengine/processor/sed.rb
depengine-3.0.16 lib/depengine/processor/sed.rb
depengine-3.0.15 lib/depengine/processor/sed.rb
depengine-3.0.14 lib/depengine/processor/sed.rb
depengine-3.0.13 lib/depengine/processor/sed.rb
depengine-3.0.12 lib/depengine/processor/sed.rb
depengine-3.0.11 lib/depengine/processor/sed.rb
depengine-3.0.10 lib/depengine/processor/sed.rb
depengine-3.0.9 lib/depengine/processor/sed.rb
depengine-3.0.8 lib/depengine/processor/sed.rb
depengine-3.0.7 lib/depengine/processor/sed.rb
depengine-3.0.6 lib/depengine/processor/sed.rb
depengine-3.0.5 lib/depengine/processor/sed.rb
depengine-3.0.4 lib/depengine/processor/sed.rb
depengine-3.0.3 lib/depengine/processor/sed.rb
depengine-3.0.2 lib/depengine/processor/sed.rb
depengine-3.0.1 lib/depengine/processor/sed.rb