Sha256: 534b5788b29885e42fe0228bdaf37f3eb587cb5fb3c6d672326904836b2a78ec
Contents?: true
Size: 1.36 KB
Versions: 5
Compression:
Stored size: 1.36 KB
Contents
#!/usr/bin/env ruby require 'tins/go' include Tins::GO require 'tins/secure_write' include Tins::SecureWrite require 'tins/find' include Tins::Find require 'utils' class ::File include Utils::FileXt end def usage puts <<-EOT Usage: #{File.basename($0)} [OPTS] [PATHS] PATHS are the directory and file paths that are search for files to be stripped. Options are -I SUFFIXES list of suffixes -h display this help Version is #{File.basename($0)} #{Utils::VERSION}. EOT exit 1 end args = go 'I:h' args['h'] and usage paths = ARGV.empty? ? %w[.] : ARGV paths = paths.map { |p| File.expand_path(p) } suffix = args['I'].ask_and_send(:split, /[\s,]+/).to_a config = Utils::Config::ConfigFile.new config.parse_config_file File.expand_path('~/.utilsrc') find(*(paths + [ { :suffix => suffix} ])) do |filename| bn, s = File.basename(filename), File.stat(filename) s.symlink? and next if s.directory? config.strip_spaces.prune?(bn) and prune next end s.file? or next config.strip_spaces.skip?(bn) and next File.ascii?(filename) or next STDOUT.puts "Stripping spaces from #{filename.inspect}." secure_write(filename) do |output| File.open(filename) do |file| old_mode = file.stat.mode file.each do |line| line.gsub!(/[ \t\v]+$/, '') output.write line end File.chmod old_mode, output.path end end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
utils-0.0.54 | bin/strip_spaces |
utils-0.0.53 | bin/strip_spaces |
utils-0.0.52 | bin/strip_spaces |
utils-0.0.51 | bin/strip_spaces |
utils-0.0.50 | bin/strip_spaces |