Sha256: 65e9d1dd8d163250d4c9d1ab0547190ec3d6ae8a323b9265549711a6295ca245

Contents?: true

Size: 466 Bytes

Versions: 2

Compression:

Stored size: 466 Bytes

Contents

namespace :st do
  desc 'Add magic comment for source encoding for ruby 1.9'
  task :ruby_magic_encoding, :glob, :encoding do |t, args|
    encoding = args[:encoding] || 'utf-8'

    SourceTools.glob(args[:glob]){ |path|
      header = path.readlines.first
      next if header =~ /\A# ?encoding:/
      content = path.read

      puts "Processing #{path}"
      SourceTools.wrap_source( path, content,
        :header => "# encoding: #{encoding}")
    }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
source-tools-0.6.1 lib/source-tools/tasks/ruby_magic_encoding.rb
source-tools-0.6.0 lib/source-tools/tasks/ruby_magic_encoding.rb