Module: OrgMode::FileTools

Extended by:
FileUtils, FileTools
Included in:
FileTools
Defined in:
lib/org_mode/file_tools.rb

Instance Method Summary collapse

Instance Method Details

#backup(file) ⇒ Object



7
8
9
10
# File 'lib/org_mode/file_tools.rb', line 7

def backup(file)
  mkdir_p backup_dir unless File.exist?(backup_dir)
  cp file, add_unique_extention(backup_path(file))
end

#backup_dirObject



24
25
26
# File 'lib/org_mode/file_tools.rb', line 24

def backup_dir
  OrgMode::Configuration.backup_dir
end

#backup_path(file) ⇒ Object



19
20
21
# File 'lib/org_mode/file_tools.rb', line 19

def backup_path(file)
  backup_dir + ::File.basename(file)
end

#spit_into_file(buffer, file) ⇒ Object



12
13
14
15
16
17
# File 'lib/org_mode/file_tools.rb', line 12

def spit_into_file(buffer, file)
  File.open(file, 'w') do |f|
   f.write(buffer) 
   f.flush
  end
end