Sha256: 2239cc48125460cdc98bcf819a6b136316826bcdb587a8c20f347a78a1aa0b51

Contents?: true

Size: 877 Bytes

Versions: 4

Compression:

Stored size: 877 Bytes

Contents

require 'rubygems'
require 'rake/clean'
require 'ludy'
Ludy.require_all_in 'tasks/erb_cpp'

namespace :erb do

  inputs = FileList['**/*.erb']
  outputs = inputs.ext
  CLEAN.include outputs

  desc 'automaticly translate all *.cpp.erb into *.cpp'
  task :preprocess => [:begin, outputs, :end].flatten
  task :begin do; puts "processing templates: #{inputs.inspect}\n\n"; end
  task :end do; puts "processing done."; end

  require 'erb'
  require 'open-uri'

  inputs.zip(outputs).each{ |input, output|
    file output => input do
      puts "processing... #{output}"
      open output, 'w' do |o|
        @class = output.pathmap '%n'
        @dir = output.pathmap('%-1d')
        @indent = '    '
        @prefix = ''
        PROJ ||= 'please_set_PROJ_for_your_header_name'
        o << ERB.new(open(input).read).result(binding)
      end
    end
  }

end # of namespace erb

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ludy-0.1.0 lib/ludy/tasks/erb_cpp.rb
ludy-0.1.1 lib/ludy/tasks/erb_cpp.rb
ludy-0.1.2 lib/ludy/tasks/erb_cpp.rb
ludy-0.1.3 lib/ludy/tasks/erb_cpp.rb