class RugularCoffee
Attributes
coffee_file[R]
Public Class Methods
compile(coffee_file)
click to toggle source
# File lib/rugular/tasks/server/guards/rugular_coffee.rb, line 4 def self.compile(coffee_file) new(coffee_file).compile end
delete(coffee_file)
click to toggle source
# File lib/rugular/tasks/server/guards/rugular_coffee.rb, line 8 def self.delete(coffee_file) new(coffee_file).delete end
new(coffee_file)
click to toggle source
# File lib/rugular/tasks/server/guards/rugular_coffee.rb, line 12 def initialize(coffee_file) @coffee_file = coffee_file end
Public Instance Methods
compile()
click to toggle source
# File lib/rugular/tasks/server/guards/rugular_coffee.rb, line 16 def compile write_tmp_file "Successfully compiled #{coffee_file} to js!\n" end
delete()
click to toggle source
# File lib/rugular/tasks/server/guards/rugular_coffee.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_coffee.rb, line 46 def create_tmp_folder dirname = File.dirname(tmp_file) FileUtils.mkdir_p(dirname) unless File.directory? dirname end
javascript()
click to toggle source
# File lib/rugular/tasks/server/guards/rugular_coffee.rb, line 32 def javascript @_javascript ||= CoffeeScript.compile(File.open(coffee_file)) end
tmp_file()
click to toggle source
# File lib/rugular/tasks/server/guards/rugular_coffee.rb, line 36 def tmp_file coffee_file.gsub('src', '.tmp').gsub('coffee', 'js') end
write_javascript()
click to toggle source
# File lib/rugular/tasks/server/guards/rugular_coffee.rb, line 52 def write_javascript ->(file) { file.write javascript } end
write_tmp_file()
click to toggle source
# File lib/rugular/tasks/server/guards/rugular_coffee.rb, line 40 def write_tmp_file create_tmp_folder File.open(tmp_file, 'w', &write_javascript) end