Class: ZAWS::Helper::ZFile

Inherits:
Object
  • Object
show all
Defined in:
lib/zaws/helper/zfile.rb

Class Method Summary collapse

Class Method Details

.prepend(command, description, filepath) ⇒ Object

This prepend function not currently unit tested, see “thor/spec/actions/file_manipulation_spec” for ideas on how to accomplish this.



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/zaws/helper/zfile.rb', line 8

def self.prepend(command,description,filepath)
     new_file=filepath + ".new"
     File.open(new_file, 'w') do |fo|
       fo.puts description
       fo.puts command
       File.foreach(filepath) do |li|
         fo.puts li
       end
     end
       File.rename(new_file, filepath)
end