Module | Sass::Plugin |
In: |
lib/sass/plugin.rb
|
Checks each stylesheet in options[:css_location] to see if it needs updating, and updates it using the corresponding template from options[:templates] if it does.
# File lib/sass/plugin.rb, line 42 42: def update_stylesheets 43: return if options[:never_update] 44: 45: @@checked_for_updates = true 46: Dir.glob(File.join(options[:template_location], "**", "*.sass")).entries.each do |file| 47: 48: # Get the relative path to the file with no extension 49: name = file.sub(options[:template_location] + "/", "")[0...-5] 50: 51: if !forbid_update?(name) && (options[:always_update] || stylesheet_needs_update?(name)) 52: css = css_filename(name) 53: File.delete(css) if File.exists?(css) 54: 55: filename = template_filename(name) 56: l_options = @@options.dup 57: l_options[:filename] = filename 58: l_options[:load_paths] = load_paths 59: engine = Engine.new(File.read(filename), l_options) 60: result = begin 61: engine.render 62: rescue Exception => e 63: exception_string(e) 64: end 65: 66: # Create any directories that might be necessary 67: dirs = [l_options[:css_location]] 68: name.split("/")[0...-1].each { |dir| dirs << "#{dirs[-1]}/#{dir}" } 69: dirs.each { |dir| Dir.mkdir(dir) unless File.exist?(dir) } 70: 71: # Finally, write the file 72: File.open(css, 'w') do |file| 73: file.print(result) 74: end 75: end 76: end 77: end