pax_global_header 0000666 0000000 0000000 00000000064 13235430744 0014517 g ustar 00root root 0000000 0000000 52 comment=767881d3a71846562b696353b58c84faeb81b72e
jekyll-sass-converter-1.5.2/ 0000775 0000000 0000000 00000000000 13235430744 0015772 5 ustar 00root root 0000000 0000000 jekyll-sass-converter-1.5.2/.gitignore 0000664 0000000 0000000 00000000075 13235430744 0017764 0 ustar 00root root 0000000 0000000 .sass-cache
*.gem
docs/_site
Gemfile.lock
pkg
rdoc
spec/dest
jekyll-sass-converter-1.5.2/.rspec 0000664 0000000 0000000 00000000025 13235430744 0017104 0 ustar 00root root 0000000 0000000 --color
--format doc
jekyll-sass-converter-1.5.2/.rubocop.yml 0000664 0000000 0000000 00000000333 13235430744 0020243 0 ustar 00root root 0000000 0000000 inherit_gem:
jekyll: .rubocop.yml
Metrics/LineLength:
Exclude:
- spec/**/*
- jekyll-sass-converter.gemspec
Metrics/BlockLength:
Exclude:
- spec/**/*
Layout/IndentHeredoc:
Exclude:
- spec/**/*
jekyll-sass-converter-1.5.2/.travis.yml 0000664 0000000 0000000 00000001010 13235430744 0020073 0 ustar 00root root 0000000 0000000 sudo: false
cache: bundler
language: ruby
rvm:
- 2.5
- 2.4
- 2.3
- 2.2
matrix:
include:
- rvm: 2.4.2
env: JEKYLL_VERSION=3.6
env:
matrix:
- JEKYLL_VERSION=3.6
branches:
only:
- master
before_install:
- gem update --system
script: script/cibuild
notifications:
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
jekyll-sass-converter-1.5.2/Gemfile 0000664 0000000 0000000 00000000225 13235430744 0017264 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true
source "https://rubygems.org"
gemspec
gem "jekyll", ENV["JEKYLL_VERSION"] ? "~> #{ENV["JEKYLL_VERSION"]}" : ">= 2.0"
jekyll-sass-converter-1.5.2/History.markdown 0000664 0000000 0000000 00000003412 13235430744 0021177 0 ustar 00root root 0000000 0000000 ## 1.5.2 / 2017-02-03
### Development Fixes
* Test against Ruby 2.5 (#68)
## 1.5.1 / 2017-12-02
### Minor
* Security: Bump Rubocop to 0.51
### Development Fixes
* Drop support for Jekyll 2.x and Ruby 2.0 (#62)
* Inherit Jekyll's rubocop config for consistency (#61)
* Define path with __dir__ (#60)
* Fix script/release
## 1.5.0 / 2016-11-14
* Allow `load_paths` in safe mode with sanitization (#50)
* SCSS converter: expand @config["source"] to be "safer". (#55)
* 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
* Include line number in syntax error message (#26)
* Raise a `Jekyll::Converters::Scss::SyntaxError` instead of just a `StandardError` (#29)
### Development Fixes
* Fix typo in SCSS converter spec filename (#27)
* Add tests for custom syntax error handling (#29)
## 1.2.1 / 2014-08-30
* Only include something in the sass load path if it exists (#23)
## 1.2.0 / 2014-07-31
### Minor Enhancements
* Allow user to specify style in safe mode. (#16)
### Development Fixes
* Only include the `lib/` files in the gem. (#17)
## 1.1.0 / 2014-07-29
### Minor Enhancements
* Implement custom load paths (#14)
* Lock down sass configuration when in safe mode. (#15)
## 1.0.0 / 2014-05-06
* Birthday!
* Don't use core extensions (#2)
* Allow users to set style of outputted CSS (#4)
* Determine input syntax based on file extension (#9)
jekyll-sass-converter-1.5.2/LICENSE.txt 0000664 0000000 0000000 00000002140 13235430744 0017612 0 ustar 00root root 0000000 0000000 Copyright (c) 2014-present Parker Moore and the jekyll-sass-converter contributors
MIT License
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
jekyll-sass-converter-1.5.2/README.md 0000664 0000000 0000000 00000002017 13235430744 0017251 0 ustar 00root root 0000000 0000000 # Jekyll Sass Converter
Let Jekyll build your Sass and SCSS!
[](https://travis-ci.org/jekyll/jekyll-sass-converter)
## Installation
**Jekyll Sass Converter requires Jekyll 2.0.0 or greater and is bundled
with Jekyll so you don't need to install it if you're already using Jekyll.**
Add this line to your application's Gemfile:
gem 'jekyll-sass-converter'
And then execute:
$ bundle
Or install it yourself as:
$ gem install jekyll-sass-converter
## Usage
Jekyll Sass Converter comes bundled with Jekyll 2.0.0 and greater. For more
information about usage, visit the [Jekyll Assets Documentation
page](http://jekyllrb.com/docs/assets/).
## Contributing
1. Fork it ( http://github.com/jekyll/jekyll-sass-converter/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
jekyll-sass-converter-1.5.2/Rakefile 0000664 0000000 0000000 00000000073 13235430744 0017437 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true
require "bundler/gem_tasks"
jekyll-sass-converter-1.5.2/docs/ 0000775 0000000 0000000 00000000000 13235430744 0016722 5 ustar 00root root 0000000 0000000 jekyll-sass-converter-1.5.2/docs/README.md 0000664 0000000 0000000 00000001607 13235430744 0020205 0 ustar 00root root 0000000 0000000 ---
layout: default
---
# This is an example site for Sass integration in Jekyll
You have two kinds of Sass files:
1. Main files, which you wish to be output as CSS files
2. Partials, which are used by main files in `@import` statements
Main files are like pages – they go where you want them to be output, and they contain the YAML front matter (`---` lines) at the top. Partials are like hidden Jekyll data, so they go in an underscored directory, which defaults to `_sass`. You site might look like this:
.
| - _sass
| - _typography.scss
| - _layout.scss
| - _colors.scss
| - stylesheets
| - screen.scss
| - print.scss
And so on.
The output, in your `_site` directory, would look like this:
.
| - stylesheets
| - screen.css
| - print.css
Boom! Now you have just your SCSS/Sass converted over to CSS with all the proper inputs.
jekyll-sass-converter-1.5.2/docs/_config.yml 0000664 0000000 0000000 00000000115 13235430744 0021046 0 ustar 00root root 0000000 0000000 sass:
style: compact # possible values: nested expanded compact compressed
jekyll-sass-converter-1.5.2/docs/_layouts/ 0000775 0000000 0000000 00000000000 13235430744 0020561 5 ustar 00root root 0000000 0000000 jekyll-sass-converter-1.5.2/docs/_layouts/default.html 0000664 0000000 0000000 00000000403 13235430744 0023070 0 ustar 00root root 0000000 0000000
Sass Example Site
{{ content }}
jekyll-sass-converter-1.5.2/docs/_sass/ 0000775 0000000 0000000 00000000000 13235430744 0020032 5 ustar 00root root 0000000 0000000 jekyll-sass-converter-1.5.2/docs/_sass/_typography.scss 0000664 0000000 0000000 00000001144 13235430744 0023274 0 ustar 00root root 0000000 0000000 // This is a partial.
// It lies in /_sass, just waiting to be imported.
// It does not contain the YAML front matter and has no corresponding output file in the built site.
body {
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";
font-size: 18px;
line-height: 1.5;
color: #24292e;
background-color: #fff;
}
a {
color: #0366d6;
}
code,
pre {
font-family: Menlo, Consolas, "Consolas for Powerline", "Courier New", Courier, monospace;
background-color: #2b2b2b;
color: #fff;
padding: 0.25em
}
jekyll-sass-converter-1.5.2/docs/assets/ 0000775 0000000 0000000 00000000000 13235430744 0020224 5 ustar 00root root 0000000 0000000 jekyll-sass-converter-1.5.2/docs/assets/css/ 0000775 0000000 0000000 00000000000 13235430744 0021014 5 ustar 00root root 0000000 0000000 jekyll-sass-converter-1.5.2/docs/assets/css/main.scss 0000664 0000000 0000000 00000000320 13235430744 0022630 0 ustar 00root root 0000000 0000000 ---
# this ensures Jekyll reads the file to be transformed into CSS later
# only Main files contain this front matter, not partials.
---
@import "typography";
.content {
width: 45rem;
margin: 0 auto;
}
jekyll-sass-converter-1.5.2/docs/index.md 0000664 0000000 0000000 00000001716 13235430744 0020360 0 ustar 00root root 0000000 0000000 ---
layout: default
---
# This is an example site for Sass integration in Jekyll
You have two kinds of Sass files:
1. Main files, which you wish to be output as CSS files
2. Partials, which are used by main files in `@import` statements
Main files are like pages – they go where you want them to be output, and they contain the YAML front matter (`---` lines) at the top. Partials are like hidden Jekyll data, so they go in an underscored directory, which defaults to `_sass`.
You site might look like this:
| - _sass
| - _typography.scss
| - _layout.scss
| - _colors.scss
| - assets/css
| - main.scss
| - print.scss
And so on.
The output, in your `_site` directory, would look like this:
| - assets/css
| - main.css
| - print.css
Boom! Now you have just your SCSS/Sass converted over to CSS with all the proper inputs. See also [assets section in Jekyll's documentation](https://jekyllrb.com/docs/assets/).
jekyll-sass-converter-1.5.2/jekyll-sass-converter.gemspec 0000664 0000000 0000000 00000001662 13235430744 0023612 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true
lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "jekyll-sass-converter/version"
Gem::Specification.new do |spec|
spec.name = "jekyll-sass-converter"
spec.version = JekyllSassConverter::VERSION
spec.authors = ["Parker Moore"]
spec.email = ["parkrmoore@gmail.com"]
spec.summary = "A basic Sass converter for Jekyll."
spec.homepage = "https://github.com/jekyll/jekyll-sass-converter"
spec.license = "MIT"
spec.files = `git ls-files -z`.split("\x0").grep(%r!^lib/!)
spec.require_paths = ["lib"]
spec.add_runtime_dependency "sass", "~> 3.4"
spec.add_development_dependency "bundler", "~> 1.5"
spec.add_development_dependency "jekyll", ">= 2.0"
spec.add_development_dependency "rake"
spec.add_development_dependency "rspec"
spec.add_development_dependency "rubocop", "0.51"
end
jekyll-sass-converter-1.5.2/lib/ 0000775 0000000 0000000 00000000000 13235430744 0016540 5 ustar 00root root 0000000 0000000 jekyll-sass-converter-1.5.2/lib/jekyll-sass-converter.rb 0000664 0000000 0000000 00000000251 13235430744 0023331 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true
require "jekyll-sass-converter/version"
require "jekyll/converters/scss"
require "jekyll/converters/sass"
module JekyllSassConverter
end
jekyll-sass-converter-1.5.2/lib/jekyll-sass-converter/ 0000775 0000000 0000000 00000000000 13235430744 0023006 5 ustar 00root root 0000000 0000000 jekyll-sass-converter-1.5.2/lib/jekyll-sass-converter/version.rb 0000664 0000000 0000000 00000000131 13235430744 0025013 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true
module JekyllSassConverter
VERSION = "1.5.2".freeze
end
jekyll-sass-converter-1.5.2/lib/jekyll/ 0000775 0000000 0000000 00000000000 13235430744 0020032 5 ustar 00root root 0000000 0000000 jekyll-sass-converter-1.5.2/lib/jekyll/converters/ 0000775 0000000 0000000 00000000000 13235430744 0022224 5 ustar 00root root 0000000 0000000 jekyll-sass-converter-1.5.2/lib/jekyll/converters/sass.rb 0000664 0000000 0000000 00000000476 13235430744 0023531 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true
require "sass"
require "jekyll/utils"
require "jekyll/converters/scss"
module Jekyll
module Converters
class Sass < Scss
safe true
priority :low
def matches(ext)
ext =~ %r!^\.sass$!i
end
def syntax
:sass
end
end
end
end
jekyll-sass-converter-1.5.2/lib/jekyll/converters/scss.rb 0000664 0000000 0000000 00000006372 13235430744 0023534 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true
require "sass"
require "jekyll/utils"
module Jekyll
module Converters
class Scss < Converter
BYTE_ORDER_MARK = %r!^\xEF\xBB\xBF!
SyntaxError = Class.new(ArgumentError)
safe true
priority :low
ALLOWED_STYLES = %w(nested expanded compact compressed).freeze
def matches(ext)
ext =~ %r!^\.scss$!i
end
def output_ext(_ext)
".css"
end
def safe?
!!@config["safe"]
end
def jekyll_sass_configuration
options = @config["sass"] || {}
unless options["style"].nil?
options["style"] = options["style"].to_s.gsub(%r!\A:!, "").to_sym
end
options
end
def sass_build_configuration_options(overrides)
if safe?
{
:load_paths => sass_load_paths,
:syntax => syntax,
:style => sass_style,
:cache => false,
}
else
Jekyll::Utils.symbolize_hash_keys(
Jekyll::Utils.deep_merge_hashes(
jekyll_sass_configuration,
overrides
)
)
end
end
def syntax
:scss
end
def sass_dir
return "_sass" if jekyll_sass_configuration["sass_dir"].to_s.empty?
jekyll_sass_configuration["sass_dir"]
end
def sass_style
style = jekyll_sass_configuration.fetch("style", :compact)
ALLOWED_STYLES.include?(style.to_s) ? style.to_sym : :compact
end
def user_sass_load_paths
Array(jekyll_sass_configuration["load_paths"])
end
def sass_dir_relative_to_site_source
Jekyll.sanitized_path(site_source, sass_dir)
end
def sass_load_paths
paths = user_sass_load_paths + [sass_dir_relative_to_site_source]
if safe?
# Sanitize paths to prevent any attack vectors (.e.g. `/**/*`)
paths.map! { |path| Jekyll.sanitized_path(site_source, path) }
end
# Expand file globs (e.g. `node_modules/*/node_modules` )
Dir.chdir(site_source) do
paths = paths.map { |path| Dir.glob(path) }.flatten.uniq
paths.map! do |path|
if safe?
# Sanitize again in case globbing was able to do something crazy.
Jekyll.sanitized_path(site_source, path)
else
File.expand_path(path)
end
end
end
paths.select { |path| File.directory?(path) }
end
def allow_caching?
!safe?
end
def add_charset?
!!jekyll_sass_configuration["add_charset"]
end
def sass_configs
sass_build_configuration_options({
"syntax" => syntax,
"cache" => allow_caching?,
"load_paths" => sass_load_paths,
})
end
def convert(content)
output = ::Sass.compile(content, sass_configs)
replacement = add_charset? ? '@charset "UTF-8";' : ""
output.sub(BYTE_ORDER_MARK, replacement)
rescue ::Sass::SyntaxError => e
raise SyntaxError, "#{e} on line #{e.sass_line}"
end
private
def site_source
@site_source ||= File.expand_path(@config["source"]).freeze
end
end
end
end
jekyll-sass-converter-1.5.2/script/ 0000775 0000000 0000000 00000000000 13235430744 0017276 5 ustar 00root root 0000000 0000000 jekyll-sass-converter-1.5.2/script/bootstrap 0000775 0000000 0000000 00000000063 13235430744 0021240 0 ustar 00root root 0000000 0000000 #! /bin/bash
bundle install -j8 || bundle install
jekyll-sass-converter-1.5.2/script/cibuild 0000775 0000000 0000000 00000000031 13235430744 0020631 0 ustar 00root root 0000000 0000000 #! /bin/bash
script/test
jekyll-sass-converter-1.5.2/script/release 0000775 0000000 0000000 00000000127 13235430744 0020644 0 ustar 00root root 0000000 0000000 #! /bin/bash
# Tag and push a release.
set -e
script/cibuild
bundle exec rake release
jekyll-sass-converter-1.5.2/script/spec 0000777 0000000 0000000 00000000000 13235430744 0021050 2test ustar 00root root 0000000 0000000 jekyll-sass-converter-1.5.2/script/test 0000775 0000000 0000000 00000000041 13235430744 0020176 0 ustar 00root root 0000000 0000000 #!/bin/bash
bundle exec rspec $@
jekyll-sass-converter-1.5.2/spec/ 0000775 0000000 0000000 00000000000 13235430744 0016724 5 ustar 00root root 0000000 0000000 jekyll-sass-converter-1.5.2/spec/other_sass_library/ 0000775 0000000 0000000 00000000000 13235430744 0022622 5 ustar 00root root 0000000 0000000 jekyll-sass-converter-1.5.2/spec/other_sass_library/_sass/ 0000775 0000000 0000000 00000000000 13235430744 0023732 5 ustar 00root root 0000000 0000000 jekyll-sass-converter-1.5.2/spec/other_sass_library/_sass/_color.scss 0000664 0000000 0000000 00000000030 13235430744 0026075 0 ustar 00root root 0000000 0000000 a {
color: #999999;
}
jekyll-sass-converter-1.5.2/spec/other_sass_library/css/ 0000775 0000000 0000000 00000000000 13235430744 0023412 5 ustar 00root root 0000000 0000000 jekyll-sass-converter-1.5.2/spec/other_sass_library/css/main.scss 0000664 0000000 0000000 00000000032 13235430744 0025226 0 ustar 00root root 0000000 0000000 ---
---
@import "color";
jekyll-sass-converter-1.5.2/spec/sass_converter_spec.rb 0000664 0000000 0000000 00000003752 13235430744 0023332 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true
require "spec_helper"
describe(Jekyll::Converters::Sass) do
let(:site) do
Jekyll::Site.new(site_configuration)
end
let(:content) do
<<-SASS
// tl;dr some sass
$font-stack: Helvetica, sans-serif
body
font-family: $font-stack
font-color: fuschia
SASS
end
let(:css_output) do
<<-CSS
body {\n font-family: Helvetica, sans-serif;\n font-color: fuschia; }
CSS
end
let(:invalid_content) do
<<-SASS
font-family: $font-stack;
SASS
end
def compressed(content)
content.gsub(%r!\s+!, "").gsub(%r!;}!, "}") + "\n"
end
def converter(overrides = {})
Jekyll::Converters::Sass.new(site_configuration({ "sass" => overrides }))
end
context "matching file extensions" do
it "does not match .scss files" do
expect(converter.matches(".scss")).to be_falsey
end
it "matches .sass files" do
expect(converter.matches(".sass")).to be_truthy
end
end
context "converting sass" do
it "produces CSS" do
expect(converter.convert(content)).to eql(compressed(css_output))
end
it "includes the syntax error line in the syntax error message" do
error_message = "Invalid CSS after \"$font-stack\": expected expression (e.g. 1px, bold), was \";\" on line 1"
expect do
converter.convert(invalid_content)
end.to raise_error(Jekyll::Converters::Scss::SyntaxError, error_message)
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
jekyll-sass-converter-1.5.2/spec/scss_converter_spec.rb 0000664 0000000 0000000 00000020504 13235430744 0023326 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true
require "spec_helper"
require "tmpdir"
describe(Jekyll::Converters::Scss) do
let(:site) do
Jekyll::Site.new(site_configuration)
end
let(:content) do
<<-SCSS
$font-stack: Helvetica, sans-serif;
body {
font-family: $font-stack;
font-color: fuschia;
}
SCSS
end
let(:css_output) do
<<-CSS
body {\n font-family: Helvetica, sans-serif;\n font-color: fuschia; }
CSS
end
let(:invalid_content) do
<<-SCSS
$font-stack: Helvetica
body {
font-family: $font-stack;
SCSS
end
def compressed(content)
content.gsub(%r!\s+!, "").gsub(%r!;}!, "}") + "\n"
end
def converter(overrides = {})
Jekyll::Converters::Scss.new(site_configuration({ "sass" => overrides }))
end
context "matching file extensions" do
it "matches .scss files" do
expect(converter.matches(".scss")).to be_truthy
end
it "does not match .sass files" do
expect(converter.matches(".sass")).to be_falsey
end
end
context "determining the output file extension" do
it "always outputs the .css file extension" do
expect(converter.output_ext(".always-css")).to eql(".css")
end
end
context "when building configurations" do
it "allow caching in unsafe mode" do
expect(converter.sass_configs[:cache]).to be_truthy
end
it "set the load paths to the _sass dir relative to site source" do
expect(converter.sass_configs[:load_paths]).to eql([source_dir("_sass")])
end
it "allow for other styles" do
expect(converter({ "style" => :compressed }).sass_configs[:style]).to eql(:compressed)
end
context "when specifying sass dirs" do
context "when the sass dir exists" do
it "allow the user to specify a different sass dir" do
FileUtils.mkdir(source_dir("_scss"))
expect(converter({ "sass_dir" => "_scss" }).sass_configs[:load_paths]).to eql([source_dir("_scss")])
FileUtils.rmdir(source_dir("_scss"))
end
it "not allow sass_dirs outside of site source" do
expect(
converter({ "sass_dir" => "/etc/passwd" }).sass_dir_relative_to_site_source
).to eql(source_dir("etc/passwd"))
end
end
end
context "in safe mode" do
let(:verter) do
Jekyll::Converters::Scss.new(site.config.merge({
"sass" => {},
"safe" => true,
}))
end
it "does not allow caching" do
expect(verter.sass_configs[:cache]).to be_falsey
end
it "forces load_paths to be just the local load path" do
expect(verter.sass_configs[:load_paths]).to eql([source_dir("_sass")])
end
it "allows the user to specify the style" do
allow(verter).to receive(:sass_style).and_return(:compressed)
expect(verter.sass_configs[:style]).to eql(:compressed)
end
it "defaults style to :compact" do
expect(verter.sass_configs[:style]).to eql(:compact)
end
it "only contains :syntax, :cache, :style, and :load_paths keys" do
expect(verter.sass_configs.keys).to eql([:load_paths, :syntax, :style, :cache])
end
end
end
context "converting SCSS" do
it "produces CSS" do
expect(converter.convert(content)).to eql(compressed(css_output))
end
it "includes the syntax error line in the syntax error message" do
error_message = 'Invalid CSS after "body ": expected selector or at-rule, was "{" on line 2'
expect do
converter.convert(invalid_content)
end.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
let(:test_css_file) { dest_dir("css/main.css") }
before(:each) { site.process }
it "outputs the CSS file" do
expect(File.exist?(test_css_file)).to be_truthy
end
it "imports SCSS partial" do
expect(File.read(test_css_file)).to eql(compressed(".half {\n width: 50%; }\n"))
end
it "uses a compressed style" do
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) { scss_converter_instance(site) }
let(:test_css_file) { dest_dir("css", "main.css") }
context "unsafe mode" do
let(:site) do
Jekyll::Site.new(site_configuration.merge({
"source" => sass_lib,
"sass" => {
"load_paths" => external_library,
},
}))
end
before(:each) do
FileUtils.mkdir_p(external_library) unless File.directory?(external_library)
end
after(:each) do
FileUtils.rmdir(external_library) if File.directory?(external_library)
end
it "recognizes the new load path" do
expect(verter.sass_load_paths).to include(external_library)
end
it "ensures the sass_dir is still in the load path" do
expect(verter.sass_load_paths).to include(sass_lib("_sass"))
end
it "brings in the grid partial" do
site.process
expect(File.read(test_css_file)).to eql("a {\n color: #999999; }\n")
end
context "with the sass_dir specified twice" do
let(:site) do
Jekyll::Site.new(site_configuration.merge({
"source" => sass_lib,
"sass" => {
"load_paths" => [
external_library,
sass_lib("_sass"),
],
},
}))
end
it "ensures the sass_dir only occurrs once in the load path" do
expect(verter.sass_load_paths).to eql([external_library, sass_lib("_sass")])
end
end
end
context "safe mode" do
let(:site) do
Jekyll::Site.new(site_configuration.merge({
"safe" => true,
"source" => sass_lib,
"sass" => {
"load_paths" => external_library,
},
}))
end
it "ignores the new load path" do
expect(verter.sass_load_paths).not_to include(external_library)
end
it "ensures the sass_dir is the entire load path" do
expect(verter.sass_load_paths).to eql([sass_lib("_sass")])
end
end
end
context "importing from internal libraries" do
let(:internal_library) { source_dir("bower_components/jquery") }
let(:converter) { scss_converter_instance(site) }
before(:each) do
FileUtils.mkdir_p(internal_library) unless File.directory?(internal_library)
end
after(:each) do
FileUtils.rmdir(internal_library) if File.directory?(internal_library)
end
context "unsafe mode" do
let(:site) do
Jekyll::Site.new(site_configuration.merge({
"sass" => {
"load_paths" => ["bower_components/*"],
},
}))
end
it "expands globs" do
expect(converter.sass_load_paths).to include(internal_library)
end
end
context "safe mode" do
let(:site) do
Jekyll::Site.new(site_configuration.merge({
"safe" => true,
"sass" => {
"load_paths" => [
"bower_components/*",
Dir.tmpdir,
"../..",
],
},
}))
end
it "allows local load paths" do
expect(converter.sass_load_paths).to include(internal_library)
end
it "ignores external load paths" do
expect(converter.sass_load_paths).not_to include(Dir.tmpdir)
end
it "does not allow traversing outside source directory" do
converter.sass_load_paths.each do |path|
expect(path).to include(source_dir)
expect(path).not_to include("..")
end
end
end
end
end
jekyll-sass-converter-1.5.2/spec/source/ 0000775 0000000 0000000 00000000000 13235430744 0020224 5 ustar 00root root 0000000 0000000 jekyll-sass-converter-1.5.2/spec/source/_config.yml 0000664 0000000 0000000 00000000056 13235430744 0022354 0 ustar 00root root 0000000 0000000 sass:
style: :compressed
highlighter: rouge
jekyll-sass-converter-1.5.2/spec/source/_sass/ 0000775 0000000 0000000 00000000000 13235430744 0021334 5 ustar 00root root 0000000 0000000 jekyll-sass-converter-1.5.2/spec/source/_sass/_color.scss 0000664 0000000 0000000 00000000042 13235430744 0023502 0 ustar 00root root 0000000 0000000 $black: #999;
a { color: $black; } jekyll-sass-converter-1.5.2/spec/source/_sass/_grid.scss 0000664 0000000 0000000 00000000025 13235430744 0023312 0 ustar 00root root 0000000 0000000 .half { width: 50%; } jekyll-sass-converter-1.5.2/spec/source/css/ 0000775 0000000 0000000 00000000000 13235430744 0021014 5 ustar 00root root 0000000 0000000 jekyll-sass-converter-1.5.2/spec/source/css/main.scss 0000664 0000000 0000000 00000000030 13235430744 0022626 0 ustar 00root root 0000000 0000000 ---
---
@import "grid"; jekyll-sass-converter-1.5.2/spec/spec_helper.rb 0000664 0000000 0000000 00000002213 13235430744 0021540 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true
require "fileutils"
require "jekyll"
lib = File.expand_path("lib", __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require "jekyll-sass-converter"
Jekyll.logger.log_level = :error
RSpec.configure do |config|
config.run_all_when_everything_filtered = true
config.filter_run :focus
config.order = "random"
SOURCE_DIR = File.expand_path("source", __dir__)
DEST_DIR = File.expand_path("dest", __dir__)
SASS_LIB_DIR = File.expand_path("other_sass_library", __dir__)
FileUtils.rm_rf(DEST_DIR)
FileUtils.mkdir_p(DEST_DIR)
def source_dir(*files)
File.join(SOURCE_DIR, *files)
end
def dest_dir(*files)
File.join(DEST_DIR, *files)
end
def sass_lib(*files)
File.join(SASS_LIB_DIR, *files)
end
def site_configuration(overrides = {})
Jekyll.configuration(overrides.merge({
"source" => source_dir,
"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