Skip to content
Permalink
Browse files

Extract nanoc-sass gem

  • Loading branch information
ddfreyne committed Dec 1, 2019
1 parent c7c4f54 commit fc265e810ac1cfea5ff79b6a85fe65a145b0bbc3
@@ -140,7 +140,7 @@ RSpec/RepeatedDescription:
# Offense count: 2
RSpec/RepeatedExample:
Exclude:
- 'nanoc/spec/nanoc/filters/sass_spec.rb'
- 'nanoc-sass/spec/nanoc/sass_spec.rb'

# Offense count: 9
RSpec/ScatteredLet:
@@ -9,6 +9,7 @@ gemspec path: 'nanoc-checking'
gemspec path: 'nanoc-deploying'
gemspec path: 'nanoc-external'
gemspec path: 'nanoc-live'
gemspec path: 'nanoc-sass'
gemspec path: 'nanoc-spec'
gemspec path: 'guard-nanoc'

@@ -24,6 +24,7 @@ packages = %w[
nanoc-deploying
nanoc-external
nanoc-live
nanoc-sass
nanoc-spec
guard-nanoc
]
@@ -0,0 +1,3 @@
-r ./spec/spec_helper.rb
--format Fuubar
--color
@@ -0,0 +1,19 @@
Copyright (c) 2014–… Denis Defreyne and contributors

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.
@@ -0,0 +1,5 @@
# nanoc-sass news

## 1.0.0 (2019-11-17)

Initial release (extracted from nanoc)
@@ -0,0 +1,3 @@
# nanoc-sass

This provides the `sass` filter for [Nanoc](https://nanoc.ws).
@@ -0,0 +1,18 @@
# frozen_string_literal: true

require 'rspec/core/rake_task'
require 'rubocop/rake_task'

RuboCop::RakeTask.new(:rubocop)

RSpec::Core::RakeTask.new(:spec) do |t|
t.verbose = false
end

task test: :spec

task :gem do
sh('gem build *.gemspec')
end

task default: %i[test rubocop]
@@ -0,0 +1,3 @@
# frozen_string_literal: true

require 'nanoc/sass'
@@ -0,0 +1,11 @@
# frozen_string_literal: true

require 'nanoc-core'

module Nanoc
module Sass
end
end

require 'nanoc/sass/version'
require 'nanoc/sass/filter'
@@ -1,8 +1,8 @@
# frozen_string_literal: true

module Nanoc::Filters
module Nanoc::Sass
module SassCommon
REQUIRES = %w[sass nanoc/filters/sass/importer nanoc/filters/sass/functions].freeze
REQUIRES = %w[sass nanoc/sass/importer nanoc/sass/functions].freeze

def css(filter, rep, content, params)
css, = render(filter, rep, content, params)
@@ -17,7 +17,7 @@ def sourcemap(filter, rep, content, params)
private

def render(filter, rep, content, params = {})
importer = Nanoc::Filters::SassCommon::Importer.new(filter)
importer = Nanoc::Sass::Importer.new(filter)

options = params.merge(
load_paths: [importer, *params[:load_paths]&.reject { |p| p.is_a?(String) && %r{^content/} =~ p }],
@@ -47,7 +47,7 @@ def render(filter, rep, content, params = {})
end
end

class SassFilter < Nanoc::Filter
class SassFilter < Nanoc::Core::Filter
identifier :sass

include SassCommon
@@ -58,7 +58,7 @@ def run(content, params = {})
end
end

class SassSourcemapFilter < Nanoc::Filter
class SassSourcemapFilter < Nanoc::Core::Filter
identifier :sass_sourcemap

include SassCommon
File renamed without changes.
@@ -1,6 +1,6 @@
# frozen_string_literal: true

module Nanoc::Filters::SassCommon
module Nanoc::Sass
# @api private
class Importer < ::Sass::Importers::Filesystem
attr_reader :filter
@@ -0,0 +1,7 @@
# frozen_string_literal: true

module Nanoc
module Sass
VERSION = '1.0.0'
end
end
@@ -0,0 +1,21 @@
# frozen_string_literal: true

require_relative 'lib/nanoc/sass/version'

Gem::Specification.new do |s|
s.name = 'nanoc-sass'
s.version = Nanoc::Sass::VERSION
s.homepage = 'https://nanoc.ws/'
s.summary = 'Sass support for Nanoc'
s.description = 'Provides Sass functionality for Nanoc'
s.author = 'Denis Defreyne'
s.email = 'denis+rubygems@denis.ws'
s.license = 'MIT'

s.files = ['NEWS.md', 'README.md'] + Dir['lib/**/*.rb']
s.require_paths = ['lib']

s.required_ruby_version = '~> 2.4'

s.add_runtime_dependency('nanoc-core', '~> 4.11', '>= 4.11.14')
end
@@ -0,0 +1,9 @@
NEWS.md
README.md

lib/nanoc-sass.rb
lib/nanoc/sass.rb
lib/nanoc/sass/filter.rb
lib/nanoc/sass/functions.rb
lib/nanoc/sass/importer.rb
lib/nanoc/sass/version.rb
@@ -0,0 +1,20 @@
# frozen_string_literal: true

describe 'nanoc-sass.gem', chdir: false, stdio: true do
subject do
TTY::Command.new.run('gem build nanoc-sass.gemspec')
end

around do |ex|
Dir['*.gem'].each { |f| FileUtils.rm(f) }
ex.run
Dir['*.gem'].each { |f| FileUtils.rm(f) }
end

it 'builds gem' do
expect { subject }
.to change { Dir['*.gem'] }
.from([])
.to(include(match(/^nanoc-sass-.*\.gem$/)))
end
end
@@ -0,0 +1,7 @@
# frozen_string_literal: true

describe 'manifest', chdir: false do
example do
expect('nanoc-sass').to have_a_valid_manifest
end
end
@@ -1,6 +1,6 @@
# frozen_string_literal: true

describe Nanoc::Filters::SassCommon do
describe Nanoc::Sass do
context 'with item, items, config context' do
subject(:sass_sourcemap) do
::Nanoc::Filter.named(:sass_sourcemap).new(sass_sourcemap_params)
@@ -0,0 +1,7 @@
# frozen_string_literal: true

require_relative '../../common/spec/spec_helper_head'

require 'nanoc/sass'

require_relative '../../common/spec/spec_helper_foot'
@@ -37,6 +37,7 @@ module Nanoc
require 'nanoc-cli'
require 'nanoc-checking'
require 'nanoc-deploying'
require 'nanoc-sass'

# Re-export from Nanoc::Core
Nanoc::Identifier = Nanoc::Core::Identifier
@@ -27,7 +27,6 @@ module Nanoc::Filters
require_relative 'filters/redcloth'
require_relative 'filters/relativize_paths'
require_relative 'filters/rubypants'
require_relative 'filters/sass'
require_relative 'filters/slim'
require_relative 'filters/typogruby'
require_relative 'filters/uglify_js'
@@ -25,6 +25,7 @@ Gem::Specification.new do |s|
s.add_runtime_dependency('nanoc-cli', "= #{Nanoc::VERSION}")
s.add_runtime_dependency('nanoc-core', "= #{Nanoc::VERSION}")
s.add_runtime_dependency('nanoc-deploying', '~> 1.0')
s.add_runtime_dependency('nanoc-sass', '~> 1.0')
s.add_runtime_dependency('parallel', '~> 1.12')
s.add_runtime_dependency('tty-command', '~> 0.8')
s.add_runtime_dependency('tty-which', '~> 0.4')
@@ -42,9 +42,6 @@ lib/nanoc/filters/redcarpet.rb
lib/nanoc/filters/redcloth.rb
lib/nanoc/filters/relativize_paths.rb
lib/nanoc/filters/rubypants.rb
lib/nanoc/filters/sass.rb
lib/nanoc/filters/sass/functions.rb
lib/nanoc/filters/sass/importer.rb
lib/nanoc/filters/slim.rb
lib/nanoc/filters/typogruby.rb
lib/nanoc/filters/uglify_js.rb

0 comments on commit fc265e8

Please sign in to comment.
You can’t perform that action at this time.