Skip to content

Commit

Permalink
Merge pull request #306 from gpakosz/reduce_sass_filter_dependencies
Browse files Browse the repository at this point in the history
Reduce sass filtered items dependencies
  • Loading branch information
denisdefreyne committed Apr 23, 2013
2 parents dcbec2e + 0c6fb7d commit 939dc14
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
3 changes: 2 additions & 1 deletion lib/nanoc/base/source_data/item.rb
Expand Up @@ -33,7 +33,7 @@ class Item
attr_reader :raw_content

# @return [String] The filename pointing to the file containing this
# item’s content (only available for binary items)
# item’s content
attr_reader :raw_filename

# @return [Nanoc::Site] The site this item belongs to
Expand Down Expand Up @@ -82,6 +82,7 @@ def initialize(raw_content_or_raw_filename, attributes, identifier, params=nil)
if @is_binary
@raw_filename = raw_content_or_raw_filename
else
@raw_filename = attributes[:content_filename]
@raw_content = raw_content_or_raw_filename
end

Expand Down
10 changes: 5 additions & 5 deletions lib/nanoc/filters/sass.rb
Expand Up @@ -22,10 +22,10 @@ def run(content, params={})

# Find items
item_dirglob = Pathname.new(sass_filename).dirname.realpath.to_s + '**'
clean_items = @items.reject { |i| i[:content_filename].nil? }
clean_items = @items.reject { |i| i.raw_filename.nil? }
@scoped_items, @rest_items = clean_items.partition do |i|
i[:content_filename] &&
Pathname.new(i[:content_filename]).realpath.fnmatch(item_dirglob)
i.raw_filename &&
Pathname.new(i.raw_filename).realpath.fnmatch(item_dirglob)
end

# Render
Expand All @@ -36,8 +36,8 @@ def run(content, params={})

def imported_filename_to_item(filename)
filematch = lambda do |i|
i[:content_filename] &&
Pathname.new(i[:content_filename]).realpath == Pathname.new(filename).realpath
i.raw_filename &&
Pathname.new(i.raw_filename).realpath == Pathname.new(filename).realpath
end
@scoped_items.find(&filematch) || @rest_items.find(&filematch)
end
Expand Down

0 comments on commit 939dc14

Please sign in to comment.