class Styles
Public Class Methods
new(styles_path)
click to toggle source
# File lib/styles.rb, line 2 def initialize(styles_path) @styles_path = styles_path @styles = {} end
Public Instance Methods
compile()
click to toggle source
# File lib/styles.rb, line 30 def compile() walk @styles.each do |key, content| view_path = Pathname("dist/" + key.to_s.delete_prefix('"').delete_suffix('/"') + ".css") view_path.dirname.mkpath view_path.write(content) end end
minify(content)
click to toggle source
# File lib/styles.rb, line 20 def minify(content) return content.gsub(/\s+/, "") end
parse(path)
click to toggle source
# File lib/styles.rb, line 15 def parse(path) file_content = read path return file_content end
read(path)
click to toggle source
# File lib/styles.rb, line 7 def read(path) if File.file? path return File.read(path) else raise "File #{path} does not exist" end end
walk()
click to toggle source
# File lib/styles.rb, line 24 def walk() for file in Dir[@styles_path + "/**/*.css"] @styles[file.sub(@styles_path + "/", "").sub(".css", "").to_sym] = minify(parse(file)) end end