zweilove / css_splitter

Gem for splitting up stylesheets that go beyond the IE limit of 4095 selectors, for Rails 3.1+ apps using the Asset Pipeline.
MIT License
160 stars 47 forks source link

Gracefully handle when assets are not configured #62

Closed seckenrode closed 8 years ago

seckenrode commented 8 years ago

In sprockets-rails v3, app.assets is now only set when assets.compile is set to true. This is currently causing an error when upgrading to Rails 4.2.5.

This change will cause CSS Splitter to only be registered when assets themselves are configured.

Fixes #60

seckenrode commented 8 years ago

Before

~/development/css_splitter@seckenrode(master)
$ rake test
/Users/seckenrode/development/css_splitter/lib/css_splitter/engine.rb:6:in `block in <class:Engine>': undefined method `register_bundle_processor' for nil:NilClass (NoMethodError
)
...

After

$ rake test
Run options: --seed 2141

# Running:

DEPRECATION WARNING: You didn't set `secret_key_base`. Read the upgrade documentation to learn more about this new config option. (called from validate_secret_key_config! at /Use
rs/seckenrode/.gem/ruby/2.2.0/gems/railties-4.2.5/lib/rails/application.rb:530)
.............................

Finished in 0.635507s, 45.6328 runs/s, 59.7948 assertions/s.

29 runs, 38 assertions, 0 failures, 0 errors, 0 skips
seckenrode commented 8 years ago

Tests are failing in Ruby 1.9.3 due to Travis' version of Bundler being outdated. We ran into this issue with one of our repositories the other day and were able to solve it by adding:

before_install:
  - gem update bundler

See https://github.com/bundler/bundler/issues/3558 for more information

I made the change to this PR to get the build to pass. Let me know if you would like me to do that separately. These two changes should unbreak master.

jhilden commented 8 years ago

thanks a lot for the fix @seckenrode

I released a new version 0.4.4

I ended up removing the updating of bundler on travis, because it seem to work without it.

seckenrode commented 8 years ago

Thanks so much! Travis must have snuck in an update to their bundler version. :)