Sha256: 611b0ccd6fe4094fa7674dc4b73a76206535fc75ad39dab32b9110452187a447

Contents?: true

Size: 336 Bytes

Versions: 4

Compression:

Stored size: 336 Bytes

Contents

module Semmy
  module Files
    module_function

    def rewrite(path, update)
      content = File.binread(path)

      File.open(path, 'wb') do |file|
        file.write(update.call(content))
      end
    end

    def rewrite_all(glob, update)
      Dir.glob(glob) do |path|
        rewrite(path, update)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
semmy-0.3.0 lib/semmy/files.rb
semmy-0.2.1 lib/semmy/files.rb
semmy-0.2.0 lib/semmy/files.rb
semmy-0.1.0 lib/semmy/files.rb