Sha256: b3634dc96b1d896919d17a6475a8fb9febd232edb85efcc7d04cdf90af4dfe88
Contents?: true
Size: 927 Bytes
Versions: 4
Compression:
Stored size: 927 Bytes
Contents
#!/usr/bin/env ruby require 'tins/secure_write' include Tins::SecureWrite require 'utils' include Utils::Find class ::File include Utils::FileXt end pathes = ARGV.empty? ? %w[.] : ARGV pathes = pathes.map { |p| File.expand_path(p) } config = Utils::Config::ConfigFile.new config.parse_config_file File.expand_path('~/.utilsrc') find(*pathes) 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
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
utils-0.0.33 | bin/strip_spaces |
utils-0.0.32 | bin/strip_spaces |
utils-0.0.31 | bin/strip_spaces |
utils-0.0.30 | bin/strip_spaces |