diff --git a/Tools/Rake/quicktemplate.rb b/quicktemplate.rb similarity index 94% rename from Tools/Rake/quicktemplate.rb rename to quicktemplate.rb index 27074637a..a2324af7c 100644 --- a/Tools/Rake/quicktemplate.rb +++ b/quicktemplate.rb @@ -1,48 +1,48 @@ -require 'rake' -require 'erb' - -class QuickTemplate - attr_reader :args, :file - - def initialize(file) - raise "The template file to process must be given" if file.nil? - - @file = file - end - - def exec(args = {}) - template = prepare_template File.read(@file) - result = exec_erb template, args - - resultFile = @file.ext('') - File.open(resultFile, 'w') do - |f| f.write(result) - end - - puts "Created file #{resultFile}" - end - - def prepare_template(template) - tag_regex = /(@\w[\w\.]+\w@)/ - - hits = template.scan(tag_regex) - tags = hits.map do |item| - item[0].chomp('@').reverse.chomp('@').reverse.strip - end - - tags.map! do |a| - a.to_sym - end - tags.uniq! - - tags.inject(template) do |text, tag| - text.gsub /@#{tag.to_s}@/, "<%= #{tag.to_s} %>" - end - end - - def exec_erb(template, args) - b = binding - erb = ERB.new(template, 0, "%") - erb.result(b) - end +require 'rake' +require 'erb' + +class QuickTemplate + attr_reader :args, :file + + def initialize(file) + raise "The template file to process must be given" if file.nil? + + @file = file + end + + def exec(args = {}) + template = prepare_template File.read(@file) + result = exec_erb template, args + + resultFile = @file.ext('') + File.open(resultFile, 'w') do + |f| f.write(result) + end + + puts "Created file #{resultFile}" + end + + def prepare_template(template) + tag_regex = /(@\w[\w\.]+\w@)/ + + hits = template.scan(tag_regex) + tags = hits.map do |item| + item[0].chomp('@').reverse.chomp('@').reverse.strip + end + + tags.map! do |a| + a.to_sym + end + tags.uniq! + + tags.inject(template) do |text, tag| + text.gsub /@#{tag.to_s}@/, "<%= #{tag.to_s} %>" + end + end + + def exec_erb(template, args) + b = binding + erb = ERB.new(template, 0, "%") + erb.result(b) + end end \ No newline at end of file diff --git a/rakefile.rb b/rakefile.rb index 691e7c6d4..35f57980d 100644 --- a/rakefile.rb +++ b/rakefile.rb @@ -3,7 +3,7 @@ require 'albacore' require 'configatron' require 'fileutils' - require File.dirname(__FILE__) + "/Tools/Rake/quicktemplate.rb" + require './quicktemplate.rb' require './rakefile.include.rb' rescue LoadError