Sha256: c7305223f18060b00e13f3f4a30b39e4ea7b0e59d14298a11436e4f8b69e74a6

Contents?: true

Size: 674 Bytes

Versions: 3

Compression:

Stored size: 674 Bytes

Contents

#!/usr/bin/env ruby

require 'spruz/secure_write'
include Spruz::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) }

find(*pathes) do |path|
  File.basename(path) =~ /\A\./ and prune
  File.directory?(path) and next
  File.ascii?(path) or next
  STDOUT.puts "Stripping spaces from #{path.inspect}."
  secure_write(path) do |output|
    File.open(path) 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

3 entries across 3 versions & 1 rubygems

Version Path
utils-0.0.18 bin/strip_spaces
utils-0.0.17 bin/strip_spaces
utils-0.0.16 bin/strip_spaces