… not magic enough
Currently, Context#logical_path from sprockets seems to return the incorrect value when a path happens to contain periods: sstephenson/sprockets#299 With this bug in sprockets, an asset located in `jquery.mobile-1.0.1/jquery.mobile-1.0.1.css` will be interpreted to have a logical path of only `jquery`, and thus it's parent is simply `.`. So if that asset references `url(images/icons-18-white.png)` urlrewriter sees no parent path, so it's URL won't be changed. The URL really needs to be rewritten to `url(jquery.mobile-1.0.1/images/icons-18-white.png)` to work. The fix is to simply ignore the incorrect `Context#logical_path` method and grab the original `@logical_path` instance variable. This seems icky, but since Rails is currently tied to sprockets 2.1.x, I don't know the likelihood of this being fixed in sprockets and being used in Rails apps anytime soon. So in the mean time, this makes things work as you'd expect, even if you happen to have a folder with a period in the name.
Otherwise, the whole library was being included in the gemspec, so running `bundle install` would fail if any dependencies were missing from the system with: There was a LoadError while evaluating sprockets-urlrewriter.gemspec: no such file to load -- sprockets from [...]/sprockets-urlrewriter.gemspec:3