pax_global_header00006660000000000000000000000064142071310340014505gustar00rootroot0000000000000052 comment=41740374682ea691207c267cfbcca7ea30438b91 jekyll-sass-converter-2.2.0/000077500000000000000000000000001420713103400157545ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/.github/000077500000000000000000000000001420713103400173145ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/.github/workflows/000077500000000000000000000000001420713103400213515ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/.github/workflows/ci.yml000066400000000000000000000023621420713103400224720ustar00rootroot00000000000000name: Continuous Integration on: push: branches: - master pull_request: branches: - master jobs: ci: name: "Ruby ${{ matrix.ruby_version }} (${{ matrix.os }})" runs-on: ${{ matrix.os }} strategy: fail-fast: false matrix: os: - "ubuntu-latest" - "windows-latest" ruby_version: - "2.5" - "2.7" - "3.0" steps: - uses: actions/checkout@v2 with: fetch-depth: 5 - name: "Set up Ruby ${{ matrix.ruby_version }}" uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby_version }} bundler-cache: true - name: Execute Unit Tests run: bash script/test --force-color style_check: name: "Style Check (Ruby ${{ matrix.ruby_version }})" runs-on: "ubuntu-latest" strategy: fail-fast: false matrix: ruby_version: - 2.5 steps: - uses: actions/checkout@v2 with: fetch-depth: 5 - name: "Set up Ruby ${{ matrix.ruby_version }}" uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby_version }} bundler-cache: true - name: Run RuboCop run: bash script/fmt jekyll-sass-converter-2.2.0/.github/workflows/release.yml000066400000000000000000000014431420713103400235160ustar00rootroot00000000000000name: Release Gem on: push: branches: ["master"] paths: ["lib/**/version.rb"] jobs: release: if: "github.repository_owner == 'jekyll'" name: "Release Gem (Ruby ${{ matrix.ruby_version }})" runs-on: "ubuntu-latest" strategy: fail-fast: true matrix: ruby_version: ["2.7"] steps: - name: Checkout Repository uses: actions/checkout@v2 - name: "Set up Ruby ${{ matrix.ruby_version }}" uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby_version }} bundler-cache: true - name: Build and Publish Gem uses: ashmaroli/release-gem@dist with: gemspec_name: "jekyll-sass-converter" env: GEM_HOST_API_KEY: ${{ secrets.RUBYGEMS_GEM_PUSH_API_KEY }} jekyll-sass-converter-2.2.0/.gitignore000066400000000000000000000001311420713103400177370ustar00rootroot00000000000000.jekyll-cache .sass-cache *.gem docs/_site Gemfile.lock pkg rdoc spec/dest vendor/bundle jekyll-sass-converter-2.2.0/.rspec000066400000000000000000000000251420713103400170660ustar00rootroot00000000000000--color --format doc jekyll-sass-converter-2.2.0/.rubocop.yml000066400000000000000000000011561420713103400202310ustar00rootroot00000000000000inherit_from: .rubocop_todo.yml require: rubocop-jekyll inherit_gem: rubocop-jekyll: .rubocop.yml AllCops: TargetRubyVersion: 2.5 SuggestExtensions: false Exclude: - vendor/**/* Layout/LineEndStringConcatenationIndentation: Enabled: true Lint/EmptyInPattern: Enabled: false Naming/InclusiveLanguage: Enabled: false Performance/MapCompact: Enabled: true Performance/RedundantEqualityComparisonBlock: Enabled: true Performance/RedundantSplitRegexpArgument: Enabled: true Style/InPatternThen: Enabled: false Style/MultilineInPatternThen: Enabled: false Style/QuotedSymbols: Enabled: true jekyll-sass-converter-2.2.0/.rubocop_todo.yml000066400000000000000000000023331420713103400212540ustar00rootroot00000000000000# This configuration was generated by # `rubocop --auto-gen-config` # on 2021-09-22 14:14:54 UTC using RuboCop version 1.18.4. # The point is for the user to remove these configuration records # one by one as the offenses are removed from the code base. # Note that changes in the inspected code, or installation of new # versions of RuboCop, may require this file to be generated again. # Offense count: 3 # Configuration parameters: AllowedMethods. # AllowedMethods: enums Lint/ConstantDefinitionInBlock: Exclude: - 'spec/spec_helper.rb' # Offense count: 1 # Configuration parameters: IgnoredMethods. Metrics/CyclomaticComplexity: Max: 9 # Offense count: 1 # Configuration parameters: IgnoredMethods. Metrics/PerceivedComplexity: Max: 10 # Offense count: 1 # Cop supports --auto-correct. # Configuration parameters: SafeMultiline. Performance/DeletePrefix: Exclude: - 'lib/jekyll/converters/scss.rb' # Offense count: 1 # Cop supports --auto-correct. Style/RedundantBegin: Exclude: - 'lib/jekyll/converters/scss.rb' # Offense count: 4 # Cop supports --auto-correct. # Configuration parameters: Mode. Style/StringConcatenation: Exclude: - 'lib/jekyll/converters/scss.rb' - 'lib/jekyll/source_map_page.rb' jekyll-sass-converter-2.2.0/Gemfile000066400000000000000000000003341420713103400172470ustar00rootroot00000000000000# frozen_string_literal: true source "https://rubygems.org" gemspec gem "jekyll", ENV["JEKYLL_VERSION"] ? "~> #{ENV["JEKYLL_VERSION"]}" : ">= 4.0" gem "minima" gem "sass-embedded", "~> 1.0" if RUBY_VERSION >= "2.6.0" jekyll-sass-converter-2.2.0/History.markdown000066400000000000000000000065131420713103400211660ustar00rootroot00000000000000## 2.2.0 / 2022-02-28 ### Minor Enhancements * Support sass-embedded as alternative implementation (#124) ### Bug Fixes * Source map sources should to be relative to site.source (#119) * Sourcemaps should not be rendered by Liquid (#123) ### Development Fixes * Migrate from AppVeyor CI to GH Actions (#125) * Refactor specs to reduce repetition (#126) * Reduce overall class size (#132) * Use new sass-embedded api (#131) * Add workflow to release gem via GH Actions (#134) ### Documentation * Update CI status badge (#127) * Update `sass-embedded` info in `README.md` (#133) ## 2.1.0 / 2020-02-05 ### Development Fixes * chore(ci): use Ubuntu 18.04 (bionic) (#100) ### Minor Enhancements * Fix `Scss#sass_dir_relative_to_site_source` logic (#99) ## 2.0.1 / 2019-09-26 ### Bug Fixes * Do not register hooks for documents of type :pages (#94) * Append theme's sass path after all sanitizations (#96) ## 2.0.0 / 2019-08-14 ### Major Enhancements * Migrate to sassc gem (#75) * Use and test sassc-2.1.0 pre-releases and beyond (#86) * Drop support for Ruby 2.3 (#90) ### Minor Enhancements * Generate Sass Sourcemaps (#79) * Configure Sass to load from theme-gem if possible (#80) * SyntaxError line and filename are set by SassC (#85) * Memoize #jekyll_sass_configuration (#82) ### Development Fixes * Target Ruby 2.3 (#70) * Lint with rubocop-jekyll (#73) * Clear out RuboCop TODO (#87) * Cache stateless regexes in class constants (#83) * Add appveyor.yml (#76) ### Bug Fixes * Fix rendering of sourcemap page (#89) ## 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-2.2.0/LICENSE.txt000066400000000000000000000021401420713103400175740ustar00rootroot00000000000000Copyright (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-2.2.0/README.md000066400000000000000000000107041420713103400172350ustar00rootroot00000000000000# Jekyll Sass Converter Let Jekyll build your Sass and SCSS! [![Continuous Integration](https://github.com/jekyll/jekyll-sass-converter/actions/workflows/ci.yml/badge.svg)](https://github.com/jekyll/jekyll-sass-converter/actions/workflows/ci.yml) ## 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](https://jekyllrb.com/docs/assets/). ### Sass Implementations #### SassC By default, Jekyll Sass Converter uses [sassc](https://rubygems.org/gems/sassc) for Sass implmentation. `sassc` is based on LibSass, and [LibSass is deprecated](https://sass-lang.com/blog/libsass-is-deprecated). #### Sass Embedded [sass-embedded](https://rubygems.org/gems/sass-embedded) is a host for the [Sass embedded protocol](https://github.com/sass/embedded-protocol). The host runs [Dart Sass compiler](https://github.com/sass/dart-sass-embedded) as a subprocess and communicates with the dart-sass compiler by sending / receiving [protobuf](https://github.com/protocolbuffers/protobuf) messages via the standard input-output channel. To use the `sass-embedded` implementation, you need to first install the `sass-embedded` gem either via your `Gemfile` and Bundler, or directly. Add this line to your application's Gemfile: gem 'sass-embedded', '~> 1.0' And then execute: $ bundle Or install it yourself as: $ gem install sass-embedded Then, you have to specify `sass-embedded` as the desired implementation in your `_config.yml`: ```yaml sass: implementation: sass-embedded ``` ### Source Maps Starting with `v2.0`, the Converter will by default generate a _source map_ file along with the `.css` output file. The _source map_ is useful when we use the web developers tools of [Chrome](https://developers.google.com/web/tools/chrome-devtools/) or [Firefox](https://developer.mozilla.org/en-US/docs/Tools) to debug our `.sass` or `.scss` stylesheets. The _source map_ is a file that maps from the output `.css` file to the original source `.sass` or `.scss` style sheets. Thus enabling the browser to reconstruct the original source and present the reconstructed original in the debugger. ### Configuration Options Configuration options are specified in the `_config.yml` file in the following way: ```yml sass: : : ``` Available options are: * **`implementation`** Sets the Sass implementation to use. Can be `sassc` or `sass-embedded`. Defaults to `sassc`. * **`style`** Sets the style of the CSS-output. Can be `nested`, `compact`, `compressed`, or `expanded`. See the [SASS_REFERENCE](https://sass-lang.com/documentation/cli/dart-sass#style) for details. Defaults to `compact` for `sassc`. Defaults to `expanded` for `sass-embedded`. * **`sass_dir`** A filesystem-path which should be searched for Sass partials. Defaults to `_sass` * **`load_paths`** An array of additional filesystem-paths which should be searched for Sass partials. Defaults to `[]` * **`line_comments`** When set to _true_, the line number and filename of the source is included in the compiled CSS-file. Useful for debugging when the _source map_ is not available, but might considerably increase the size of the generated CSS files. Defaults to `false`. * **`sourcemap`** Controls when source maps shall be generated. - `never` — causes no source maps to be generated at all. - `always` — source maps will always be generated. - `development` — source maps will only be generated if the site is in development [environment](https://jekyllrb.com/docs/configuration/environments/). That is, when the environment variable `JEKYLL_ENV` is set to `development`. Defaults to `always`. ## Contributing 1. Fork it ( https://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-2.2.0/Rakefile000066400000000000000000000000731420713103400174210ustar00rootroot00000000000000# frozen_string_literal: true require "bundler/gem_tasks" jekyll-sass-converter-2.2.0/docs/000077500000000000000000000000001420713103400167045ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/docs/README.md000066400000000000000000000016071420713103400201670ustar00rootroot00000000000000--- 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-2.2.0/docs/_config.yml000066400000000000000000000001151420713103400210300ustar00rootroot00000000000000sass: style: compact # possible values: nested expanded compact compressed jekyll-sass-converter-2.2.0/docs/_layouts/000077500000000000000000000000001420713103400205435ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/docs/_layouts/default.html000066400000000000000000000004031420713103400230520ustar00rootroot00000000000000 Sass Example Site
{{ content }}
jekyll-sass-converter-2.2.0/docs/_sass/000077500000000000000000000000001420713103400200145ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/docs/_sass/_typography.scss000066400000000000000000000011441420713103400232560ustar00rootroot00000000000000// 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-2.2.0/docs/assets/000077500000000000000000000000001420713103400202065ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/docs/assets/css/000077500000000000000000000000001420713103400207765ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/docs/assets/css/main.scss000066400000000000000000000003201420713103400226120ustar00rootroot00000000000000--- # 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-2.2.0/docs/index.md000066400000000000000000000017161420713103400203420ustar00rootroot00000000000000--- 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-2.2.0/jekyll-sass-converter.gemspec000066400000000000000000000015431420713103400235720ustar00rootroot00000000000000# frozen_string_literal: true require_relative "lib/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.required_ruby_version = ">= 2.5.0" spec.add_runtime_dependency "sassc", "> 2.0.1", "< 3.0" spec.add_development_dependency "bundler" spec.add_development_dependency "rake" spec.add_development_dependency "rspec" spec.add_development_dependency "rubocop-jekyll", "~> 0.12.0" end jekyll-sass-converter-2.2.0/lib/000077500000000000000000000000001420713103400165225ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/lib/jekyll-sass-converter.rb000066400000000000000000000002511420713103400233130ustar00rootroot00000000000000# frozen_string_literal: true require "jekyll-sass-converter/version" require "jekyll/converters/scss" require "jekyll/converters/sass" module JekyllSassConverter end jekyll-sass-converter-2.2.0/lib/jekyll-sass-converter/000077500000000000000000000000001420713103400227705ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/lib/jekyll-sass-converter/version.rb000066400000000000000000000001221420713103400247750ustar00rootroot00000000000000# frozen_string_literal: true module JekyllSassConverter VERSION = "2.2.0" end jekyll-sass-converter-2.2.0/lib/jekyll/000077500000000000000000000000001420713103400200145ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/lib/jekyll/converters/000077500000000000000000000000001420713103400222065ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/lib/jekyll/converters/sass.rb000066400000000000000000000004601420713103400235040ustar00rootroot00000000000000# frozen_string_literal: true require "sassc" require "jekyll/utils" require "jekyll/converters/scss" module Jekyll module Converters class Sass < Scss EXTENSION_PATTERN = %r!^\.sass$!i.freeze safe true priority :low def syntax :sass end end end end jekyll-sass-converter-2.2.0/lib/jekyll/converters/scss.rb000066400000000000000000000275071420713103400235210ustar00rootroot00000000000000# frozen_string_literal: true require "sassc" require "jekyll/utils" require "jekyll/source_map_page" module Jekyll module Converters class Scss < Converter BYTE_ORDER_MARK = %r!^\xEF\xBB\xBF!.freeze EXTENSION_PATTERN = %r!^\.scss$!i.freeze SyntaxError = Class.new(ArgumentError) safe true priority :low # This hook is triggered just before the method {#convert(content)} is executed, it # associates the Scss (and Sass) converters with their respective sass_page objects. Jekyll::Hooks.register :pages, :pre_render do |page| next unless page.is_a?(Jekyll::Page) page.converters.each do |converter| converter.associate_page(page) if converter.is_a?(Jekyll::Converters::Scss) end end # This hook is triggered just after the method {#convert(content)} has been executed, it # dissociates the Scss (and Sass) converters with their respective sass_page objects. Jekyll::Hooks.register :pages, :post_render do |page| next unless page.is_a?(Jekyll::Page) page.converters.each do |converter| converter.dissociate_page(page) if converter.is_a?(Jekyll::Converters::Scss) end end ALLOWED_IMPLEMENTATIONS = %w(sassc sass-embedded).freeze ALLOWED_STYLES = %w(nested expanded compact compressed).freeze # Associate this Converter with the "page" object that manages input and output files for # this converter. # # Note: changing the associated sass_page during the live time of this Converter instance # may result in inconsistent results. # # @param [Jekyll:Page] page The sass_page for which this object acts as converter. def associate_page(page) if @sass_page Jekyll.logger.debug "Sass Converter:", "sass_page re-assigned: #{@sass_page.name} to #{page.name}" dissociate_page(page) return end @sass_page = page end # Dissociate this Converter with the "page" object. # # @param [Jekyll:Page] page The sass_page for which this object has acted as a converter. def dissociate_page(page) unless page.equal?(@sass_page) Jekyll.logger.debug "Sass Converter:", "dissociating a page that was never associated #{page.name}" end @source_map_page = nil @sass_page = nil @site = nil end def matches(ext) ext =~ self.class::EXTENSION_PATTERN end def output_ext(_ext) ".css" end def safe? !!@config["safe"] end def jekyll_sass_configuration @jekyll_sass_configuration ||= begin options = @config["sass"] || {} unless options["style"].nil? options["style"] = options["style"].to_s.gsub(%r!\A:!, "").to_sym end options end end def sass_build_configuration_options(overrides) return overrides if safe? Jekyll::Utils.symbolize_hash_keys( Jekyll::Utils.deep_merge_hashes(jekyll_sass_configuration, overrides) ) 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_implementation implementation = jekyll_sass_configuration["implementation"] ALLOWED_IMPLEMENTATIONS.include?(implementation) ? implementation : "sassc" end def sass_style # `:expanded` is the default output style for newer sass implementations. # For backward compatibility, `:compact` is kept as the default output style for sassc. default = sass_implementation == "sassc" ? :compact : :expanded style = jekyll_sass_configuration.fetch("style", default) ALLOWED_STYLES.include?(style.to_s) ? style.to_sym : default end def user_sass_load_paths Array(jekyll_sass_configuration["load_paths"]) end def sass_dir_relative_to_site_source @sass_dir_relative_to_site_source ||= begin Jekyll.sanitized_path(site_source, sass_dir).sub(site.source + "/", "") end end # rubocop:disable Metrics/AbcSize def sass_load_paths paths = user_sass_load_paths + [sass_dir_relative_to_site_source] # Sanitize paths to prevent any attack vectors (.e.g. `/**/*`) paths.map! { |path| Jekyll.sanitized_path(site_source, path) } if safe? # Expand file globs (e.g. `node_modules/*/node_modules` ) Dir.chdir(site_source) do paths = paths.flat_map { |path| Dir.glob(path) } paths.map! do |path| # Sanitize again in case globbing was able to do something crazy. safe? ? Jekyll.sanitized_path(site_source, path) : File.expand_path(path) end end paths.uniq! paths << site.theme.sass_path if site.theme&.sass_path paths.select { |path| File.directory?(path) } end # rubocop:enable Metrics/AbcSize def allow_caching? !safe? end def add_charset? !!jekyll_sass_configuration["add_charset"] end def sass_configs sass_build_configuration_options( :style => sass_style, :syntax => syntax, :filename => filename, :output_path => output_path, :source_map_file => source_map_file, :load_paths => sass_load_paths, :omit_source_map_url => !sourcemap_required?, :source_map_contents => true, :line_comments_option => line_comments_option ) end def convert(content) case sass_implementation when "sass-embedded" Jekyll::External.require_with_graceful_fail("sass-embedded") sass_embedded_convert(content) when "sassc" sass_convert(content) end end private def sass_convert(content) config = sass_configs engine = SassC::Engine.new(content.dup, config) output = engine.render sass_generate_source_map(engine) if sourcemap_required? replacement = add_charset? ? '@charset "UTF-8";' : "" output.sub(BYTE_ORDER_MARK, replacement) rescue SassC::SyntaxError => e raise SyntaxError, e.to_s end def sass_embedded_config { :load_paths => sass_load_paths, :source_map => sourcemap_required?, :source_map_include_sources => true, :style => sass_style, :syntax => syntax == :sass ? :indented : syntax, :url => sass_file_url, } end def sass_embedded_convert(content) output = ::Sass.compile_string(content, **sass_embedded_config) sass_embedded_generate_source_map(output.source_map) if sourcemap_required? replacement = add_charset? ? '@charset "UTF-8";' : "" source_mapping_url = Addressable::URI.encode(File.basename(source_map_file)) eof = sourcemap_required? ? "\n\n/*# sourceMappingURL=#{source_mapping_url} */" : "\n" output.css.sub(BYTE_ORDER_MARK, replacement) + eof rescue ::Sass::CompileError => e Jekyll.logger.error e.full_message raise SyntaxError, e.message end # The Page instance for which this object acts as a converter. attr_reader :sass_page def associate_page_failed? !sass_page end # The name of the input scss (or sass) file. This information will be used for error # reporting and will written into the source map file as main source. # # Returns the name of the input file or "stdin" if #associate_page failed def filename return "stdin" if associate_page_failed? File.join(site_source_relative_from_pwd, sass_page.name) end # The URL of the input scss (or sass) file. This information will be used for error reporting. def sass_file_url return if associate_page_failed? file_url_from_path(File.join(site_source, sass_page.relative_path)) end # The value of the `line_comments` option. # When set to `true` causes the line number and filename of the source be emitted into the # compiled CSS-file. Useful for debugging when the source-map is not available. # # Returns the value of the `line_comments`-option chosen by the user or 'false' by default. def line_comments_option jekyll_sass_configuration.fetch("line_comments", false) end # The value of the `sourcemap` option chosen by the user. # # This option controls when sourcemaps shall be generated or not. # # Returns the value of the `sourcemap`-option chosen by the user or ':always' by default. def sourcemap_option jekyll_sass_configuration.fetch("sourcemap", :always).to_sym end # Determines whether a sourcemap shall be generated or not. # # Returns `true` if a sourcemap shall be generated, `false` otherwise. def sourcemap_required? return false if associate_page_failed? || sourcemap_option == :never return true if sourcemap_option == :always !(sourcemap_option == :development && Jekyll.env != "development") end # The name of the generated css file. This information will be written into the source map # file as a backward reference to the input. # # Returns the name of the css file or "stdin.css" if #associate_page failed def output_path return "stdin.css" if associate_page_failed? File.join(site_source_relative_from_pwd, sass_page.basename + ".css") end # The name of the generated source map file. This information will be written into the # css file to reference to the source map. # # Returns the name of the css file or "" if #associate_page failed def source_map_file return "" if associate_page_failed? File.join(site_source_relative_from_pwd, sass_page.basename + ".css.map") end def source_map_page return if associate_page_failed? @source_map_page ||= SourceMapPage.new(sass_page) end # Reads the source-map from the engine and adds it to the source-map-page. # # @param [::SassC::Engine] engine The sass Compiler engine. def sass_generate_source_map(engine) return if associate_page_failed? source_map_page.source_map(engine.source_map) site.pages << source_map_page rescue ::SassC::NotRenderedError => e Jekyll.logger.warn "Could not generate source map #{e.message} => #{e.cause}" end # Reads the source-map and adds it to the source-map-page. def sass_embedded_generate_source_map(source_map) return if associate_page_failed? map_data = JSON.parse(source_map) map_data["file"] = Addressable::URI.encode(File.basename(output_path)) map_data["sources"].map! do |s| s.start_with?("file:") ? Addressable::URI.parse(s).route_from(site_source_url) : s end source_map_page.source_map(JSON.generate(map_data)) site.pages << source_map_page end def site associate_page_failed? ? Jekyll.sites.last : sass_page.site end def site_source site.source end def site_source_relative_from_pwd @site_source_relative_from_pwd ||= Pathname.new(site_source).relative_path_from(Pathname.new(Dir.pwd)).to_s end def site_source_url @site_source_url ||= file_url_from_path("#{site_source}/") end def file_url_from_path(path) Addressable::URI.encode("file://#{path.start_with?("/") ? "" : "/"}#{path}") end end end end jekyll-sass-converter-2.2.0/lib/jekyll/source_map_page.rb000066400000000000000000000015311420713103400234720ustar00rootroot00000000000000# frozen_string_literal: true module Jekyll # A Jekyll::Page subclass to manage the source map file associated with # a given scss / sass page. class SourceMapPage < Page # Initialize a new SourceMapPage. # # @param [Jekyll::Page] css_page The Page object that manages the css file. def initialize(css_page) @site = css_page.site @dir = css_page.dir @data = css_page.data @name = css_page.basename + ".css.map" process(@name) Jekyll::Hooks.trigger :pages, :post_init, self end def source_map(map) self.content = map end def ext ".map" end def asset_file? true end def render_with_liquid? false end # @return[String] the object as a debug String. def inspect "#<#{self.class} @name=#{name.inspect}>" end end end jekyll-sass-converter-2.2.0/script/000077500000000000000000000000001420713103400172605ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/script/bootstrap000077500000000000000000000000731420713103400212230ustar00rootroot00000000000000#! /bin/bash set -e bundle install -j8 || bundle install jekyll-sass-converter-2.2.0/script/cibuild000077500000000000000000000000551420713103400206210ustar00rootroot00000000000000#! /bin/bash set -e script/test script/fmt jekyll-sass-converter-2.2.0/script/fmt000077500000000000000000000003461420713103400177770ustar00rootroot00000000000000#!/bin/bash echo "RuboCop $(bundle exec rubocop --version)" bundle exec rubocop -D $@ success=$? if ((success != 0)); then echo -e "\nTry running \`script/fmt --safe-auto-correct\` to automatically fix errors" fi exit $success jekyll-sass-converter-2.2.0/script/release000077500000000000000000000001271420713103400206260ustar00rootroot00000000000000#! /bin/bash # Tag and push a release. set -e script/cibuild bundle exec rake release jekyll-sass-converter-2.2.0/script/spec000077700000000000000000000000001420713103400210322testustar00rootroot00000000000000jekyll-sass-converter-2.2.0/script/test000077500000000000000000000003561420713103400201710ustar00rootroot00000000000000#!/bin/bash set -e echo "Running rspec with sassc" SASS_IMPLEMENTATION=sassc bundle exec rspec $@ if bundle info sass-embedded; then echo "Running rspec with sass-embedded" SASS_IMPLEMENTATION=sass-embedded bundle exec rspec $@ fi jekyll-sass-converter-2.2.0/spec/000077500000000000000000000000001420713103400167065ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/spec/[alpha]beta/000077500000000000000000000000001420713103400211175ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/spec/[alpha]beta/_config.yml000066400000000000000000000000561420713103400232470ustar00rootroot00000000000000sass: style: :compressed highlighter: rouge jekyll-sass-converter-2.2.0/spec/[alpha]beta/_sass/000077500000000000000000000000001420713103400222275ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/spec/[alpha]beta/_sass/_color.scss000066400000000000000000000000421420713103400243750ustar00rootroot00000000000000$black: #999; a { color: $black } jekyll-sass-converter-2.2.0/spec/[alpha]beta/_sass/_grid.scss000066400000000000000000000000251420713103400242050ustar00rootroot00000000000000.half { width: 50% } jekyll-sass-converter-2.2.0/spec/[alpha]beta/css/000077500000000000000000000000001420713103400217075ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/spec/[alpha]beta/css/main.scss000066400000000000000000000000311420713103400235220ustar00rootroot00000000000000--- --- @import "grid"; jekyll-sass-converter-2.2.0/spec/nested_source/000077500000000000000000000000001420713103400215505ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/spec/nested_source/src/000077500000000000000000000000001420713103400223375ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/spec/nested_source/src/_config.yml000066400000000000000000000000561420713103400244670ustar00rootroot00000000000000sass: style: :compressed highlighter: rouge jekyll-sass-converter-2.2.0/spec/nested_source/src/_sass/000077500000000000000000000000001420713103400234475ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/spec/nested_source/src/_sass/_color.scss000066400000000000000000000000431420713103400256160ustar00rootroot00000000000000$black: #999; a { color: $black; } jekyll-sass-converter-2.2.0/spec/nested_source/src/_sass/_grid.scss000066400000000000000000000000261420713103400254260ustar00rootroot00000000000000.half { width: 50%; } jekyll-sass-converter-2.2.0/spec/nested_source/src/css/000077500000000000000000000000001420713103400231275ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/spec/nested_source/src/css/main.scss000066400000000000000000000000311420713103400247420ustar00rootroot00000000000000--- --- @import "grid"; jekyll-sass-converter-2.2.0/spec/other_sass_library/000077500000000000000000000000001420713103400226045ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/spec/other_sass_library/_sass/000077500000000000000000000000001420713103400237145ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/spec/other_sass_library/_sass/_color.scss000066400000000000000000000000301420713103400260570ustar00rootroot00000000000000a { color: #999999; } jekyll-sass-converter-2.2.0/spec/other_sass_library/css/000077500000000000000000000000001420713103400233745ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/spec/other_sass_library/css/main.scss000066400000000000000000000000321420713103400252100ustar00rootroot00000000000000--- --- @import "color"; jekyll-sass-converter-2.2.0/spec/pages-collection/000077500000000000000000000000001420713103400221365ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/spec/pages-collection/_pages/000077500000000000000000000000001420713103400233745ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/spec/pages-collection/_pages/test.md000066400000000000000000000000521420713103400246720ustar00rootroot00000000000000--- title: Test Document --- Hello World jekyll-sass-converter-2.2.0/spec/pages-collection/_sass/000077500000000000000000000000001420713103400232465ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/spec/pages-collection/_sass/_color.scss000066400000000000000000000000431420713103400254150ustar00rootroot00000000000000$black: #999; a { color: $black; } jekyll-sass-converter-2.2.0/spec/pages-collection/_sass/_grid.scss000066400000000000000000000000261420713103400252250ustar00rootroot00000000000000.half { width: 50%; } jekyll-sass-converter-2.2.0/spec/pages-collection/css/000077500000000000000000000000001420713103400227265ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/spec/pages-collection/css/main.scss000066400000000000000000000000311420713103400245410ustar00rootroot00000000000000--- --- @import "grid"; jekyll-sass-converter-2.2.0/spec/sass_converter_spec.rb000066400000000000000000000066571420713103400233230ustar00rootroot00000000000000# frozen_string_literal: true require "spec_helper" describe(Jekyll::Converters::Sass) do let(:site) do Jekyll::Site.new(site_configuration) end let(:sass_converter) do sass_converter_instance(site) 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(:expanded_css_output) do <<~CSS body { font-family: Helvetica, sans-serif; font-color: fuschia; } CSS end let(:compact_css_output) do <<~CSS body { font-family: Helvetica, sans-serif; font-color: fuschia; } CSS end let(:invalid_content) do <<~SASS font-family: $font-stack; SASS end def converter(overrides = {}) sass_converter_instance(site).dup.tap do |obj| obj.instance_variable_get(:@config)["sass"] = overrides end 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 expected = sass_embedded? ? expanded_css_output : compact_css_output expect(converter.convert(content)).to eql(expected) end it "includes the syntax error line in the syntax error message" do expected = if sass_embedded? %r!Expected newline!i else error_message = 'Error: Invalid CSS after "f": expected 1 selector or at-rule.' %r!\A#{error_message} was "font-family: \$font-"\s+on line 1:1 of stdin! end expect do converter.convert(invalid_content) end.to raise_error(Jekyll::Converters::Scss::SyntaxError, expected) 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 unless asked to" do overrides = { "style" => :compressed, "add_charset" => true } result = converter(overrides).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 context "in a site with a collection labelled 'pages'" do let(:site) do make_site( "source" => File.expand_path("pages-collection", __dir__), "sass" => { "style" => :expanded, }, "collections" => { "pages" => { "output" => true, }, } ) end it "produces CSS without raising errors" do expect { site.process }.not_to raise_error expect(sass_converter.convert(content)).to eql(expanded_css_output) end end context "in a site nested inside directory with square brackets" do let(:site) do make_site( "source" => File.expand_path("[alpha]beta", __dir__), "sass" => { "style" => :expanded, } ) end it "produces CSS without raising errors" do expect { site.process }.not_to raise_error expect(sass_converter.convert(content)).to eql(expanded_css_output) end end end jekyll-sass-converter-2.2.0/spec/scss_converter_spec.rb000066400000000000000000000310241420713103400233070ustar00rootroot00000000000000# frozen_string_literal: true require "spec_helper" require "tmpdir" describe(Jekyll::Converters::Scss) do let(:site) do Jekyll::Site.new(site_configuration) end let(:scss_converter) do scss_converter_instance(site) end let(:content) do <<~SCSS $font-stack: Helvetica, sans-serif; body { font-family: $font-stack; font-color: fuschia; } SCSS end let(:expanded_css_output) do <<~CSS body { font-family: Helvetica, sans-serif; font-color: fuschia; } CSS end let(:compact_css_output) do <<~CSS body { font-family: Helvetica, sans-serif; font-color: fuschia; } CSS end let(:invalid_content) do <<~SCSS $font-stack: Helvetica body { font-family: $font-stack; SCSS end def converter(overrides = {}) scss_converter_instance(site).dup.tap do |obj| obj.instance_variable_get(:@config)["sass"] = overrides end 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 # Caching is no more a feature with sassC # 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 create_directory(source_dir("_scss")) override = { "sass_dir" => "_scss" } expect(converter(override).sass_configs[:load_paths]).to eql([source_dir("_scss")]) remove_directory(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("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 :expanded for sass-embedded or :compact for sassc" do expected = sass_embedded? ? :expanded : :compact expect(verter.sass_configs[:style]).to eql(expected) end it "at least contains :syntax and :load_paths keys" do expect(verter.sass_configs.keys).to include(:load_paths, :syntax) end end end context "converting SCSS" do it "produces CSS" do expected = sass_embedded? ? expanded_css_output : compact_css_output expect(converter.convert(content)).to eql(expected) end it "includes the syntax error line in the syntax error message" do expected = if sass_embedded? %r!expected ";"!i else error_message = 'Error: Invalid CSS after "body": expected 1 selector or at-rule' %r!\A#{error_message}, was "{"\s+on line 2! end expect { scss_converter.convert(invalid_content) }.to( raise_error(Jekyll::Converters::Scss::SyntaxError, expected) ) 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 overrides = { "style" => :compressed, "add_charset" => true } result = converter(overrides).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( ".half{width:50%}\n\n/*# sourceMappingURL=main.css.map */" ) 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(:test_css_file) { dest_dir("css", "main.css") } context "in unsafe mode" do let(:site) do make_site( "source" => sass_lib, "sass" => { "load_paths" => external_library, } ) end before(:each) { create_directory external_library } after(:each) { remove_directory external_library } it "recognizes the new load path" do expect(scss_converter.sass_load_paths).to include(external_library) end it "ensures the sass_dir is still in the load path" do expect(scss_converter.sass_load_paths).to include(sass_lib("_sass")) end it "brings in the grid partial" do site.process expected = if sass_embedded? "a {\n color: #999999;\n}\n\n/*# sourceMappingURL=main.css.map */" else "a { color: #999999; }\n\n/*# sourceMappingURL=main.css.map */" end expect(File.read(test_css_file)).to eql(expected) end context "with the sass_dir specified twice" do let(:site) do make_site( "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(scss_converter.sass_load_paths).to eql([external_library, sass_lib("_sass")]) end end end context "in safe mode" do let(:site) do make_site( "safe" => true, "source" => sass_lib, "sass" => { "load_paths" => external_library, } ) end it "ignores the new load path" do expect(scss_converter.sass_load_paths).not_to include(external_library) end it "ensures the sass_dir is the entire load path" do expect(scss_converter.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") } before(:each) { create_directory internal_library } after(:each) { remove_directory internal_library } context "in unsafe mode" do let(:site) do make_site( "sass" => { "load_paths" => ["bower_components/*"], } ) end it "expands globs" do expect(scss_converter.sass_load_paths).to include(internal_library) end end context "in safe mode" do let(:site) do make_site( "safe" => true, "sass" => { "load_paths" => [ Dir.tmpdir, "bower_components/*", "../..", ], } ) end it "allows local load paths" do expect(scss_converter.sass_load_paths).to include(internal_library) end it "ignores external load paths" do expect(scss_converter.sass_load_paths).not_to include(Dir.tmpdir) end it "does not allow traversing outside source directory" do scss_converter.sass_load_paths.each do |path| expect(path).to include(source_dir) expect(path).not_to include("..") end end end end context "with valid sass paths in a theme" do context "in unsafe mode" do let(:site) do make_site("theme" => "minima") end it "includes the theme's sass directory" do expect(site.theme.sass_path).to be_truthy expect(scss_converter.sass_load_paths).to include(site.theme.sass_path) end end context "in safe mode" do let(:site) do make_site( "theme" => "minima", "safe" => true ) end it "includes the theme's sass directory" do expect(site.safe).to be true expect(site.theme.sass_path).to be_truthy expect(converter.sass_load_paths).to include(site.theme.sass_path) end end end context "in a site with a collection labelled 'pages'" do let(:site) do make_site( "source" => File.expand_path("pages-collection", __dir__), "sass" => { "style" => :expanded, }, "collections" => { "pages" => { "output" => true, }, } ) end it "produces CSS without raising errors" do expect { site.process }.not_to raise_error expect(scss_converter.convert(content)).to eql(expanded_css_output) end end context "in a site nested inside directory with square brackets" do let(:site) do make_site( "source" => File.expand_path("[alpha]beta", __dir__), "sass" => { "style" => :expanded, } ) end it "produces CSS without raising errors" do expect { site.process }.not_to raise_error expect(scss_converter.convert(content)).to eql(expanded_css_output) end end context "generating sourcemap" do let(:sourcemap_file) { dest_dir("css/app.css.map") } let(:sourcemap_contents) { File.binread(sourcemap_file) } before { site.process } it "outputs the sourcemap file" do expect(File.exist?(sourcemap_file)).to be true end it "should not have Liquid expressions rendered" do expect(sourcemap_contents).to include("{{ site.mytheme.skin }}") end context "in a site with source not equal to its default value of `Dir.pwd`" do let(:site) do make_site( "source" => File.expand_path("nested_source/src", __dir__) ) end let(:test_sourcemap_file) { dest_dir("css/main.css.map") } let(:sourcemap_data) { JSON.parse(File.binread(test_sourcemap_file)) } before(:each) { site.process } it "outputs the sourcemap file" do expect(File.exist?(test_sourcemap_file)).to be_truthy end it "contains relevant sass sources" do sources = sourcemap_data["sources"] # sass-embedded (dart-sass) does not inlcude main.scss in sources # because main.scss only contains @import statements # thus there is no actual scss code to be mapped expect(sources).to include("main.scss") unless sass_embedded? expect(sources).to include("_sass/_grid.scss") expect(sources).to_not include("_sass/_color.scss") # not imported into "main.scss" end it "does not leak directory structure outside of `site.source`" do site_source_relative_from_pwd = \ Pathname.new(site.source) .relative_path_from(Pathname.new(Dir.pwd)) .to_s relative_path_parts = site_source_relative_from_pwd.split(File::SEPARATOR) expect(site_source_relative_from_pwd).to eql("spec/nested_source/src") expect(relative_path_parts).to eql(%w(spec nested_source src)) relative_path_parts.each do |dirname| sourcemap_data["sources"].each do |fpath| expect(fpath).to_not include(dirname) end end end end end end jekyll-sass-converter-2.2.0/spec/source/000077500000000000000000000000001420713103400202065ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/spec/source/_config.yml000066400000000000000000000000561420713103400223360ustar00rootroot00000000000000sass: style: :compressed highlighter: rouge jekyll-sass-converter-2.2.0/spec/source/_sass/000077500000000000000000000000001420713103400213165ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/spec/source/_sass/_color.scss000066400000000000000000000001741420713103400234720ustar00rootroot00000000000000// {% debug %}This is a comment.{% enddebug %} // Import using {{ site.mytheme.skin }}. $black: #999; a { color: $black; } jekyll-sass-converter-2.2.0/spec/source/_sass/_grid.scss000066400000000000000000000000251420713103400232740ustar00rootroot00000000000000.half { width: 50%; }jekyll-sass-converter-2.2.0/spec/source/css/000077500000000000000000000000001420713103400207765ustar00rootroot00000000000000jekyll-sass-converter-2.2.0/spec/source/css/app.scss000066400000000000000000000000321420713103400224460ustar00rootroot00000000000000--- --- @import "color"; jekyll-sass-converter-2.2.0/spec/source/css/main.scss000066400000000000000000000000301420713103400226100ustar00rootroot00000000000000--- --- @import "grid";jekyll-sass-converter-2.2.0/spec/spec_helper.rb000066400000000000000000000040261420713103400215260ustar00rootroot00000000000000# 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 module GlobalSharedContext extend RSpec::SharedContext let(:sass_implementation) { ENV["SASS_IMPLEMENTATION"] } let(:sass_embedded?) { sass_implementation == "sass-embedded" } end RSpec.configure do |config| config.run_all_when_everything_filtered = true config.filter_run :focus config.order = "random" config.include GlobalSharedContext config.before(:example) do if sass_implementation allow_any_instance_of(Jekyll::Converters::Scss) .to(receive(:sass_implementation).and_return(sass_implementation)) end end 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 # rubocop:disable Style/StringConcatenation def compressed(content) content.gsub(%r!\s+!, "").gsub(%r!;}!, "}") + "\n" end # rubocop:enable Style/StringConcatenation def make_site(config) Jekyll::Site.new(site_configuration.merge(config)) end def scss_converter_instance(site) site.find_converter_instance(Jekyll::Converters::Scss) end def sass_converter_instance(site) site.find_converter_instance(Jekyll::Converters::Sass) end def create_directory(location) FileUtils.mkdir_p(location) unless File.directory?(location) end def remove_directory(location) FileUtils.rmdir(location) if File.directory?(location) end end