Sha256: 2571815a5eaa7bad84099e4761bc6a8aa4c5d4240370da4eb54258c21a84250b
Contents?: true
Size: 1.25 KB
Versions: 2
Compression:
Stored size: 1.25 KB
Contents
require 'find' module Frank class Output < Frank::Base include Frank::Render attr_accessor :static_folder, :dynamic_folder, :templates, :output_folder, :proj_dir def initialize(&block) instance_eval &block @output_path = File.join(@proj_dir, @output_folder) end def compile_templates dir = File.join( @proj_dir, @dynamic_folder ) Find.find(dir) do |path| if FileTest.file?(path) and !File.basename(path).match(/^\./) path = path[ dir.size + 1 ..-1 ] name, ext = name_ext(path) new_ext = reverse_ext_lookup(ext) new_file = File.join( @output_folder, "#{name}.#{new_ext}") FileUtils.makedirs(new_file.split('/').reverse[1..-1].reverse.join('/')) File.open(new_file, 'w') {|f| f.write render_path(path) } puts "Create #{name}.#{new_ext}" end end end def copy_static puts "Copying over your static content" static_folder = File.join(@proj_dir, @static_folder) FileUtils.cp_r(static_folder, @output_path) end def dump FileUtils.mkdir(@output_path) puts "Create #{@output_folder}" compile_templates copy_static end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
frank-0.1.1 | lib/frank/output.rb |
frank-0.1.0 | lib/frank/output.rb |