Module: AsciiDataTools::ExternalPrograms

Included in:
Controller::EditController, Controller::QDiffController, Filter::Diffing::DiffExecutingFilter, Filter::SortingFilter
Defined in:
lib/ascii-data-tools/external_programs.rb

Instance Method Summary collapse

Instance Method Details

#diff(files) ⇒ Object



7
8
9
# File 'lib/ascii-data-tools/external_programs.rb', line 7

def diff(files)
  IO.popen(diff_command_for(files))
end

#diff_command_for(files) ⇒ Object



11
12
13
# File 'lib/ascii-data-tools/external_programs.rb', line 11

def diff_command_for(files)
  "diff " + files.collect(&:path).join(' ')
end

#edit_differences(filenames) ⇒ Object



19
20
21
# File 'lib/ascii-data-tools/external_programs.rb', line 19

def edit_differences(filenames)
  Kernel.system("vimdiff #{filenames.join(' ')}")
end

#modify_file_mtime_to(new_mtime) ⇒ Object



3
4
5
# File 'lib/ascii-data-tools/external_programs.rb', line 3

def modify_file_mtime_to(new_mtime)
  Kernel.system("touch -am -t #{new_mtime.strftime('%Y%m%d%H%M.%S')} #{self.path}")
end

#sort(input_file, output_file) ⇒ Object



15
16
17
# File 'lib/ascii-data-tools/external_programs.rb', line 15

def sort(input_file, output_file)
  Kernel.system("sort #{input_file.path} > #{output_file.path}")
end