lib/auto_rails_cleanup/cleaner.rb
# delete one method at a time and test
# using `sed '7,9d' ./file` to remove lines, seems to only soemtimes work, moving to awk
delete one method at a time and test
using `sed '7,9d' ./file` to remove lines, seems to only soemtimes work, moving to awk
delete one method at a time and test using ` sed ' 7 9d ' . / file ` to remove lines seems to only soemtimes work moving to awk
def next_run
    file_method_data = methods_data.pop
    return unless file_method_data
    file = file_method_data.shift
    filename = file.sub('./', (project_dir + '/'))
    return next_run if !File.exists?(filename) || File.directory?(filename)
    method_name = file_method_data.first[:method_name]
    starting_line = file_method_data.first[:starting_line]
    ending_line = file_method_data.first[:ending_line]
    Dir.chdir(project_dir) do
      `awk -v m=#{starting_line} -v n=#{ending_line} 'm <= NR && NR <= n {next} {print}' #{filename} > #{project_dir + '/tmp/replace.txt'}; mv #{project_dir + '/tmp/replace.txt'} #{filename}`
      `#{ENV['CLEANUP_PROCESS']}` if ENV['CLEANUP_PROCESS']
      `git commit -a -m "removed #{short_name(filename)} method #{method_name}"`
      `git push origin #{BRANCH}` if remote
    end
    file
  end
def next_run file_method_data = methods_data . pop return unless file_method_data file = file_method_data . shift filename = file . sub ( './' , ( project_dir + '/' ) ) return next_run if ! File . exists? ( filename ) || File . directory? ( filename ) method_name = file_method_data . first [ :method_name ] starting_line = file_method_data . first [ :starting_line ] ending_line = file_method_data . first [ :ending_line ] Dir . chdir ( project_dir ) do ` awk -v m= #{ starting_line }  -v n= #{ ending_line }  'm <= NR && NR <= n {next} {print}'  #{ filename }  >  #{ project_dir + '/tmp/replace.txt' } ; mv  #{ project_dir + '/tmp/replace.txt' } #{ filename } ` ` #{ ENV [ 'CLEANUP_PROCESS' ] } ` if ENV [ 'CLEANUP_PROCESS' ] ` git commit -a -m "removed  #{ short_name ( filename ) }  method  #{ method_name } " ` ` git push origin  #{ BRANCH } ` if remote end file end
delete one method at a time and test
using `sed '7,9d' ./file` to remove lines, seems to only soemtimes work, moving to awk
delete one method at a time and test using ` sed ' 7 9d ' . / file ` to remove lines seems to only soemtimes work moving to awk
# normalize to full file path