Skip to content
This repository was archived by the owner on Jun 10, 2018. It is now read-only.

Check if individual asset matches filters#514

Closed
schneems wants to merge 1 commit intosstephenson:masterfrom
schneems:schneems/asset-filtered
Closed

Check if individual asset matches filters#514
schneems wants to merge 1 commit intosstephenson:masterfrom
schneems:schneems/asset-filtered

Conversation

@schneems
Copy link
Copy Markdown
Contributor

This PR exposes matches_filter via a public method called filtered? for the purposes of detecting if an asset exists in a filter. This is to be used in rails/sprockets-rails#96. This change to sprockets was requested by @rafaelfranca to prevent the interface from accidentally changing or breaking.

This PR exposes `matches_filter` via a public method called `filtered?` for the purposes of detecting if an asset exists in a filter. This is to be used in rails/sprockets-rails#96. This change to sprockets was requested by @rafaelfranca to prevent the interface from accidentally changing or breaking.
@josh
Copy link
Copy Markdown
Contributor

josh commented Dec 11, 2013

I'm going to redo all the path lookup helpers for 3.x.

I don't particularly like this api. filter? what, paths, assets, it doesn't say.

@schneems
Copy link
Copy Markdown
Contributor Author

We could preserve the existing protected API and call it matches_filter? or we could make it more verbose and call it asset_matches_filters? to give a hint of the order of parameters. We need an exposed way to detect if given a set of filters and an asset if sprockets will compile or not compile that asset.

The method doesn't even need to be on environment or index in this case the protected method matches_filter doesn't actually use any methods on Sprockets::Base at all it's purely functional, it only uses elements passed in. If you wanted we could move to a separate class Sprockets::FilterMatcher that could be used to replace the implementation of matches_filter.

We've got options. We need this functionality exposed, I'm very open to how we write the implementation. Let me know which of the above options you like the best, or please suggest something else.

@josh
Copy link
Copy Markdown
Contributor

josh commented Apr 17, 2014

Heres the direction I'm trying to go by exposing more filter as enumerators.

https://github.com/sstephenson/sprockets/blob/master/lib/sprockets/manifest.rb#L109-L151

It should be easier to chain filters on to them. And even better you can use .lazy on Ruby 2.

@josh josh closed this Jul 2, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants