Sha256: 7b0193e1f281b6e1ae5c3b9e594f88ca9883d3670ad186b1cc5b33bf1f3f430e

Contents?: true

Size: 1.15 KB

Versions: 2

Compression:

Stored size: 1.15 KB

Contents

module Hanami
  module Assets
    module Compilers
      # Sass/SCSS Compiler
      #
      # @since 0.3.0
      # @api private
      class Sass < Compiler
        # @since 0.3.0
        # @api private
        EXTENSIONS = /\.(sass|scss)\z/.freeze

        # @since 0.3.0
        # @api private
        def self.eligible?(name)
          name.to_s =~ EXTENSIONS
        end

        # @since 1.3.3
        # @api private
        def initialize(*)
          super
          require 'sassc'
        end

        private

        # @since 0.3.0
        # @api private
        def renderer
          @renderer ||=
            ::SassC::Engine.new(
              source.read,
              syntax: target_syntax,
              load_paths: load_paths
            )
        end

        # @since 0.3.0
        # @api private
        def dependencies
          renderer.dependencies.map(&:filename)
        rescue source::NotRenderedError
          []
        end

        # @since 1.3.2
        # @api private
        def target_syntax
          if source.extname =~ /sass\z/.freeze
            :sass
          else
            :scss
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hanami-assets-1.3.4 lib/hanami/assets/compilers/sass.rb
hanami-assets-1.3.3 lib/hanami/assets/compilers/sass.rb