class StaticFileSaver
Attributes
document[RW]
path[RW]
Public Class Methods
new(ember_path, document)
click to toggle source
# File lib/static_file_saver.rb, line 4 def initialize(ember_path, document) self.path = static_file_path_for(ember_path) self.document = document end
Public Instance Methods
save()
click to toggle source
# File lib/static_file_saver.rb, line 9 def save create_directory create_file end
Private Instance Methods
create_directory()
click to toggle source
# File lib/static_file_saver.rb, line 22 def create_directory FileUtils.mkdir_p(File.dirname(@path)) end
create_file()
click to toggle source
# File lib/static_file_saver.rb, line 16 def create_file File.open(@path + ".html", "w+") do |f| f.write(@document.to_s) end end
static_file_path_for(path)
click to toggle source
# File lib/static_file_saver.rb, line 26 def static_file_path_for(path) file_name = path.gsub("#!",'') file_name << 'index' if path[path.length-1] == '/' "public/static" + file_name end