class SassMyLess::Base
Constants
- ConvertList
Public Class Methods
convert(input_dir, output_dir)
click to toggle source
Copies the entire directory to the output
# File lib/SassMyLess.rb, line 15 def self.convert(input_dir, output_dir) input_path = File.expand_path("#{input_dir}") output_path = File.expand_path("#{output_dir}") FileUtils.mkdir_p(output_path) unless Dir.exists?(output_path) FileUtils.cp_r "#{input_path}/.", "#{output_path}" self.traverse_dir output_path end
Private Class Methods
traverse_dir(directory)
click to toggle source
Traverses the output directory and converts every file.
# File lib/SassMyLess.rb, line 26 def self.traverse_dir directory Dir.glob("#{directory}/*").each_with_object({}) do |f, h| if File.file?(f) src = open(f).read.encode!('UTF-8') ConvertList.each do |regexp, with| src.gsub! /#{regexp}/, with File.open(f, 'w') {|fh| fh.write(src) } end FileUtils.mv(f, f.gsub('.less', '.scss')) end end end