Class: Sprockets::SassEmbedded::SassProcessor
- Inherits:
-
Object
- Object
- Sprockets::SassEmbedded::SassProcessor
- Defined in:
- lib/sprockets/sass_embedded/sass_processor.rb
Direct Known Subclasses
Defined Under Namespace
Modules: Functions
Class Method Summary collapse
- .cache_key ⇒ String
- .call(input) ⇒ Object
- .instance ⇒ Sprockets::SassEmbedded::SassProcessor
- .syntax ⇒ Symbol
Instance Method Summary collapse
- #cache_key ⇒ String
-
#call(input) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength.
-
#initialize(cache_version: nil, functions: nil, sass_config: {}, **_options) ⇒ SassProcessor
constructor
Public: Initialize template with custom options.
Constructor Details
#initialize(cache_version: nil, functions: nil, sass_config: {}, **_options) ⇒ SassProcessor
Public: Initialize template with custom options.
options - Hash cache_version - String custom cache version. Used to force a cache
change after code changes are made to Sass Functions.
70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/sprockets/sass_embedded/sass_processor.rb', line 70 def initialize(cache_version: nil, functions: nil, sass_config: {}, **) @cache_version = cache_version @sass_config = sass_config @functions = Module.new do include Functions include functions if functions class_eval(&block) if block_given? end end |
Class Method Details
.cache_key ⇒ String
46 47 48 |
# File 'lib/sprockets/sass_embedded/sass_processor.rb', line 46 def self.cache_key instance.cache_key end |
.call(input) ⇒ Object
50 51 52 |
# File 'lib/sprockets/sass_embedded/sass_processor.rb', line 50 def self.call(input) instance.call(input) end |
.instance ⇒ Sprockets::SassEmbedded::SassProcessor
55 56 57 |
# File 'lib/sprockets/sass_embedded/sass_processor.rb', line 55 def self.instance @instance ||= new end |
.syntax ⇒ Symbol
60 61 62 |
# File 'lib/sprockets/sass_embedded/sass_processor.rb', line 60 def self.syntax :indented end |
Instance Method Details
#cache_key ⇒ String
83 84 85 86 87 88 89 90 91 |
# File 'lib/sprockets/sass_embedded/sass_processor.rb', line 83 def cache_key @cache_key ||= [ self.class.name, VERSION, Autoload::SassEmbedded::Embedded::VERSION, @cache_version ].join(":") end |
#call(input) ⇒ Object
rubocop:disable Metrics/AbcSize, Metrics/MethodLength
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/sprockets/sass_embedded/sass_processor.rb', line 94 def call(input) context = input[:environment].context_class.new(input) = ( functions: DartSassFunctionsHash.new( @functions, sprockets: { context: context, dependencies: context.[:dependencies], environment: input[:environment] } ).to_h, load_paths: context.environment.paths, source_map: true, syntax: self.class.syntax, url: URIUtils.build_asset_uri(input[:filename]) ) result = Autoload::SassEmbedded.compile_string(input[:data], **) css = result.css map = SourceMapUtils.combine_source_maps( input[:metadata][:map], SourceMapUtils.format_source_map(JSON.parse(result.source_map), input) ) sass_dependencies = Set.new result.loaded_urls.each do |url| scheme, _host, path, _query = URIUtils.split_file_uri(url) next unless scheme == "file" sass_dependencies << path context.[:dependencies] << URIUtils.build_file_digest_uri(path) end context..merge(data: css, map: map, sass_dependencies: sass_dependencies) end |