Skip to content

Commit

Permalink
Merge remote-tracking branch 'metaskills/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
brendon committed Oct 12, 2017
2 parents 6beb590 + 7bb14e5 commit 8c5a707
Show file tree
Hide file tree
Showing 16 changed files with 133 additions and 34 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ pkg/*
*.log
tmp/*
test/dummy_app/tmp/cache/assets/*
gemfiles/*.gemfile
*.gemfile.lock
Gemfile.lock
47 changes: 35 additions & 12 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 11 additions & 3 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -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
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
10 changes: 10 additions & 0 deletions gemfiles/rails40.gemfile
Original file line number Diff line number Diff line change
@@ -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: "../"
10 changes: 10 additions & 0 deletions gemfiles/rails41.gemfile
Original file line number Diff line number Diff line change
@@ -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: "../"
10 changes: 10 additions & 0 deletions gemfiles/rails42.gemfile
Original file line number Diff line number Diff line change
@@ -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: "../"
10 changes: 10 additions & 0 deletions gemfiles/rails50.gemfile
Original file line number Diff line number Diff line change
@@ -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: "../"
10 changes: 10 additions & 0 deletions gemfiles/rails51.gemfile
Original file line number Diff line number Diff line change
@@ -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: "../"
1 change: 1 addition & 0 deletions less-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
25 changes: 17 additions & 8 deletions lib/less/rails/railtie.rb
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/less/rails/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Less
module Rails
VERSION = "2.8.0"
VERSION = "3.0.0"
end
end
6 changes: 4 additions & 2 deletions test/cases/railtie_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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={})
Expand Down

0 comments on commit 8c5a707

Please sign in to comment.