lib/rack/less/source.rb in rack-less-1.5.0 vs lib/rack/less/source.rb in rack-less-2.0.0

- old
+ new

@@ -19,14 +19,14 @@ # but also accept files with the .css extension PREFERRED_EXTENSIONS = [:less, :css] YUI_OPTS = {} - attr_reader :path + attr_reader :css_resource - def initialize(path, options={}) - @path = path + def initialize(css_resource, options={}) + @css_resource = css_resource.gsub(/^\/+/, '') @compress = options[:compress] @cache = options[:cache] @folder = get_required_path(options, :folder) end @@ -62,12 +62,12 @@ end else compiled_css end - if cache? && !File.exists?(cf = File.join(@cache, "#{@path}.css")) - FileUtils.mkdir_p(@cache) + if cache? && !File.exists?(cf = File.join(@cache, "#{@css_resource}.css")) + FileUtils.mkdir_p(File.dirname(cf)) File.open(cf, "w") do |file| file.write(compiled_css) end end @@ -79,16 +79,16 @@ protected # Preferred, existing source files matching the css name def css_sources - @css_sources ||= preferred_sources([@path]) + @css_sources ||= preferred_sources([*@css_resource]) end # Preferred, existing source files matching a corresponding # Rack::Less::Config combination directive, if any def combination_sources - @combination_sources ||= preferred_sources(Rack::Less.config.combinations[@path] || []) + @combination_sources ||= preferred_sources(Rack::Less.config.combinations[@css_resource] || []) end private # Given a list of sources, return a list of