Sha256: d53cb97817b57aa902e2b3d0c71c08473a25ce063236742bbd4b25396c8b4fe8
Contents?: true
Size: 891 Bytes
Versions: 2
Compression:
Stored size: 891 Bytes
Contents
# forked from http://github.com/dkubb/dm-dev namespace :st do desc 'Strip trailing whitespace from source files, also normalize tabs to spaces, and an newline at end of file' task :strip, :spaces, :glob do |t, args| require 'source-tools' require 'zlib' spaces = ' ' * (args[:spaces] || 2).to_i kind = if args[:glob] [:glob, args[:glob]] else [:each_source_path] end SourceTools.send(*kind){ |path| # strat striping unnecessary whitespaces result = path.open('r:binary'){ |f| SourceTools.strip(f, spaces) } # skip the file if it was not modified next if Zlib.crc32(result) == Zlib.crc32(path.read) puts "Stripping #{args[:glob] ? path : path.relative_path_from(Pathname.new(Dir.pwd))}" path.open('w'){ |f| f.write result } } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
source-tools-0.6.1 | lib/source-tools/tasks/strip.rb |
source-tools-0.6.0 | lib/source-tools/tasks/strip.rb |