Module: Vebdew::Runner
- Defined in:
- lib/vebdew/runner.rb
Class Method Summary collapse
Class Method Details
.compile(vew, erb, html) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/vebdew/runner.rb', line 32 def compile vew, erb, html if !File.exist?(vew) puts "Vew file doesn't exist!" elsif !File.exist?(erb) puts "Erb template doesn't exist!" else parser = Parser.new(IO.readlines(vew)) result = Formatter.new(parser, File.read(erb)).to_html File.open(html, "w") { |f| f.write result } end end |
.create ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/vebdew/runner.rb', line 7 def create dir = File.join File.dirname(__FILE__), "../template/*" Dir[File. dir].each do |file| FileUtils.cp_r file, Dir.pwd end puts "Vebdew project generated!" end |
.generate ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/vebdew/runner.rb', line 15 def generate vew = File.join Dir.pwd, "vew" temp = File.join vew, "template.erb" if !File.exist?(vew) or !File.directory?(vew) puts "Is this a Vebdew project? 'vew' directory does not exist!" elsif !File.exist?(temp) puts "The template file 'vew/template.erb' does not exist!" else Dir[File.join vew, "*.vew"].each do |file| html = File.basename(file, ".vew") + ".html" compile file, temp, File.join(Dir.pwd, html) puts "#{html} compiled!" end end end |