Sha256: f5ebcf1786afa761308409561c3f61b479805393eecf197c4d91e508eb65e09b

Contents?: true

Size: 916 Bytes

Versions: 4

Compression:

Stored size: 916 Bytes

Contents

require "#{File.dirname(__FILE__)}/through_ryoku"

module I18nTranslationGeneratorModule
  class ErbExecuter
    def exec_erb(filename)
      begin
#         ERB.new(File.read(f)).result
        (m = Module.new).module_eval <<-EOS
          class Executer
            extend ERB::DefMethod
            include ActionView::Helpers::TranslationHelper
            include I18nTranslationGeneratorModule::ThroughRyoku

            fname = '#{filename}'
            erb = nil
            File.open(fname) {|f| erb = ERB.new(f.read, nil, '-') }
            erb.def_method(self, 'execute', fname)
          end
        EOS
        nil.class_eval {def method_missing(method, *args, &block); nil; end}
        m.const_get('Executer').new.execute { }
      rescue => e
        p e
        # do nothing
      ensure
        nil.class_eval {undef :method_missing} if nil.respond_to? :method_missing
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
amatsuda-i18n_generators-0.5.0 generators/i18n_translation/lib/erb_executer.rb
amatsuda-i18n_generators-0.6.0 generators/i18n_translation/lib/erb_executer.rb
i18n_generators-0.8.1 generators/i18n_translation/lib/erb_executer.rb
i18n_generators-0.8.0 generators/i18n_translation/lib/erb_executer.rb