Sha256: 230cb9925446caa63121fd0562328d0ac21f9333f0f10444e3b9ee11fcb043e0

Contents?: true

Size: 773 Bytes

Versions: 4

Compression:

Stored size: 773 Bytes

Contents

class FeatureCompiler
  def compile
    require 'yaml'
    require 'erb'
    tt = PLATFORM =~ /win32/ ? 'tt.bat' : 'tt'

    template = ERB.new(IO.read(File.dirname(__FILE__) + '/../lib/cucumber/treetop_parser/feature.treetop.erb'))
    langs = YAML.load_file(File.dirname(__FILE__) + '/../lib/cucumber/languages.yml')

    langs.each do |lang, words|
      grammar_file = File.dirname(__FILE__) + "/../lib/cucumber/treetop_parser/feature_#{lang}.treetop"
      grammar = template.result(binding)
      File.open(grammar_file, "wb") do |io|
        io.write(grammar)
      end
      sh "#{tt} #{grammar_file}"
      FileUtils.rm(grammar_file)
    end
  end
end

namespace :treetop do
  desc 'Compile the grammar'
  task :compile do
    FeatureCompiler.new.compile
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
aslakhellesoy-cucumber-0.1.1 gem_tasks/treetop.rake
aslakhellesoy-cucumber-0.1.2 gem_tasks/treetop.rake
aslakhellesoy-cucumber-0.1.3 gem_tasks/treetop.rake
aslakhellesoy-cucumber-0.1.4 gem_tasks/treetop.rake