diff --git a/.travis.yml b/.travis.yml index c634286..444e2fc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,35 @@ +sudo: false language: ruby -script : script/cibuild rvm: -- 2.1.0 -- 2.0.0 -- 1.9.3 +- 2.2.4 +- 2.1.8 +- ruby-head +matrix: + allow_failures: + - rvm: ruby-head + include: + - rvm: 1.9.3 + env: JEKYLL_VERSION=2.5 + - rvm: 2.3.0 + env: JEKYLL_VERSION=3.1 +env: + matrix: + - JEKYLL_VERSION=2.5 + - JEKYLL_VERSION=3.1 +branches: + only: + - master +install: +- travis_retry script/bootstrap +script: script/cibuild notifications: - email: false + irc: + on_success: change + on_failure: change + channels: + - irc.freenode.org#jekyll + template: + - '%{repository}#%{build_number} %{message} %{build_url}' + email: + on_success: never + on_failure: change diff --git a/Gemfile b/Gemfile index 851fabc..fcaf453 100644 --- a/Gemfile +++ b/Gemfile @@ -1,2 +1,4 @@ source 'https://rubygems.org' gemspec + +gem "jekyll", ENV["JEKYLL_VERSION"] ? "~> #{ENV["JEKYLL_VERSION"]}" : ">= 2.0" diff --git a/History.markdown b/History.markdown index 306d18e..e110e68 100644 --- a/History.markdown +++ b/History.markdown @@ -1,3 +1,20 @@ +## HEAD + + * Match Ruby versions with jekyll/jekyll (#46) + * Don't test Jekyll 2.5 against Ruby 2.3. (#52) + +## 1.4.0 / 2015-12-25 + +### Minor Enhancements + + * Bump Sass to v3.4 and above. (#40) + * Strip byte order mark from generated compressed Sass/SCSS (#39) + * Strip BOM by default, but don't add in the `@charset` by default (#42) + +### Development Fixes + + * Add Jekyll 2 & 3 to test matrix (#41) + ## 1.3.0 / 2014-12-07 ### Minor Enhancements diff --git a/jekyll-sass-converter.gemspec b/jekyll-sass-converter.gemspec index d14e604..36ece76 100644 --- a/jekyll-sass-converter.gemspec +++ b/jekyll-sass-converter.gemspec @@ -15,10 +15,10 @@ Gem::Specification.new do |spec| spec.files = `git ls-files -z`.split("\x0").grep(%r{^lib/}) spec.require_paths = ["lib"] - spec.add_runtime_dependency "sass", "~> 3.2" + spec.add_runtime_dependency "sass", "~> 3.4" spec.add_development_dependency "bundler", "~> 1.5" spec.add_development_dependency "rake" spec.add_development_dependency "rspec" - spec.add_development_dependency "jekyll", "~> 2.0" + spec.add_development_dependency "jekyll", ">= 2.0" end diff --git a/lib/jekyll-sass-converter/version.rb b/lib/jekyll-sass-converter/version.rb index b6d82f4..93087d9 100644 --- a/lib/jekyll-sass-converter/version.rb +++ b/lib/jekyll-sass-converter/version.rb @@ -1,3 +1,3 @@ module JekyllSassConverter - VERSION = "1.3.0" + VERSION = "1.4.0" end diff --git a/lib/jekyll/converters/scss.rb b/lib/jekyll/converters/scss.rb index 4e71065..a8c2d30 100644 --- a/lib/jekyll/converters/scss.rb +++ b/lib/jekyll/converters/scss.rb @@ -1,9 +1,12 @@ +# encoding: utf-8 + require 'sass' require 'jekyll/utils' module Jekyll module Converters class Scss < Converter + BYTE_ORDER_MARK = /^\xEF\xBB\xBF/ SyntaxError = Class.new(ArgumentError) safe true @@ -91,6 +94,10 @@ def allow_caching? !safe? end + def add_charset? + !!jekyll_sass_configuration["add_charset"] + end + def sass_configs sass_build_configuration_options({ "syntax" => syntax, @@ -100,7 +107,9 @@ def sass_configs end def convert(content) - ::Sass.compile(content, sass_configs) + output = ::Sass.compile(content, sass_configs) + replacement = add_charset? ? '@charset "UTF-8";' : '' + output.sub(BYTE_ORDER_MARK, replacement) rescue ::Sass::SyntaxError => e raise SyntaxError.new("#{e.to_s} on line #{e.sass_line}") end diff --git a/script/bootstrap b/script/bootstrap index 8a09d8a..68f70ff 100755 --- a/script/bootstrap +++ b/script/bootstrap @@ -1,3 +1,3 @@ #! /bin/bash -bundle install +bundle install -j8 || bundle install diff --git a/spec/sass_converter_spec.rb b/spec/sass_converter_spec.rb index c7aaff1..ae1d240 100644 --- a/spec/sass_converter_spec.rb +++ b/spec/sass_converter_spec.rb @@ -53,6 +53,17 @@ def converter(overrides = {}) converter.convert(invalid_content) }.to raise_error(Jekyll::Converters::Scss::SyntaxError, error_message) end - end + it "removes byte order mark from compressed Sass" do + result = converter({ "style" => :compressed }).convert("a\n content: \"\uF015\"") + expect(result).to eql("a{content:\"\uF015\"}\n") + expect(result.bytes.to_a[0..2]).not_to eql([0xEF, 0xBB, 0xBF]) + end + + it "does not include the charset if asked not to" do + result = converter({ "style" => :compressed, "add_charset" => true }).convert("a\n content: \"\uF015\"") + expect(result).to eql("@charset \"UTF-8\";a{content:\"\uF015\"}\n") + expect(result.bytes.to_a[0..2]).not_to eql([0xEF, 0xBB, 0xBF]) + end + end end diff --git a/spec/scss_converter_spec.rb b/spec/scss_converter_spec.rb index bde73b6..6711f05 100644 --- a/spec/scss_converter_spec.rb +++ b/spec/scss_converter_spec.rb @@ -122,6 +122,18 @@ def converter(overrides = {}) converter.convert(invalid_content) }.to raise_error(Jekyll::Converters::Scss::SyntaxError, error_message) end + + it "removes byte order mark from compressed SCSS" do + result = converter({ "style" => :compressed }).convert("a{content:\"\uF015\"}") + expect(result).to eql("a{content:\"\uF015\"}\n") + expect(result.bytes.to_a[0..2]).not_to eql([0xEF, 0xBB, 0xBF]) + end + + it "does not include the charset unless asked to" do + result = converter({ "style" => :compressed, "add_charset" => true }).convert("a{content:\"\uF015\"}") + expect(result).to eql("@charset \"UTF-8\";a{content:\"\uF015\"}\n") + expect(result.bytes.to_a[0..2]).not_to eql([0xEF, 0xBB, 0xBF]) + end end context "importing partials" do @@ -137,7 +149,7 @@ def converter(overrides = {}) end it "uses a compressed style" do - instance = site.getConverterImpl(Jekyll::Converters::Scss) + instance = scss_converter_instance(site) expect(instance.jekyll_sass_configuration).to eql({"style" => :compressed}) expect(instance.sass_configs[:style]).to eql(:compressed) end @@ -145,7 +157,7 @@ def converter(overrides = {}) context "importing from external libraries" do let(:external_library) { source_dir("bower_components/jquery") } - let(:verter) { site.getConverterImpl(Jekyll::Converters::Scss) } + let(:verter) { scss_converter_instance(site) } let(:test_css_file) { dest_dir('css', 'main.css') } context "unsafe mode" do diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 4199b8c..a014eb0 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -41,4 +41,12 @@ def site_configuration(overrides = {}) "destination" => dest_dir })) end + + def scss_converter_instance(site) + if Jekyll::VERSION >= '3.0' + site.find_converter_instance(Jekyll::Converters::Scss) + else + site.getConverterImpl(Jekyll::Converters::Scss) + end + end end