class Trekky
Public Class Methods
new(source_dir)
click to toggle source
# File lib/trekky.rb, line 6 def initialize(source_dir) @context = Context.new(source_dir) end
Public Instance Methods
render_to(target_dir)
click to toggle source
# File lib/trekky.rb, line 10 def render_to(target_dir) @context.sources.each do |source| path = target_path(target_dir, source) output = source.render output = source.render_errors unless source.valid? STDOUT.puts "Writing #{source.path} to #{path}" write(output, path) end end
Private Instance Methods
target_path(target_dir, source)
click to toggle source
# File lib/trekky.rb, line 22 def target_path(target_dir, source) path = File.join(target_dir, source.path.gsub(@context.source_dir, '')) if type = source.type path.gsub(/\.#{type}/, '') else path end end
write(output, path)
click to toggle source
# File lib/trekky.rb, line 31 def write(output, path) FileUtils.mkdir_p(File.dirname(path)) File.open(path, "wb") {|f| f.write(output) } end