class RugularHaml
Attributes
haml_file[R]
Public Class Methods
compile(haml_file)
click to toggle source
# File lib/rugular/tasks/server/guards/rugular_haml.rb, line 4 def self.compile(haml_file) new(haml_file).compile end
delete(haml_file)
click to toggle source
# File lib/rugular/tasks/server/guards/rugular_haml.rb, line 8 def self.delete(haml_file) new(haml_file).delete end
new(haml_file)
click to toggle source
# File lib/rugular/tasks/server/guards/rugular_haml.rb, line 12 def initialize(haml_file) @haml_file = haml_file end
Public Instance Methods
compile()
click to toggle source
# File lib/rugular/tasks/server/guards/rugular_haml.rb, line 16 def compile write_tmp_file "Successfully compiled #{haml_file} to html!\n" end
delete()
click to toggle source
# File lib/rugular/tasks/server/guards/rugular_haml.rb, line 22 def delete FileUtils.rm(tmp_file) "Sucessfully removed #{tmp_file}\n" end
Private Instance Methods
create_tmp_folder()
click to toggle source
# File lib/rugular/tasks/server/guards/rugular_haml.rb, line 50 def create_tmp_folder dirname = File.dirname(tmp_file) FileUtils.mkdir_p(dirname) unless File.directory? dirname end
html()
click to toggle source
# File lib/rugular/tasks/server/guards/rugular_haml.rb, line 30 def html @_html ||= ::Haml::Engine.new(File.read(haml_file)).render end
tmp_file()
click to toggle source
# File lib/rugular/tasks/server/guards/rugular_haml.rb, line 36 def tmp_file haml_file.gsub('src', '.tmp').gsub('haml', 'html') end
write_html()
click to toggle source
# File lib/rugular/tasks/server/guards/rugular_haml.rb, line 46 def write_html ->(file) { file.write html } end
write_tmp_file()
click to toggle source
# File lib/rugular/tasks/server/guards/rugular_haml.rb, line 40 def write_tmp_file create_tmp_folder File.open(tmp_file, 'w', &write_html) end