dartsass-sprockets 3.0.0 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 27972e22ea4a4d83396a8874b82d96d48b006bbff80a6fd09b566819e1a94cbe
4
- data.tar.gz: 8c01d7c429722328d6dcb3f8b7a85ad17a5f88abf7d4ad0044f62c5c26e4fcda
3
+ metadata.gz: 6ab3cc3dd35bada15e7bc557efce4b403181bb5ee117487e99e22441fe60df97
4
+ data.tar.gz: 981e5d83fb052ffd0ddb4e3b9ec686ab81ae49b703db88672224f4a3997c22c5
5
5
  SHA512:
6
- metadata.gz: 7a6e2076e7a2c18806ac6932539026eea2ecf427618824bac7169e17655a991fa5cd2e19a2a6179aa28946ec57170e4fc335b28d1c0a2fb4794da608455a8d17
7
- data.tar.gz: 5cf8902d81bcb478120735495b9ed76668e25570975d97e7c559531e10b3b55c4f8f072c3c7ed9b226a4965d98fd6925c08526262e507d8a9e1f46b808fe5b53
6
+ metadata.gz: 48fee21a6ded6e569d8f48aa92bb514cae6980b5fd748a99d0f6b1631961efccba54cddb11983364e203656266fabe29163a8077c30a8263e5aef514d6bc0495
7
+ data.tar.gz: 8d8690cb0a58cc7a87d39c571c4d18fd9411d1c1c15d3ccfd5f238fbafca65bfc05cf6cd9c27901b3483026153d4693701ba9c8912b4da238359fb137affe9e6
data/README.md CHANGED
@@ -7,7 +7,7 @@ Use [Dart Sass](https://sass-lang.com/dart-sass) with Sprockets and the Ruby on
7
7
 
8
8
  This gem is a fork of [sass/sassc-rails](https://github.com/sass/sassc-rails)
9
9
  which maintains API compatibility but delegates to the
10
- [dartsass-ruby](https://github.com/tablecheck/sass-embedded-host-ruby) gem
10
+ [sass-embedded](https://github.com/sass-contrib/sass-embedded-host-ruby) gem
11
11
  which uses Dart Sass instead of the libsass C implmentation.
12
12
 
13
13
  For ease of upgrading, the root namespace `::SassC` is still used by this gem,
@@ -25,11 +25,20 @@ gem 'dartsass-sprockets'
25
25
  This will automatically configure your default Rails
26
26
  `config.assets.css_compressor` to use `:sass`.
27
27
 
28
+ ### Version Support
29
+
30
+ The current version of `dartsass-sprockets` supports:
31
+ - Ruby 3.1+
32
+ - Rails 6.1+
33
+
34
+ For older versions of Ruby and Rails may be supported with earlier versions of this gem.
35
+
28
36
  ### Upgrading to Dart Sass
29
37
 
30
38
  This gem is a drop-in replacement to [sass-rails](https://github.com/rails/sass-rails).
31
39
  Note the following differences:
32
40
 
41
+ * This library does not apply SASS processing to `.css` files. Please ensure all your SASS files have file extension `.scss`.
33
42
  * `config.sass.style` values `:nested` and `:compact` will behave as `:expanded`. Use `:compressed` for minification.
34
43
  * `config.sass.line_comments` option is ignored and will always be disabled.
35
44
 
@@ -58,10 +67,11 @@ Note these source maps are *inline* and will be appended to the compiled
58
67
  ## Credits
59
68
 
60
69
  * This gem is maintained and used in production by [TableCheck](https://www.tablecheck.com/en/join). (We'd be very glad if the Sass organization could take over maintainership in the future!)
70
+ * Thank you to [Natsuki](https://ntk.me) for the [sass-embedded](https://github.com/sass-contrib/sass-embedded-host-ruby) gem.
61
71
  * Credit to [Ryan Boland](https://ryanboland.com) and the authors of the original
62
72
  [sass/sassc-rails](https://github.com/sass/sassc-rails) and
63
73
  [sass-rails](https://github.com/rails/sass-rails) gems.
64
- * See our [awesome contributors](https://github.com/tablecheck/sassc-ruby/graphs/contributors).
74
+ * See our [awesome contributors](https://github.com/tablecheck/dartsass-sprockets/graphs/contributors).
65
75
 
66
76
  ### Contributing
67
77
 
@@ -1,3 +1,3 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "sassc/rails"
3
+ require_relative 'sassc/rails'
@@ -1,12 +1,14 @@
1
- require "rails/generators/named_base"
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails/generators/named_base'
2
4
 
3
5
  module Sass
4
6
  module Generators
5
7
  class AssetsGenerator < ::Rails::Generators::NamedBase
6
- source_root File.expand_path("../templates", __FILE__)
8
+ source_root File.expand_path('templates', __dir__)
7
9
 
8
10
  def copy_sass
9
- template "stylesheet.sass", File.join('app/assets/stylesheets', class_path, "#{file_name}.sass")
11
+ template 'stylesheet.sass', File.join('app/assets/stylesheets', class_path, "#{file_name}.sass")
10
12
  end
11
13
  end
12
14
  end
@@ -1,9 +1,13 @@
1
- require "rails/generators/sass_scaffold"
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails/generators/sass_scaffold'
2
4
 
3
5
  module Sass
4
6
  module Generators
5
7
  class ScaffoldGenerator < ::Sass::Generators::ScaffoldBase
6
- def syntax() :sass end
8
+ def syntax
9
+ :sass
10
+ end
7
11
  end
8
12
  end
9
13
  end
@@ -1,12 +1,14 @@
1
- require "sassc/engine"
2
- require "rails/generators/named_base"
1
+ # frozen_string_literal: true
2
+
3
+ require 'sassc/engine'
4
+ require 'rails/generators/named_base'
3
5
 
4
6
  module Sass
5
7
  module Generators
6
8
  class ScaffoldBase < ::Rails::Generators::NamedBase
7
9
  def copy_stylesheet
8
10
  dir = ::Rails::Generators::ScaffoldGenerator.source_root
9
- file = File.join(dir, "scaffold.css")
11
+ file = File.join(dir, 'scaffold.css')
10
12
  converted_contents = ::SassC::Engine.new(File.read(file)).render
11
13
  create_file "app/assets/stylesheets/scaffolds.#{syntax}", converted_contents
12
14
  end
@@ -1,12 +1,14 @@
1
- require "rails/generators/named_base"
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails/generators/named_base'
2
4
 
3
5
  module Scss
4
6
  module Generators
5
7
  class AssetsGenerator < ::Rails::Generators::NamedBase
6
- source_root File.expand_path("../templates", __FILE__)
8
+ source_root File.expand_path('templates', __dir__)
7
9
 
8
10
  def copy_scss
9
- template "stylesheet.scss", File.join('app/assets/stylesheets', class_path, "#{file_name}.scss")
11
+ template 'stylesheet.scss', File.join('app/assets/stylesheets', class_path, "#{file_name}.scss")
10
12
  end
11
13
  end
12
14
  end
@@ -1,10 +1,13 @@
1
- require "rails/generators/sass_scaffold"
1
+ # frozen_string_literal: true
2
+
3
+ require 'rails/generators/sass_scaffold'
2
4
 
3
5
  module Scss
4
6
  module Generators
5
7
  class ScaffoldGenerator < ::Sass::Generators::ScaffoldBase
6
- def syntax() :scss end
8
+ def syntax
9
+ :scss
10
+ end
7
11
  end
8
12
  end
9
13
  end
10
-
@@ -3,32 +3,29 @@
3
3
  require 'sprockets/sass_compressor'
4
4
  require 'securerandom'
5
5
 
6
- class Sprockets::SassCompressor
7
- def initialize(options = {})
8
- @options = {
9
- syntax: :scss,
10
- cache: false,
11
- read_cache: false,
12
- style: :compressed
13
- }.merge(options).freeze
14
- @cache_key = SecureRandom.uuid
15
- end
6
+ module Sprockets
7
+ class SassCompressor
8
+ def initialize(options = {})
9
+ @options = {
10
+ syntax: :scss,
11
+ cache: false,
12
+ read_cache: false,
13
+ style: :compressed
14
+ }.merge(options).freeze
15
+ @cache_key = SecureRandom.uuid
16
+ end
16
17
 
17
- def call(*args)
18
- input = if defined?(data)
19
- data # sprockets 2.x
20
- else
21
- args[0][:data] #sprockets 3.x
18
+ def call(*args)
19
+ input = if defined?(data)
20
+ data # sprockets 2.x
21
+ else
22
+ args[0][:data] # sprockets 3.x
23
+ end
24
+
25
+ SassC::Engine.new(input, { style: :compressed }).render
22
26
  end
23
27
 
24
- SassC::Engine.new(
25
- input,
26
- {
27
- style: :compressed
28
- }
29
- ).render
28
+ # sprockets 2.x
29
+ alias evaluate call
30
30
  end
31
-
32
- # sprockets 2.x
33
- alias :evaluate :call
34
31
  end
@@ -5,9 +5,9 @@ require 'sprockets/sass_functions'
5
5
  module Sprockets
6
6
  module SassFunctions
7
7
  def asset_data_url(path)
8
- ::SassC::Script::Value::String.new("url(" + sprockets_context.asset_data_uri(path.value) + ")")
8
+ ::SassC::Script::Value::String.new("url(#{sprockets_context.asset_data_uri(path.value)})")
9
9
  end
10
10
  end
11
11
  end
12
12
 
13
- ::SassC::Script::Functions.send :include, Sprockets::SassFunctions
13
+ SassC::Script::Functions.include Sprockets::SassFunctions
@@ -8,44 +8,44 @@ module SassC
8
8
  class Extension
9
9
  attr_reader :postfix
10
10
 
11
- def initialize(postfix=nil)
11
+ def initialize(postfix = nil)
12
12
  @postfix = postfix
13
13
  end
14
14
 
15
- def import_for(full_path, parent_dir, options)
15
+ def import_for(full_path, _parent_dir, _options)
16
16
  SassC::Importer::Import.new(full_path)
17
17
  end
18
18
  end
19
19
 
20
20
  class CSSExtension
21
21
  def postfix
22
- ".css"
22
+ '.css'
23
23
  end
24
24
 
25
- def import_for(full_path, parent_dir, options)
26
- import_path = full_path.gsub(/\.css$/,"")
25
+ def import_for(full_path, _parent_dir, _options)
26
+ import_path = full_path.gsub(/\.css$/, '')
27
27
  SassC::Importer::Import.new(import_path)
28
28
  end
29
29
  end
30
30
 
31
31
  class CssScssExtension < Extension
32
32
  def postfix
33
- ".css.scss"
33
+ '.css.scss'
34
34
  end
35
35
 
36
- def import_for(full_path, parent_dir, options)
37
- source = File.open(full_path, 'rb') { |f| f.read }
36
+ def import_for(full_path, _parent_dir, _options)
37
+ source = File.binread(full_path)
38
38
  SassC::Importer::Import.new(full_path, source: source)
39
39
  end
40
40
  end
41
41
 
42
42
  class CssSassExtension < Extension
43
43
  def postfix
44
- ".css.sass"
44
+ '.css.sass'
45
45
  end
46
46
 
47
- def import_for(full_path, parent_dir, options)
48
- sass = File.open(full_path, 'rb') { |f| f.read }
47
+ def import_for(full_path, _parent_dir, _options)
48
+ sass = File.binread(full_path)
49
49
  parsed_scss = SassC::Sass2Scss.convert(sass)
50
50
  SassC::Importer::Import.new(full_path, source: parsed_scss)
51
51
  end
@@ -53,10 +53,10 @@ module SassC
53
53
 
54
54
  class SassERBExtension < Extension
55
55
  def postfix
56
- ".sass.erb"
56
+ '.sass.erb'
57
57
  end
58
58
 
59
- def import_for(full_path, parent_dir, options)
59
+ def import_for(full_path, _parent_dir, options)
60
60
  template = Tilt::ERBTemplate.new(full_path)
61
61
  parsed_erb = template.render(options[:sprockets][:context], {})
62
62
  parsed_scss = SassC::Sass2Scss.convert(parsed_erb)
@@ -65,7 +65,7 @@ module SassC
65
65
  end
66
66
 
67
67
  class ERBExtension < Extension
68
- def import_for(full_path, parent_dir, options)
68
+ def import_for(full_path, _parent_dir, options)
69
69
  template = Tilt::ERBTemplate.new(full_path)
70
70
  parsed_erb = template.render(options[:sprockets][:context], {})
71
71
  SassC::Importer::Import.new(full_path, source: parsed_erb)
@@ -76,29 +76,29 @@ module SassC
76
76
  CssScssExtension.new,
77
77
  CssSassExtension.new,
78
78
  SassERBExtension.new,
79
- ERBExtension.new(".scss.erb"),
80
- ERBExtension.new(".css.erb"),
81
- Extension.new(".scss"),
82
- Extension.new(".sass"),
79
+ ERBExtension.new('.scss.erb'),
80
+ ERBExtension.new('.css.erb'),
81
+ Extension.new('.scss'),
82
+ Extension.new('.sass'),
83
83
  CSSExtension.new
84
84
  ].freeze
85
85
 
86
- PREFIXS = [ "", "_" ]
87
- GLOB = /(\A|\/)(\*|\*\*\/\*)\z/
86
+ PREFIXS = ['', '_'].freeze
87
+ GLOB = %r{(\A|/)(\*|\*\*/\*)\z}
88
88
 
89
89
  def imports(path, parent_path)
90
- parent_dir, _ = File.split(parent_path)
90
+ parent_dir, = File.split(parent_path)
91
91
  specified_dir, specified_file = File.split(path)
92
92
 
93
- if m = path.match(GLOB)
94
- path = path.sub(m[0], "")
93
+ if (m = path.match(GLOB))
94
+ path = path.sub(m[0], '')
95
95
  base = File.expand_path(path, File.dirname(parent_path))
96
96
  return glob_imports(base, m[2], parent_path)
97
97
  end
98
98
 
99
99
  search_paths = ([parent_dir] + load_paths).uniq
100
100
 
101
- if specified_dir != "."
101
+ if specified_dir != '.'
102
102
  search_paths.map! do |path|
103
103
  File.join(path, specified_dir)
104
104
  end
@@ -157,15 +157,15 @@ module SassC
157
157
 
158
158
  def globbed_files(base, glob)
159
159
  # TODO: Raise an error from SassC here
160
- raise ArgumentError unless glob == "*" || glob == "**/*"
160
+ raise ArgumentError unless ['*', '**/*'].include?(glob)
161
161
 
162
162
  extensions = EXTENSIONS.map(&:postfix)
163
- exts = extensions.map { |ext| Regexp.escape("#{ext}") }.join("|")
163
+ exts = extensions.map { |ext| Regexp.escape(ext.to_s) }.join('|')
164
164
  sass_re = Regexp.compile("(#{exts})$")
165
165
 
166
166
  record_import_as_dependency(base)
167
167
 
168
- files = Dir["#{base}/#{glob}"].sort.map do |path|
168
+ files = Dir["#{base}/#{glob}"].map do |path|
169
169
  if File.directory?(path)
170
170
  record_import_as_dependency(path)
171
171
  nil
@@ -3,78 +3,81 @@
3
3
  require 'active_support/core_ext/class/attribute'
4
4
  require 'sprockets/railtie'
5
5
 
6
- module SassC::Rails
7
- class Railtie < ::Rails::Railtie
8
- config.sass = ActiveSupport::OrderedOptions.new
6
+ module SassC
7
+ module Rails
8
+ class Railtie < ::Rails::Railtie
9
+ config.sass = ActiveSupport::OrderedOptions.new
9
10
 
10
- # Establish static configuration defaults
11
- # Emit scss files during stylesheet generation of scaffold
12
- config.sass.preferred_syntax = :scss
13
- # Initialize the load paths to an empty array
14
- config.sass.load_paths = []
11
+ # Establish static configuration defaults
12
+ # Emit scss files during stylesheet generation of scaffold
13
+ config.sass.preferred_syntax = :scss
15
14
 
16
- # Display line comments above each selector as a debugging aid
17
- config.sass.line_comments = true
15
+ # Initialize the load paths to an empty array
16
+ config.sass.load_paths = []
18
17
 
19
- # Set the default stylesheet engine
20
- # It can be overridden by passing:
21
- # --stylesheet_engine=sass
22
- # to the rails generate command
23
- config.app_generators.stylesheet_engine config.sass.preferred_syntax
18
+ # Display line comments above each selector as a debugging aid
19
+ config.sass.line_comments = true
24
20
 
25
- if config.respond_to?(:annotations)
26
- config.annotations.register_extensions("scss", "sass") { |annotation| /\/\/\s*(#{annotation}):?\s*(.*)$/ }
27
- end
21
+ # Set the default stylesheet engine
22
+ # It can be overridden by passing:
23
+ # --stylesheet_engine=sass
24
+ # to the rails generate command
25
+ config.app_generators.stylesheet_engine config.sass.preferred_syntax
28
26
 
29
- # Remove the sass middleware if it gets inadvertently enabled by applications.
30
- config.after_initialize do |app|
31
- app.config.middleware.delete(Sass::Plugin::Rack) if defined?(Sass::Plugin::Rack)
32
- end
27
+ if config.respond_to?(:annotations)
28
+ config.annotations.register_extensions('scss', 'sass') { |annotation| %r{//\s*(#{annotation}):?\s*(.*)$} }
29
+ end
33
30
 
34
- initializer :setup_sass, group: :all do |app|
35
- # Only emit one kind of syntax because though we have registered two kinds of generators
36
- syntax = app.config.sass.preferred_syntax.to_sym
37
- alt_syntax = syntax == :sass ? "scss" : "sass"
38
- app.config.generators.hide_namespace alt_syntax
31
+ # Remove the sass middleware if it gets inadvertently enabled by applications.
32
+ config.after_initialize do |app|
33
+ app.config.middleware.delete(Sass::Plugin::Rack) if defined?(Sass::Plugin::Rack)
34
+ end
39
35
 
40
- # Override stylesheet engine to the preferred syntax
41
- config.app_generators.stylesheet_engine syntax
36
+ initializer :setup_sass, group: :all do |app|
37
+ # Only emit one kind of syntax because though we have registered two kinds of generators
38
+ syntax = app.config.sass.preferred_syntax.to_sym
39
+ alt_syntax = syntax == :sass ? 'scss' : 'sass'
40
+ app.config.generators.hide_namespace alt_syntax
42
41
 
43
- # Establish configuration defaults that are environmental in nature
44
- # if config.sass.full_exception.nil?
45
- # # Display a stack trace in the css output when in development-like environments.
46
- # config.sass.full_exception = app.config.consider_all_requests_local
47
- # end
42
+ # Override stylesheet engine to the preferred syntax
43
+ config.app_generators.stylesheet_engine syntax
48
44
 
49
- app.config.assets.configure do |env|
50
- env.context_class.class_eval do
51
- class_attribute :sass_config
52
- self.sass_config = app.config.sass
53
- end
45
+ # Establish configuration defaults that are environmental in nature
46
+ # if config.sass.full_exception.nil?
47
+ # # Display a stack trace in the css output when in development-like environments.
48
+ # config.sass.full_exception = app.config.consider_all_requests_local
49
+ # end
54
50
 
55
- if env.respond_to?(:register_transformer)
56
- env.register_transformer 'text/sass', 'text/css', SassC::Rails::SassTemplate.new
57
- env.register_transformer 'text/scss', 'text/css', SassC::Rails::ScssTemplate.new
58
- end
51
+ app.config.assets.configure do |env|
52
+ env.context_class.class_eval do
53
+ class_attribute :sass_config
54
+ self.sass_config = app.config.sass
55
+ end
56
+
57
+ if env.respond_to?(:register_transformer)
58
+ env.register_transformer 'text/sass', 'text/css', SassC::Rails::SassTemplate.new
59
+ env.register_transformer 'text/scss', 'text/css', SassC::Rails::ScssTemplate.new
60
+ end
59
61
 
60
- if env.respond_to?(:register_engine)
61
- [
62
- ['.sass', SassC::Rails::SassTemplate],
63
- ['.scss', SassC::Rails::ScssTemplate]
64
- ].each do |engine|
65
- engine << { silence_deprecation: true } if Sprockets::VERSION.start_with?("3")
66
- env.register_engine(*engine)
62
+ if env.respond_to?(:register_engine)
63
+ [
64
+ ['.sass', SassC::Rails::SassTemplate],
65
+ ['.scss', SassC::Rails::ScssTemplate]
66
+ ].each do |engine|
67
+ engine << { silence_deprecation: true } if Sprockets::VERSION.start_with?('3')
68
+ env.register_engine(*engine)
69
+ end
67
70
  end
68
71
  end
69
72
  end
70
- end
71
73
 
72
- initializer :setup_compression, group: :all do |app|
73
- if !Rails.env.development?
74
- app.config.assets.css_compressor = :sass unless app.config.assets.has_key?(:css_compressor)
75
- else
76
- # Use expanded output instead of the sass default of :nested unless specified
77
- app.config.sass.style ||= :expanded
74
+ initializer :setup_compression, group: :all do |app|
75
+ if ::Rails.env.development?
76
+ # Use expanded output instead of the sass default of :nested unless specified
77
+ app.config.sass.style ||= :expanded
78
+ else
79
+ app.config.assets.css_compressor = :sass unless app.config.assets.key?(:css_compressor)
80
+ end
78
81
  end
79
82
  end
80
83
  end
@@ -1,113 +1,112 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "sprockets/version"
3
+ require 'sprockets/version'
4
4
  require 'sprockets/sass_processor'
5
- require "sprockets/utils"
6
-
7
- module SassC::Rails
8
- class SassTemplate < Sprockets::SassProcessor
9
- def initialize(options = {}, &block)
10
- @cache_version = options[:cache_version]
11
- @cache_key = "#{self.class.name}:#{VERSION}:#{SassC::VERSION}:#{@cache_version}".freeze
12
- #@importer_class = options[:importer] || Sass::Importers::Filesystem
13
- @sass_config = options[:sass_config] || {}
14
- @functions = Module.new do
15
- include Functions
16
- include options[:functions] if options[:functions]
17
- class_eval(&block) if block_given?
5
+ require 'sprockets/utils'
6
+
7
+ module SassC
8
+ module Rails
9
+ class SassTemplate < Sprockets::SassProcessor
10
+ def initialize(options = {}, &block) # rubocop:disable Lint/MissingSuper
11
+ @cache_version = options[:cache_version]
12
+ @cache_key = "#{self.class.name}:#{VERSION}:#{SassC::VERSION}:#{@cache_version}"
13
+ # @importer_class = options[:importer] || Sass::Importers::Filesystem
14
+ @sass_config = options[:sass_config] || {}
15
+ @functions = Module.new do
16
+ include Functions
17
+ include options[:functions] if options[:functions]
18
+ class_eval(&block) if block_given?
19
+ end
18
20
  end
19
- end
20
21
 
21
- def call(input)
22
- context = input[:environment].context_class.new(input)
23
-
24
- options = {
25
- filename: input[:filename],
26
- line_comments: line_comments?,
27
- syntax: self.class.syntax,
28
- load_paths: input[:environment].paths,
29
- importer: SassC::Rails::Importer,
30
- sprockets: {
31
- context: context,
32
- environment: input[:environment],
33
- dependencies: context.metadata[:dependency_paths]
34
- }
35
- }.merge!(config_options) { |key, left, right| safe_merge(key, left, right) }
36
-
37
- engine = ::SassC::Engine.new(input[:data], options)
38
-
39
- css = Sprockets::Utils.module_include(::SassC::Script::Functions, @functions) do
40
- engine.render
22
+ def call(input)
23
+ context = input[:environment].context_class.new(input)
24
+
25
+ options = {
26
+ filename: input[:filename],
27
+ line_comments: line_comments?,
28
+ syntax: self.class.syntax,
29
+ load_paths: input[:environment].paths,
30
+ importer: SassC::Rails::Importer,
31
+ sprockets: {
32
+ context: context,
33
+ environment: input[:environment],
34
+ dependencies: context.metadata[:dependency_paths]
35
+ }
36
+ }.merge!(config_options) { |key, left, right| safe_merge(key, left, right) }
37
+
38
+ engine = ::SassC::Engine.new(input[:data], options)
39
+
40
+ css = Sprockets::Utils.module_include(::SassC::Script::Functions, @functions) do
41
+ engine.render
42
+ end
43
+
44
+ context.metadata.merge(data: css)
41
45
  end
42
46
 
43
- context.metadata.merge(data: css)
44
- end
45
-
46
- def config_options
47
- opts = { style: sass_style, load_paths: load_paths }
47
+ def config_options
48
+ opts = { style: sass_style, load_paths: load_paths }
48
49
 
50
+ if ::Rails.application.config.sass.inline_source_maps
51
+ opts.merge!(source_map_file: '.',
52
+ source_map_embed: true,
53
+ source_map_contents: true)
54
+ end
49
55
 
50
- if Rails.application.config.sass.inline_source_maps
51
- opts.merge!({
52
- source_map_file: ".",
53
- source_map_embed: true,
54
- source_map_contents: true,
55
- })
56
+ opts
56
57
  end
57
58
 
58
- opts
59
- end
60
-
61
- def sass_style
62
- (Rails.application.config.sass.style || :expanded).to_sym
63
- end
59
+ def sass_style
60
+ (::Rails.application.config.sass.style || :expanded).to_sym
61
+ end
64
62
 
65
- def load_paths
66
- Rails.application.config.sass.load_paths || []
67
- end
63
+ def load_paths
64
+ ::Rails.application.config.sass.load_paths || []
65
+ end
68
66
 
69
- def line_comments?
70
- Rails.application.config.sass.line_comments
71
- end
67
+ def line_comments?
68
+ ::Rails.application.config.sass.line_comments
69
+ end
72
70
 
73
- def safe_merge(_key, left, right)
74
- if [left, right].all? { |v| v.is_a? Hash }
75
- left.merge(right) { |k, l, r| safe_merge(k, l, r) }
76
- elsif [left, right].all? { |v| v.is_a? Array }
77
- (left + right).uniq
78
- else
79
- right
71
+ def safe_merge(_key, left, right)
72
+ if [left, right].all? { |v| v.is_a? Hash }
73
+ left.merge(right) { |k, l, r| safe_merge(k, l, r) }
74
+ elsif [left, right].all? { |v| v.is_a? Array }
75
+ (left + right).uniq
76
+ else
77
+ right
78
+ end
80
79
  end
81
- end
82
80
 
83
- # The methods in the Functions module were copied here from sprockets in order to
84
- # override the Value class names (e.g. ::SassC::Script::Value::String)
85
- module Functions
86
- def asset_path(path, options = {})
87
- path = path.value
81
+ # The methods in the Functions module were copied here from sprockets in order to
82
+ # override the Value class names (e.g. ::SassC::Script::Value::String)
83
+ module Functions
84
+ def asset_path(path, options = {})
85
+ path = path.value
88
86
 
89
- path, _, query, fragment = URI.split(path)[5..8]
90
- path = sprockets_context.asset_path(path, options)
91
- query = "?#{query}" if query
92
- fragment = "##{fragment}" if fragment
87
+ path, _, query, fragment = URI.split(path)[5..8]
88
+ path = sprockets_context.asset_path(path, options)
89
+ query = "?#{query}" if query
90
+ fragment = "##{fragment}" if fragment
93
91
 
94
- ::SassC::Script::Value::String.new("#{path}#{query}#{fragment}", :string)
95
- end
92
+ ::SassC::Script::Value::String.new("#{path}#{query}#{fragment}", :string)
93
+ end
96
94
 
97
- def asset_url(path, options = {})
98
- ::SassC::Script::Value::String.new("url(#{asset_path(path, options).value})")
99
- end
95
+ def asset_url(path, options = {})
96
+ ::SassC::Script::Value::String.new("url(#{asset_path(path, options).value})")
97
+ end
100
98
 
101
- def asset_data_url(path)
102
- url = sprockets_context.asset_data_uri(path.value)
103
- ::SassC::Script::Value::String.new("url(" + url + ")")
99
+ def asset_data_url(path)
100
+ url = sprockets_context.asset_data_uri(path.value)
101
+ ::SassC::Script::Value::String.new("url(#{url})")
102
+ end
104
103
  end
105
104
  end
106
- end
107
105
 
108
- class ScssTemplate < SassTemplate
109
- def self.syntax
110
- :scss
106
+ class ScssTemplate < SassTemplate
107
+ def self.syntax
108
+ :scss
109
+ end
111
110
  end
112
111
  end
113
112
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module SassC
4
4
  module Rails
5
- VERSION = "3.0.0"
5
+ VERSION = '3.1.0'
6
6
  end
7
7
  end
data/lib/sassc/rails.rb CHANGED
@@ -1,10 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "rails/version"
3
+ require_relative 'rails/version'
4
4
 
5
- require "sassc"
6
- require_relative "rails/functions"
7
- require_relative "rails/importer"
8
- require_relative "rails/template"
9
- require_relative "rails/compressor"
10
- require_relative "rails/railtie"
5
+ require 'sassc-embedded'
6
+ require_relative 'rails/functions'
7
+ require_relative 'rails/importer'
8
+ require_relative 'rails/template'
9
+ require_relative 'rails/compressor'
10
+ require_relative 'rails/railtie'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dartsass-sprockets
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Boland
@@ -9,80 +9,52 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-02-03 00:00:00.000000000 Z
12
+ date: 2023-12-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: pry
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - ">="
19
- - !ruby/object:Gem::Version
20
- version: '0'
21
- type: :development
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- version: '0'
28
- - !ruby/object:Gem::Dependency
29
- name: bundler
15
+ name: railties
30
16
  requirement: !ruby/object:Gem::Requirement
31
17
  requirements:
32
18
  - - ">="
33
19
  - !ruby/object:Gem::Version
34
- version: '0'
35
- type: :development
20
+ version: 4.0.0
21
+ type: :runtime
36
22
  prerelease: false
37
23
  version_requirements: !ruby/object:Gem::Requirement
38
24
  requirements:
39
25
  - - ">="
40
26
  - !ruby/object:Gem::Version
41
- version: '0'
27
+ version: 4.0.0
42
28
  - !ruby/object:Gem::Dependency
43
- name: rake
29
+ name: sassc-embedded
44
30
  requirement: !ruby/object:Gem::Requirement
45
31
  requirements:
46
32
  - - "~>"
47
33
  - !ruby/object:Gem::Version
48
- version: '10.0'
49
- type: :development
34
+ version: '1.69'
35
+ type: :runtime
50
36
  prerelease: false
51
37
  version_requirements: !ruby/object:Gem::Requirement
52
38
  requirements:
53
39
  - - "~>"
54
40
  - !ruby/object:Gem::Version
55
- version: '10.0'
41
+ version: '1.69'
56
42
  - !ruby/object:Gem::Dependency
57
- name: mocha
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - ">="
61
- - !ruby/object:Gem::Version
62
- version: '0'
63
- type: :development
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
- - !ruby/object:Gem::Dependency
71
- name: dartsass-ruby
43
+ name: sprockets
72
44
  requirement: !ruby/object:Gem::Requirement
73
45
  requirements:
74
- - - "~>"
46
+ - - ">"
75
47
  - !ruby/object:Gem::Version
76
48
  version: '3.0'
77
49
  type: :runtime
78
50
  prerelease: false
79
51
  version_requirements: !ruby/object:Gem::Requirement
80
52
  requirements:
81
- - - "~>"
53
+ - - ">"
82
54
  - !ruby/object:Gem::Version
83
55
  version: '3.0'
84
56
  - !ruby/object:Gem::Dependency
85
- name: tilt
57
+ name: sprockets-rails
86
58
  requirement: !ruby/object:Gem::Requirement
87
59
  requirements:
88
60
  - - ">="
@@ -96,35 +68,7 @@ dependencies:
96
68
  - !ruby/object:Gem::Version
97
69
  version: '0'
98
70
  - !ruby/object:Gem::Dependency
99
- name: railties
100
- requirement: !ruby/object:Gem::Requirement
101
- requirements:
102
- - - ">="
103
- - !ruby/object:Gem::Version
104
- version: 4.0.0
105
- type: :runtime
106
- prerelease: false
107
- version_requirements: !ruby/object:Gem::Requirement
108
- requirements:
109
- - - ">="
110
- - !ruby/object:Gem::Version
111
- version: 4.0.0
112
- - !ruby/object:Gem::Dependency
113
- name: sprockets
114
- requirement: !ruby/object:Gem::Requirement
115
- requirements:
116
- - - ">"
117
- - !ruby/object:Gem::Version
118
- version: '3.0'
119
- type: :runtime
120
- prerelease: false
121
- version_requirements: !ruby/object:Gem::Requirement
122
- requirements:
123
- - - ">"
124
- - !ruby/object:Gem::Version
125
- version: '3.0'
126
- - !ruby/object:Gem::Dependency
127
- name: sprockets-rails
71
+ name: tilt
128
72
  requirement: !ruby/object:Gem::Requirement
129
73
  requirements:
130
74
  - - ">="
@@ -159,10 +103,11 @@ files:
159
103
  - lib/sassc/rails/railtie.rb
160
104
  - lib/sassc/rails/template.rb
161
105
  - lib/sassc/rails/version.rb
162
- homepage: https://github.com/sass/dartsass-sprockets
106
+ homepage: https://github.com/tablecheck/dartsass-sprockets
163
107
  licenses:
164
108
  - MIT
165
- metadata: {}
109
+ metadata:
110
+ rubygems_mfa_required: 'true'
166
111
  post_install_message:
167
112
  rdoc_options: []
168
113
  require_paths:
@@ -171,14 +116,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
171
116
  requirements:
172
117
  - - ">="
173
118
  - !ruby/object:Gem::Version
174
- version: 2.6.0
119
+ version: '3.1'
175
120
  required_rubygems_version: !ruby/object:Gem::Requirement
176
121
  requirements:
177
122
  - - ">="
178
123
  - !ruby/object:Gem::Version
179
124
  version: '0'
180
125
  requirements: []
181
- rubygems_version: 3.4.4
126
+ rubygems_version: 3.5.3
182
127
  signing_key:
183
128
  specification_version: 4
184
129
  summary: Use Dart Sass with Sprockets and the Ruby on Rails asset pipeline.