diff --git a/.gitignore b/.gitignore index dc124f8..55812f7 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ pkg/* *.log tmp/* test/dummy_app/tmp/cache/assets/* -gemfiles/*.gemfile +*.gemfile.lock +Gemfile.lock diff --git a/.travis.yml b/.travis.yml index 72db7c1..743fdff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,37 @@ +language: ruby +cache: bundler +sudo: false rvm: - - 1.9.3 - - 2.0.0 - - 2.1.4 - - jruby-19mode + - 1.9.3-p551 + - 2.0.0-p648 + - 2.1.10 + - 2.2.7 + - 2.3.4 + - 2.4.1 + - jruby-9.1.9.0 before_install: - - travis_retry gem install bundler - - bundle --version -install: - - travis_retry bundle install -before_script: - - travis_retry bundle exec appraisal install -script: - - bundle exec appraisal rake test + - gem install bundler +gemfile: + - gemfiles/rails40.gemfile + - gemfiles/rails41.gemfile + - gemfiles/rails42.gemfile + - gemfiles/rails50.gemfile + - gemfiles/rails51.gemfile +matrix: + exclude: + - rvm: 1.9.3-p551 + gemfile: gemfiles/rails50.gemfile + - rvm: 1.9.3-p551 + gemfile: gemfiles/rails51.gemfile + - rvm: 2.0.0-p648 + gemfile: gemfiles/rails50.gemfile + - rvm: 2.0.0-p648 + gemfile: gemfiles/rails51.gemfile + - rvm: 2.1.10 + gemfile: gemfiles/rails50.gemfile + - rvm: 2.1.10 + gemfile: gemfiles/rails51.gemfile + - rvm: 2.4.1 + gemfile: gemfiles/rails40.gemfile + - rvm: 2.4.1 + gemfile: gemfiles/rails41.gemfile diff --git a/Appraisals b/Appraisals index e4f4a92..034b201 100644 --- a/Appraisals +++ b/Appraisals @@ -1,11 +1,19 @@ appraise 'rails40' do - gem 'rails', '~> 4.0.11' + gem 'rails', '~> 4.0.13' end appraise 'rails41' do - gem 'rails', '~> 4.1.7' + gem 'rails', '~> 4.1.16' end appraise 'rails42' do - gem 'rails', '~> 4.2.1' + gem 'rails', '~> 4.2.8' +end + +appraise 'rails50' do + gem 'rails', '~> 5.0.3' +end + +appraise 'rails51' do + gem 'rails', '~> 5.1.1' end diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ffa88f..e4db829 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # CHANGELOG -### 2.8.0 - ? +### 3.0.0 - 2017-10-02 + +* Solve deprecation warning via Grease adapter! + +### 2.8.0 - 2016-10-12 * Make it possible to pass parameters to less.rb Fixes https://github.com/metaskills/less-rails/issues/94 diff --git a/README.md b/README.md index a47be1a..d9fcc92 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ This gem provides integration for Rails projects using the Less stylesheet langu Just bundle up less-rails in your Gemfile. This will pull in less as a runtime dependency too. ```ruby -gem 'less-rails', '~> 2.7.0' +gem 'less-rails', '~> 3.0.0' ``` But be warned, less.rb relies on a JavaScript runtime gem too. Just like ExecJS, it will look for a gem that is appropriate to your system. Typically, this means you will need one of the following. @@ -125,12 +125,12 @@ We also have a generator for rails scaffold CSS. Just like the Sass gem, we simp ## Contributing -This gem is fully tested from Rails 4.0 to Rails 4.2. We run our tests on [Travis CI](http://travis-ci.org/metaskills/less-rails) in both Ruby 1.9, 2.0, and jRuby 1.9 mode. If you detect a problem, open up a github issue or fork the repo and help out. After you fork or clone the repository, the following commands will get you up and running on the test suite. +This gem is fully tested from Rails 4.0 to Rails 5.1. We run our tests on [Travis CI](http://travis-ci.org/metaskills/less-rails) in both Ruby 1.9, 2.0, and JRuby 9000. If you detect a problem, open up a github issue or fork the repo and help out. After you fork or clone the repository, the following commands will get you up and running on the test suite. ```shell -$ bundle install -$ bundle exec rake appraisal:setup -$ bundle exec rake appraisal test +$ bundle +$ bundle exec appraisal install +$ bundle exec appraisal rake ``` We use the [appraisal](https://github.com/thoughtbot/appraisal) gem from Thoughtbot to help us generate the individual gemfiles for each Rails version and to run the tests locally against each generated Gemfile. The `rake appraisal test` command actually runs our test suite against all Rails versions in our `Appraisal` file. If you want to run the tests for a specific Rails version, use `rake -T` for a list. For example, the following command will run the tests for Rails 4.0 only. diff --git a/Rakefile b/Rakefile index a1f9ec0..3031524 100644 --- a/Rakefile +++ b/Rakefile @@ -7,6 +7,7 @@ Rake::TestTask.new do |t| t.libs = ['lib','test'] t.test_files = Dir.glob("test/**/*_spec.rb").sort t.verbose = true + # t.warning = false end task :default => [:test] diff --git a/gemfiles/rails40.gemfile b/gemfiles/rails40.gemfile new file mode 100644 index 0000000..10fbe6d --- /dev/null +++ b/gemfiles/rails40.gemfile @@ -0,0 +1,10 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "therubyracer", "~> 0.12.0", require: nil, platforms: :ruby +gem "therubyrhino", "~> 2.0.2", require: nil, platforms: :jruby +gem "mime-types", "~> 2.6.2", platforms: [:ruby_19, :jruby] +gem "rails", "~> 4.0.13" + +gemspec path: "../" diff --git a/gemfiles/rails41.gemfile b/gemfiles/rails41.gemfile new file mode 100644 index 0000000..d380494 --- /dev/null +++ b/gemfiles/rails41.gemfile @@ -0,0 +1,10 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "therubyracer", "~> 0.12.0", require: nil, platforms: :ruby +gem "therubyrhino", "~> 2.0.2", require: nil, platforms: :jruby +gem "mime-types", "~> 2.6.2", platforms: [:ruby_19, :jruby] +gem "rails", "~> 4.1.16" + +gemspec path: "../" diff --git a/gemfiles/rails42.gemfile b/gemfiles/rails42.gemfile new file mode 100644 index 0000000..8458c61 --- /dev/null +++ b/gemfiles/rails42.gemfile @@ -0,0 +1,10 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "therubyracer", "~> 0.12.0", require: nil, platforms: :ruby +gem "therubyrhino", "~> 2.0.2", require: nil, platforms: :jruby +gem "mime-types", "~> 2.6.2", platforms: [:ruby_19, :jruby] +gem "rails", "~> 4.2.8" + +gemspec path: "../" diff --git a/gemfiles/rails50.gemfile b/gemfiles/rails50.gemfile new file mode 100644 index 0000000..290cbfd --- /dev/null +++ b/gemfiles/rails50.gemfile @@ -0,0 +1,10 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "therubyracer", "~> 0.12.0", require: nil, platforms: :ruby +gem "therubyrhino", "~> 2.0.2", require: nil, platforms: :jruby +gem "mime-types", "~> 2.6.2", platforms: [:ruby_19, :jruby] +gem "rails", "~> 5.0.3" + +gemspec path: "../" diff --git a/gemfiles/rails51.gemfile b/gemfiles/rails51.gemfile new file mode 100644 index 0000000..bcdd770 --- /dev/null +++ b/gemfiles/rails51.gemfile @@ -0,0 +1,10 @@ +# This file was generated by Appraisal + +source "https://rubygems.org" + +gem "therubyracer", "~> 0.12.0", require: nil, platforms: :ruby +gem "therubyrhino", "~> 2.0.2", require: nil, platforms: :jruby +gem "mime-types", "~> 2.6.2", platforms: [:ruby_19, :jruby] +gem "rails", "~> 5.1.1" + +gemspec path: "../" diff --git a/less-rails.gemspec b/less-rails.gemspec index a684072..a953eb1 100644 --- a/less-rails.gemspec +++ b/less-rails.gemspec @@ -18,6 +18,7 @@ Gem::Specification.new do |gem| gem.add_runtime_dependency 'less', '~> 2.6.0' gem.add_runtime_dependency 'actionpack', '>= 4.0' gem.add_runtime_dependency 'tilt' + gem.add_runtime_dependency 'grease' gem.add_runtime_dependency 'sprockets', '> 2', '< 4' gem.add_development_dependency 'appraisal' gem.add_development_dependency 'minitest' diff --git a/lib/less/rails/railtie.rb b/lib/less/rails/railtie.rb index 64b3aa0..c23b937 100644 --- a/lib/less/rails/railtie.rb +++ b/lib/less/rails/railtie.rb @@ -1,6 +1,8 @@ +require 'less' +require 'grease' require 'sprockets/railtie' -module Less +module Less module Rails class Railtie < ::Rails::Railtie config.less = ActiveSupport::OrderedOptions.new @@ -10,15 +12,22 @@ class Railtie < ::Rails::Railtie config.app_generators.stylesheet_engine :less config.before_initialize do |app| - require 'less' - require 'less-rails' - Sprockets::Engines #force autoloading - Sprockets.register_engine '.less', LessTemplate + sprockets_env = app.assets || Sprockets + if sprockets_env.respond_to?(:register_engine) + args = ['.less', Grease.apply(LessTemplate)] + args << { mime_type: 'text/less', silence_deprecation: true } if Sprockets::VERSION.start_with?("3") + sprockets_env.register_engine(*args) + end + + if sprockets_env.respond_to?(:register_transformer) + sprockets_env.register_mime_type 'text/less', extensions: ['.less', '.less.erb', '.less.css'], charset: :css + sprockets_env.register_transformer 'text/less', 'text/css', Grease.apply(LessTemplate) + end end initializer 'less-rails.before.load_config_initializers', :before => :load_config_initializers, :group => :all do |app| sprockets_env = app.assets || Sprockets - sprockets_env.register_preprocessor 'text/css', ImportProcessor + sprockets_env.register_preprocessor 'text/css', Grease.apply(ImportProcessor) config.assets.configure do |env| env.context_class.class_eval do @@ -32,11 +41,11 @@ class Railtie < ::Rails::Railtie assets_stylesheet_paths = app.config.assets.paths.select { |p| p && p.to_s.ends_with?('stylesheets') } app.config.less.paths.unshift(*assets_stylesheet_paths) end - + initializer 'less-rails.setup_compression', :group => :all do |app| config.less.compress = app.config.assets.compress end - + end end end diff --git a/lib/less/rails/version.rb b/lib/less/rails/version.rb index 18f7161..bd2aebc 100644 --- a/lib/less/rails/version.rb +++ b/lib/less/rails/version.rb @@ -1,5 +1,5 @@ module Less module Rails - VERSION = "2.8.0" + VERSION = "3.0.0" end end diff --git a/test/cases/railtie_spec.rb b/test/cases/railtie_spec.rb index 2eaa63a..21bc5de 100644 --- a/test/cases/railtie_spec.rb +++ b/test/cases/railtie_spec.rb @@ -31,7 +31,7 @@ class RailtieSpec < Less::Rails::Spec describe 'initialization' do it 'must register our template engine' do - dummy_assets.engines['.less'].must_equal Less::Rails::LessTemplate + dummy_assets.engines['.less'].must_be_instance_of Grease::Adapter end it 'must extend the context class with our config' do @@ -40,7 +40,9 @@ class RailtieSpec < Less::Rails::Spec end it 'must register our import pre processor' do - dummy_assets.preprocessors['text/css'].must_include Less::Rails::ImportProcessor + dummy_assets.preprocessors['text/css'].any? do |preprocessor| + preprocessor.is_a? Grease::Adapter + end.must_equal true end it 'must include the asset pipelines stylesheet paths to less paths' do diff --git a/test/spec_helper.rb b/test/spec_helper.rb index 6d1da5d..7c5442b 100644 --- a/test/spec_helper.rb +++ b/test/spec_helper.rb @@ -100,7 +100,7 @@ def setup_generator_class end def run_generator(args=default_arguments, config={}) - capture(:stdout) { generator_class.start(args, config.reverse_merge(:destination_root => destination_root)) } + generator_class.start(args, config.reverse_merge(:destination_root => destination_root)) end def generator(args=default_arguments, options={}, config={})