Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into safe-load-paths
Browse files Browse the repository at this point in the history
* origin/master: (24 commits)
  Don't need history sections.
  Update history to reflect merge of jekyll#52 [ci skip]
  Don't test Jekyll 2.5 against Ruby 2.3.
  Whoops, they have to be h3's
  Update history to reflect merge of jekyll#46 [ci skip]
  travis: Jekyll 3.1.2
  travis: match rvm versions with jekyll/jekyll
  Release 💎 v1.4.0
  Update history to reflect merge of jekyll#42
  add_charset false by default, but still strip BOM
  Update history to reflect merge of jekyll#39
  Update history to reflect merge of jekyll#41
  Test Jekyll 2 & 3 explicitly
  fix converter spec for jekyll 3
  travis: update to match jekyll-watch
  Travis: use container infra
  Update Gemfile
  Add Jekyll 2 & 3 to test matrix
  Update history to reflect merge of jekyll#40
  Update the version of Sass to be 3.4.x
  ...
  • Loading branch information
bkeepers committed Jul 10, 2016
2 parents 39f708c + 97cf74f commit 4932ea9
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 13 deletions.
37 changes: 32 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
source 'https://rubygems.org'
gemspec

gem "jekyll", ENV["JEKYLL_VERSION"] ? "~> #{ENV["JEKYLL_VERSION"]}" : ">= 2.0"
17 changes: 17 additions & 0 deletions History.markdown
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions jekyll-sass-converter.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion lib/jekyll-sass-converter/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module JekyllSassConverter
VERSION = "1.3.0"
VERSION = "1.4.0"
end
11 changes: 10 additions & 1 deletion lib/jekyll/converters/scss.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion script/bootstrap
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#! /bin/bash

bundle install
bundle install -j8 || bundle install
13 changes: 12 additions & 1 deletion spec/sass_converter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
16 changes: 14 additions & 2 deletions spec/scss_converter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -137,15 +149,15 @@ 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
end

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
Expand Down
8 changes: 8 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 4932ea9

Please sign in to comment.