Class: File
- Inherits:
-
Object
- Object
- File
- Defined in:
- lib/gem_modifier.rb
Overview
remove #require remove #autoload generate and add manifest to front of file add version.rb and config.rb files convert eval to module, instance or class eval eval def to define method #binding not support
Class Method Summary collapse
Class Method Details
.prepend(path, string) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/gem_modifier.rb', line 16 def self.prepend(path, string) Tempfile.open File.basename(path) do |tempfile| # shift string to tempfile tempfile << string File.open(path, 'r+') do |file| # append original data to tempfile tempfile << file.read # reset file positions file.pos = tempfile.pos = 0 # copy tempfile back to original file file << tempfile.read end end end |