module FindAndClean

Public Instance Methods

all_files(root = Dir.pwd) click to toggle source
# File lib/fundler/find_and_clean.rb, line 23
def all_files(root = Dir.pwd)
  files = Dir.open(root).reject { |file| FileTest.directory? file }
  files_found = files.select do |file| 
    file !=~ /^\./ 
  end
  files_found.sort
end
clean_all_filenames(root = Dir.pwd) click to toggle source
# File lib/fundler/find_and_clean.rb, line 31
def clean_all_filenames(root = Dir.pwd)
  renamed = []
  self.all_files(root).each do |file|
    new_name = file.downcase.gsub(/\s+/, '_')
    File.rename(file, new_name)
    renamed << new_name
  end
  renamed.count
end
get_list() click to toggle source
# File lib/fundler/find_and_clean.rb, line 45
def get_list
  out = ""
  all_files.each do |file|
    out << "- " << File.absolute_path(file)
    out << " | " << File.atime(file).to_s
    out << " | " << File.size(file).to_s
    out << "\n"
  end
  puts out
end
get_pwd() click to toggle source
# File lib/fundler/find_and_clean.rb, line 41
def get_pwd
  Dir.pwd
end
ruby_files(root = Dir.pwd) click to toggle source

Finds all Ruby source files under the current or other supplied directory. A Ruby source file is defined as a file with the `.rb` extension or a file with no extension that has a ruby shebang line as its first line. @param root Root directory under which to search for ruby source files @return [Array] Array of filenames

# File lib/fundler/find_and_clean.rb, line 12
def ruby_files(root = Dir.pwd)
  files = Dir.open(root).reject { |file| FileTest.directory? file }
  rb_files = []
  rb_files << files.select { |file| File.extname(file) == '.rb' }
  rb_files << files.select do |file|
    File.extname(file) == '' &&
    File.open(file) { |f| f.readline } =~ /#!.*ruby/
  end
  rb_files.flatten.sort
end