Module: Vebdew::Runner
- Defined in:
- lib/vebdew/runner.rb
Class Method Summary collapse
Class Method Details
.compile(vew, erb, html) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/vebdew/runner.rb', line 37 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(project) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/vebdew/runner.rb', line 7 def create project if File.exist?(project) puts "The project already exists! Abort ..." else dir = File.join File.dirname(__FILE__), "../template/*" dst = FileUtils.mkdir project Dir[File. dir].each do |file| FileUtils.cp_r file, File.join(Dir.pwd, project) end puts "Vebdew project generated!" end end |
.generate ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/vebdew/runner.rb', line 20 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 |