sass-embedded 0.5.0 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +26 -0
- data/ext/extconf.rb +5 -5
- data/lib/sass.rb +22 -14
- data/lib/sass/embedded.rb +41 -37
- data/lib/sass/error.rb +8 -6
- data/lib/sass/info.rb +1 -1
- data/lib/sass/observer.rb +2 -3
- data/lib/sass/render.rb +6 -4
- data/lib/sass/result.rb +30 -0
- data/lib/sass/struct.rb +20 -0
- data/lib/sass/transport.rb +1 -1
- data/lib/sass/util.rb +1 -1
- data/lib/sass/version.rb +1 -1
- data/sass-embedded.gemspec +1 -1
- data/test/concurrency_test.rb +2 -2
- data/test/functions_test.rb +4 -4
- data/test/importer_test.rb +4 -4
- data/test/include_paths_test.rb +2 -2
- data/test/indented_syntax_test.rb +4 -4
- data/test/input_test.rb +2 -2
- data/test/output_test.rb +18 -18
- data/test/render_test.rb +2 -2
- data/test/source_maps_test.rb +14 -14
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ebc21eec151f7d15be984a32a5dfa6a8b4354daef5f6d152aecba17d0e422e1
|
4
|
+
data.tar.gz: bb869d1411ad2182618a065780083db630556cbd880469d0cb183936dcbd26b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53a378c79e47e534273058d2943c0052906f2a099b1a2f0ddab251c53d36404ba2dffbe7acd8f5bf761153ffd9c81b198990a62995111924909fcd27d0734d9f
|
7
|
+
data.tar.gz: '0653995fb97f097939461e982dc08184713eb4621a316b2a8867b79bdbd049d5a33e7bf0a48c6d7d653d18bb4a6a14ec49e54f49e9967840f9d2a230eeb542f3'
|
data/README.md
CHANGED
@@ -6,6 +6,12 @@ This is a Ruby library that implements the host side of the [Embedded Sass proto
|
|
6
6
|
|
7
7
|
It exposes a Ruby API for Sass that's backed by a native [Dart Sass](https://sass-lang.com/dart-sass) executable.
|
8
8
|
|
9
|
+
## Install
|
10
|
+
|
11
|
+
``` sh
|
12
|
+
gem install sass-embedded
|
13
|
+
```
|
14
|
+
|
9
15
|
## Usage
|
10
16
|
|
11
17
|
``` ruby
|
@@ -14,6 +20,26 @@ require "sass"
|
|
14
20
|
Sass.render(file: "style.scss")
|
15
21
|
```
|
16
22
|
|
23
|
+
## Options
|
24
|
+
|
25
|
+
`Sass.render()` support the following options:
|
26
|
+
|
27
|
+
- [`data`](https://sass-lang.com/documentation/js-api#data)
|
28
|
+
- [`file`](https://sass-lang.com/documentation/js-api#file)
|
29
|
+
- [`indented_syntax`](https://sass-lang.com/documentation/js-api#indentedsyntax)
|
30
|
+
- [`include_paths`](https://sass-lang.com/documentation/js-api#includepaths)
|
31
|
+
- [`output_style`](https://sass-lang.com/documentation/js-api#outputstyle)
|
32
|
+
- [`indent_type`](https://sass-lang.com/documentation/js-api#indenttype)
|
33
|
+
- [`indent_width`](https://sass-lang.com/documentation/js-api#indentwidth)
|
34
|
+
- [`linefeed`](https://sass-lang.com/documentation/js-api#linefeed)
|
35
|
+
- [`source_map`](https://sass-lang.com/documentation/js-api#sourcemap)
|
36
|
+
- [`out_file`](https://sass-lang.com/documentation/js-api#outfile)
|
37
|
+
- [`omit_source_map_url`](https://sass-lang.com/documentation/js-api#omitsourcemapurl)
|
38
|
+
- [`source_map_embed`](https://sass-lang.com/documentation/js-api#sourcemapembed)
|
39
|
+
- [`source_map_root`](https://sass-lang.com/documentation/js-api#sourcemaproot)
|
40
|
+
- [`functions`](https://sass-lang.com/documentation/js-api#functions)
|
41
|
+
- [`importer`](https://sass-lang.com/documentation/js-api#importer)
|
42
|
+
|
17
43
|
---
|
18
44
|
|
19
45
|
Disclaimer: this is not an official Google product.
|
data/ext/extconf.rb
CHANGED
@@ -8,9 +8,9 @@ require 'fileutils'
|
|
8
8
|
require_relative '../lib/sass/platform'
|
9
9
|
|
10
10
|
module Sass
|
11
|
-
# The dependency downloader. This
|
12
|
-
#
|
13
|
-
# dependencies. By default it
|
11
|
+
# The dependency downloader. This downloads all the dependencies during gem
|
12
|
+
# installation. The companion Makefile then unpacks all downloaded
|
13
|
+
# dependencies. By default it downloads the latest release of each
|
14
14
|
# dependency from GitHub releases.
|
15
15
|
#
|
16
16
|
# It is possible to specify an alternative source or version of each
|
@@ -18,9 +18,9 @@ module Sass
|
|
18
18
|
#
|
19
19
|
# @example
|
20
20
|
# gem install sass-embedded -- \
|
21
|
-
# --with-protoc=file:///path/to/protoc-*.zip
|
21
|
+
# --with-protoc=file:///path/to/protoc-*.zip \
|
22
22
|
# --with-sass-embedded=file:///path/to/sass_embedded-*.(tar.gz|zip) \
|
23
|
-
# --with-sass-embedded-protocol=file:///path/to/embedded_sass.proto
|
23
|
+
# --with-sass-embedded-protocol=file:///path/to/embedded_sass.proto
|
24
24
|
class Extconf
|
25
25
|
def initialize
|
26
26
|
get_with_config('protoc', true) { latest_protoc }
|
data/lib/sass.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# The Sass module. This
|
3
|
+
# The Sass module. This communicates with Embedded Dart Sass using
|
4
4
|
# the Embedded Sass protocol.
|
5
5
|
module Sass
|
6
6
|
class << self
|
7
|
-
# The global include_paths for Sass files. This is meant for plugins and
|
7
|
+
# The global {.include_paths} for Sass files. This is meant for plugins and
|
8
8
|
# libraries to register the paths to their Sass stylesheets to that they may
|
9
|
-
# be `@
|
10
|
-
# {Sass::Embedded}. They are lower-precedence than any include
|
11
|
-
# in via the
|
9
|
+
# be included via `@import` or `@use`. This include path is used by every
|
10
|
+
# instance of {Sass::Embedded}. They are lower-precedence than any include
|
11
|
+
# paths passed in via the `include_paths` option.
|
12
12
|
#
|
13
13
|
# If the `SASS_PATH` environment variable is set,
|
14
14
|
# the initial value of `include_paths` will be initialized based on that.
|
@@ -17,7 +17,7 @@ module Sass
|
|
17
17
|
#
|
18
18
|
# @example
|
19
19
|
# Sass.include_paths << File.dirname(__FILE__) + '/sass'
|
20
|
-
# @return [Array
|
20
|
+
# @return [Array]
|
21
21
|
def include_paths
|
22
22
|
@include_paths ||= if ENV['SASS_PATH']
|
23
23
|
ENV['SASS_PATH'].split(File::PATH_SEPARATOR)
|
@@ -26,19 +26,26 @@ module Sass
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
+
# The global {.info} method. This instantiates a global {Embedded} instance
|
30
|
+
# and calls {Embedded#info}.
|
31
|
+
#
|
32
|
+
# @raise [ProtocolError]
|
29
33
|
def info
|
30
34
|
embedded.info
|
31
35
|
end
|
32
36
|
|
33
|
-
# The global render method. This
|
34
|
-
#
|
35
|
-
#
|
36
|
-
# for supported options.
|
37
|
+
# The global {.render} method. This instantiates a global {Embedded} instance
|
38
|
+
# and calls {Embedded#render}.
|
39
|
+
#
|
40
|
+
# See {file:README.md#options} for supported options.
|
41
|
+
#
|
37
42
|
# @example
|
38
43
|
# Sass.render(data: 'h1 { font-size: 40px; }')
|
39
44
|
# @example
|
40
45
|
# Sass.render(file: 'style.css')
|
41
|
-
# @return [
|
46
|
+
# @return [Result]
|
47
|
+
# @raise [ProtocolError]
|
48
|
+
# @raise [RenderError]
|
42
49
|
def render(**kwargs)
|
43
50
|
embedded.render(**kwargs)
|
44
51
|
end
|
@@ -53,12 +60,13 @@ module Sass
|
|
53
60
|
end
|
54
61
|
end
|
55
62
|
|
56
|
-
require_relative 'sass/version'
|
57
|
-
require_relative 'sass/error'
|
58
63
|
require_relative 'sass/platform'
|
59
64
|
require_relative 'sass/util'
|
65
|
+
require_relative 'sass/struct'
|
66
|
+
require_relative 'sass/result'
|
67
|
+
require_relative 'sass/error'
|
60
68
|
require_relative 'sass/transport'
|
61
69
|
require_relative 'sass/observer'
|
62
|
-
require_relative 'sass/
|
70
|
+
require_relative 'sass/version'
|
63
71
|
require_relative 'sass/render'
|
64
72
|
require_relative 'sass/embedded'
|
data/lib/sass/embedded.rb
CHANGED
@@ -4,8 +4,9 @@ require 'base64'
|
|
4
4
|
require 'json'
|
5
5
|
|
6
6
|
module Sass
|
7
|
-
# The {Embedded}
|
8
|
-
#
|
7
|
+
# The {Embedded} host for using dart-sass-embedded. Each instance creates
|
8
|
+
# its own {Transport}.
|
9
|
+
#
|
9
10
|
# @example
|
10
11
|
# embedded = Sass::Embedded.new
|
11
12
|
# result = embedded.render(data: 'h1 { font-size: 40px; }')
|
@@ -18,69 +19,79 @@ module Sass
|
|
18
19
|
@id = 0
|
19
20
|
end
|
20
21
|
|
22
|
+
# The {Embedded#info} method.
|
23
|
+
#
|
24
|
+
# @raise [ProtocolError]
|
21
25
|
def info
|
22
|
-
@info ||=
|
26
|
+
@info ||= Version.new(@transport, next_id).message
|
23
27
|
end
|
24
28
|
|
29
|
+
# The {Embedded#render} method.
|
30
|
+
#
|
31
|
+
# See {file:README.md#options} for supported options.
|
32
|
+
#
|
33
|
+
# @return [RenderResult]
|
34
|
+
# @raise [ProtocolError]
|
35
|
+
# @raise [RenderError]
|
25
36
|
def render(data: nil,
|
26
37
|
file: nil,
|
27
38
|
indented_syntax: false,
|
28
39
|
include_paths: [],
|
29
40
|
output_style: :expanded,
|
30
|
-
# precision: 5,
|
31
41
|
indent_type: :space,
|
32
42
|
indent_width: 2,
|
33
43
|
linefeed: :lf,
|
34
|
-
# source_comments: false,
|
35
44
|
source_map: false,
|
36
45
|
out_file: nil,
|
37
46
|
omit_source_map_url: false,
|
38
|
-
|
47
|
+
source_map_contents: false,
|
39
48
|
source_map_embed: false,
|
40
49
|
source_map_root: '',
|
41
50
|
functions: {},
|
42
51
|
importer: [])
|
52
|
+
raise NotImplementedError, 'source_map_contents is not implemented' unless source_map_contents == false
|
53
|
+
|
43
54
|
start = Util.now
|
44
55
|
|
45
56
|
indent_type = parse_indent_type(indent_type)
|
46
57
|
indent_width = parse_indent_width(indent_width)
|
47
58
|
linefeed = parse_linefeed(linefeed)
|
48
59
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
if
|
60
|
+
message = Render.new(@transport, next_id,
|
61
|
+
data: data,
|
62
|
+
file: file,
|
63
|
+
indented_syntax: indented_syntax,
|
64
|
+
include_paths: include_paths,
|
65
|
+
output_style: output_style,
|
66
|
+
source_map: source_map,
|
67
|
+
out_file: out_file,
|
68
|
+
functions: functions,
|
69
|
+
importer: importer).message
|
70
|
+
|
71
|
+
if message.failure
|
61
72
|
raise RenderError.new(
|
62
|
-
|
63
|
-
|
64
|
-
if
|
73
|
+
message.failure.message,
|
74
|
+
message.failure.formatted,
|
75
|
+
if message.failure.span.nil?
|
65
76
|
nil
|
66
|
-
elsif
|
77
|
+
elsif message.failure.span.url == ''
|
67
78
|
'stdin'
|
68
79
|
else
|
69
|
-
Util.path(
|
80
|
+
Util.path(message.failure.span.url)
|
70
81
|
end,
|
71
|
-
|
72
|
-
|
82
|
+
message.failure.span ? message.failure.span.start.line + 1 : nil,
|
83
|
+
message.failure.span ? message.failure.span.start.column + 1 : nil,
|
73
84
|
1
|
74
85
|
)
|
75
86
|
end
|
76
87
|
|
77
|
-
map, source_map = post_process_map(map:
|
88
|
+
map, source_map = post_process_map(map: message.success.source_map,
|
78
89
|
file: file,
|
79
90
|
out_file: out_file,
|
80
91
|
source_map: source_map,
|
81
92
|
source_map_root: source_map_root)
|
82
93
|
|
83
|
-
css = post_process_css(css:
|
94
|
+
css = post_process_css(css: message.success.css,
|
84
95
|
indent_type: indent_type,
|
85
96
|
indent_width: indent_width,
|
86
97
|
linefeed: linefeed,
|
@@ -92,16 +103,9 @@ module Sass
|
|
92
103
|
|
93
104
|
finish = Util.now
|
94
105
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
stats: {
|
99
|
-
entry: file.nil? ? 'data' : file,
|
100
|
-
start: start,
|
101
|
-
end: finish,
|
102
|
-
duration: finish - start
|
103
|
-
}
|
104
|
-
}
|
106
|
+
stats = RenderResult::Stats.new(file.nil? ? 'data' : file, start, finish, finish - start)
|
107
|
+
|
108
|
+
RenderResult.new(css, map, stats)
|
105
109
|
end
|
106
110
|
|
107
111
|
def close
|
data/lib/sass/error.rb
CHANGED
@@ -1,21 +1,23 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Sass
|
4
|
-
class
|
4
|
+
class Error < StandardError; end
|
5
5
|
|
6
|
-
class ProtocolError <
|
6
|
+
class ProtocolError < Error; end
|
7
7
|
|
8
|
-
# The
|
9
|
-
class RenderError <
|
10
|
-
|
8
|
+
# The {Error} raised by {Embedded#render}.
|
9
|
+
class RenderError < Error
|
10
|
+
include Struct
|
11
|
+
|
12
|
+
attr_reader :formatted, :file, :line, :column, :status
|
11
13
|
|
12
14
|
def initialize(message, formatted, file, line, column, status)
|
15
|
+
super(message)
|
13
16
|
@formatted = formatted
|
14
17
|
@file = file
|
15
18
|
@line = line
|
16
19
|
@column = column
|
17
20
|
@status = status
|
18
|
-
super(message)
|
19
21
|
end
|
20
22
|
|
21
23
|
def backtrace
|
data/lib/sass/info.rb
CHANGED
data/lib/sass/observer.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Sass
|
4
|
-
# The
|
5
|
-
# from {Transport}.
|
4
|
+
# The {Observer} for receiving messages from {Transport}.
|
6
5
|
class Observer
|
7
6
|
def initialize(transport, id)
|
8
7
|
raise NotImplementedError if instance_of? Observer
|
@@ -16,7 +15,7 @@ module Sass
|
|
16
15
|
@transport.add_observer self
|
17
16
|
end
|
18
17
|
|
19
|
-
def
|
18
|
+
def message
|
20
19
|
@mutex.synchronize do
|
21
20
|
@condition_variable.wait(@mutex) if @error.nil? && @message.nil?
|
22
21
|
end
|
data/lib/sass/render.rb
CHANGED
@@ -47,15 +47,17 @@ module Sass
|
|
47
47
|
super(nil, message)
|
48
48
|
end
|
49
49
|
when EmbeddedProtocol::OutboundMessage::LogEvent
|
50
|
-
|
50
|
+
return unless message.compilation_id == @id && $stderr.tty?
|
51
|
+
|
52
|
+
warn message.formatted
|
51
53
|
when EmbeddedProtocol::OutboundMessage::CanonicalizeRequest
|
52
|
-
return unless message
|
54
|
+
return unless message.compilation_id == @id
|
53
55
|
|
54
56
|
Thread.new do
|
55
57
|
@transport.send canonicalize_response message
|
56
58
|
end
|
57
59
|
when EmbeddedProtocol::OutboundMessage::ImportRequest
|
58
|
-
return unless message
|
60
|
+
return unless message.compilation_id == @id
|
59
61
|
|
60
62
|
Thread.new do
|
61
63
|
@transport.send import_response message
|
@@ -63,7 +65,7 @@ module Sass
|
|
63
65
|
when EmbeddedProtocol::OutboundMessage::FileImportRequest
|
64
66
|
raise NotImplementedError, 'FileImportRequest is not implemented'
|
65
67
|
when EmbeddedProtocol::OutboundMessage::FunctionCallRequest
|
66
|
-
return unless message
|
68
|
+
return unless message.compilation_id == @id
|
67
69
|
|
68
70
|
Thread.new do
|
69
71
|
@transport.send function_call_response message
|
data/lib/sass/result.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sass
|
4
|
+
# The {RenderResult} of {Embedded#render}.
|
5
|
+
class RenderResult
|
6
|
+
include Struct
|
7
|
+
|
8
|
+
attr_reader :css, :map, :stats
|
9
|
+
|
10
|
+
def initialize(css, map, stats)
|
11
|
+
@css = css
|
12
|
+
@map = map
|
13
|
+
@stats = stats
|
14
|
+
end
|
15
|
+
|
16
|
+
# The {Stats} of {Embedded#render}.
|
17
|
+
class Stats
|
18
|
+
include Struct
|
19
|
+
|
20
|
+
attr_reader :entry, :start, :end, :duration
|
21
|
+
|
22
|
+
def initialize(entry, start, finish, duration)
|
23
|
+
@entry = entry
|
24
|
+
@start = start
|
25
|
+
@end = finish
|
26
|
+
@duration = duration
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/sass/struct.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Sass
|
4
|
+
# The {Struct} module.
|
5
|
+
module Struct
|
6
|
+
def [](key)
|
7
|
+
instance_variable_get("@#{key}".to_sym)
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_h
|
11
|
+
instance_variables.map do |variable|
|
12
|
+
[variable[1..].to_sym, instance_variable_get(variable)]
|
13
|
+
end.to_h
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_s
|
17
|
+
to_h.to_s
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/sass/transport.rb
CHANGED
@@ -6,7 +6,7 @@ require_relative '../../ext/embedded_sass_pb'
|
|
6
6
|
|
7
7
|
module Sass
|
8
8
|
# The {Observable} {Transport} for low level communication with
|
9
|
-
# dart-sass-embedded using protocol buffers via stdio. Received messages
|
9
|
+
# `dart-sass-embedded` using protocol buffers via stdio. Received messages
|
10
10
|
# can be observed by an {Observer}.
|
11
11
|
class Transport
|
12
12
|
include Observable
|
data/lib/sass/util.rb
CHANGED
data/lib/sass/version.rb
CHANGED
data/sass-embedded.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
spec.email = ['i@ntk.me']
|
12
12
|
spec.summary = 'Use dart-sass with Ruby!'
|
13
13
|
spec.description = 'Use dart-sass with Ruby!'
|
14
|
-
spec.homepage = 'https://github.com/ntkme/embedded-host-ruby'
|
14
|
+
spec.homepage = 'https://github.com/ntkme/sass-embedded-host-ruby'
|
15
15
|
spec.license = 'MIT'
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0")
|
data/test/concurrency_test.rb
CHANGED
@@ -15,7 +15,7 @@ module Sass
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def render(data)
|
18
|
-
@embedded.render(data: data)
|
18
|
+
@embedded.render(data: data).css
|
19
19
|
end
|
20
20
|
|
21
21
|
def test_concurrency
|
@@ -23,7 +23,7 @@ module Sass
|
|
23
23
|
threads = []
|
24
24
|
10.times do |i|
|
25
25
|
threads << Thread.new(i) do |id|
|
26
|
-
output = @embedded.render(data: "div { width: #{id} }")
|
26
|
+
output = @embedded.render(data: "div { width: #{id} }").css
|
27
27
|
assert_match(/#{id}/, output)
|
28
28
|
end
|
29
29
|
end
|
data/test/functions_test.rb
CHANGED
@@ -162,7 +162,7 @@ module Sass
|
|
162
162
|
)
|
163
163
|
)
|
164
164
|
}
|
165
|
-
})
|
165
|
+
}).css
|
166
166
|
end
|
167
167
|
|
168
168
|
# rubocop:enable Layout/LineLength
|
@@ -334,7 +334,7 @@ module Sass
|
|
334
334
|
)
|
335
335
|
)
|
336
336
|
}
|
337
|
-
})
|
337
|
+
}).css
|
338
338
|
assert_match(/test_key1/, output)
|
339
339
|
assert_match(/test_key2/, output)
|
340
340
|
assert_match(/test_value/, output)
|
@@ -356,7 +356,7 @@ module Sass
|
|
356
356
|
)
|
357
357
|
)
|
358
358
|
}
|
359
|
-
})
|
359
|
+
}).css
|
360
360
|
|
361
361
|
assert_match(/custom_function/, output)
|
362
362
|
end
|
@@ -368,7 +368,7 @@ module Sass
|
|
368
368
|
'test_function()': lambda {
|
369
369
|
Class.new
|
370
370
|
}
|
371
|
-
})
|
371
|
+
}).css
|
372
372
|
end
|
373
373
|
end
|
374
374
|
|
data/test/importer_test.rb
CHANGED
@@ -15,7 +15,7 @@ module Sass
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def render(data, importer)
|
18
|
-
@embedded.render(data: data, importer: importer)
|
18
|
+
@embedded.render(data: data, importer: importer).css
|
19
19
|
end
|
20
20
|
|
21
21
|
def test_custom_importer_works
|
@@ -121,7 +121,7 @@ module Sass
|
|
121
121
|
lambda { |_url, prev|
|
122
122
|
{ contents: ".#{prev} { color: red; }" }
|
123
123
|
}
|
124
|
-
])
|
124
|
+
]).css
|
125
125
|
|
126
126
|
assert_equal <<~CSS.chomp, output
|
127
127
|
.import-parent-filename.scss {
|
@@ -140,10 +140,10 @@ module Sass
|
|
140
140
|
lambda { |_url, _prev|
|
141
141
|
{ contents: 'h1 { color: black; }' }
|
142
142
|
}
|
143
|
-
])
|
143
|
+
]).css
|
144
144
|
}
|
145
145
|
}
|
146
|
-
])
|
146
|
+
]).css
|
147
147
|
|
148
148
|
assert_equal <<~CSS.chomp, output
|
149
149
|
h1 {
|
data/test/include_paths_test.rb
CHANGED
@@ -31,7 +31,7 @@ module Sass
|
|
31
31
|
assert_equal css, @embedded.render(file: 'styles.scss',
|
32
32
|
include_paths: %w[
|
33
33
|
included_1 included_2
|
34
|
-
])
|
34
|
+
]).css
|
35
35
|
end
|
36
36
|
|
37
37
|
def test_global_include_paths
|
@@ -51,7 +51,7 @@ module Sass
|
|
51
51
|
}
|
52
52
|
CSS
|
53
53
|
|
54
|
-
assert_equal css, @embedded.render(file: 'styles.scss')
|
54
|
+
assert_equal css, @embedded.render(file: 'styles.scss').css
|
55
55
|
end
|
56
56
|
|
57
57
|
def test_include_paths_from_env
|
@@ -35,7 +35,7 @@ module Sass
|
|
35
35
|
@embedded.render(data: sass, indented_syntax: false)
|
36
36
|
end
|
37
37
|
|
38
|
-
assert_equal css, @embedded.render(data: sass, indented_syntax: true)
|
38
|
+
assert_equal css, @embedded.render(data: sass, indented_syntax: true).css
|
39
39
|
end
|
40
40
|
|
41
41
|
def test_input_file_with_indented_syntax
|
@@ -53,9 +53,9 @@ module Sass
|
|
53
53
|
|
54
54
|
temp_file('style.sass', sass)
|
55
55
|
|
56
|
-
assert_equal css, @embedded.render(file: 'style.sass')
|
57
|
-
assert_equal css, @embedded.render(file: 'style.sass', indented_syntax: true)
|
58
|
-
assert_equal css, @embedded.render(file: 'style.sass', indented_syntax: false)
|
56
|
+
assert_equal css, @embedded.render(file: 'style.sass').css
|
57
|
+
assert_equal css, @embedded.render(file: 'style.sass', indented_syntax: true).css
|
58
|
+
assert_equal css, @embedded.render(file: 'style.sass', indented_syntax: false).css
|
59
59
|
end
|
60
60
|
end
|
61
61
|
end
|
data/test/input_test.rb
CHANGED
@@ -30,7 +30,7 @@ module Sass
|
|
30
30
|
CSS
|
31
31
|
|
32
32
|
result = @embedded.render(data: scss)
|
33
|
-
assert_equal css, result
|
33
|
+
assert_equal css, result.css
|
34
34
|
end
|
35
35
|
|
36
36
|
def test_input_file
|
@@ -50,7 +50,7 @@ module Sass
|
|
50
50
|
|
51
51
|
temp_file('style.scss', scss)
|
52
52
|
result = @embedded.render(file: 'style.scss')
|
53
|
-
assert_equal css, result
|
53
|
+
assert_equal css, result.css
|
54
54
|
end
|
55
55
|
end
|
56
56
|
end
|
data/test/output_test.rb
CHANGED
@@ -23,26 +23,26 @@ module Sass
|
|
23
23
|
}
|
24
24
|
SCSS
|
25
25
|
|
26
|
-
assert_equal <<~CSS.chomp, @embedded.render(data: data, output_style: :expanded)
|
26
|
+
assert_equal <<~CSS.chomp, @embedded.render(data: data, output_style: :expanded).css
|
27
27
|
.foo {
|
28
28
|
baz: bang;
|
29
29
|
}
|
30
30
|
CSS
|
31
31
|
|
32
|
-
assert_equal <<~CSS.chomp, @embedded.render(data: data, output_style: :compressed)
|
32
|
+
assert_equal <<~CSS.chomp, @embedded.render(data: data, output_style: :compressed).css
|
33
33
|
.foo{baz:bang}
|
34
34
|
CSS
|
35
35
|
|
36
36
|
assert_raises(ArgumentError) do
|
37
|
-
@embedded.render(data: data, output_style: :nested)
|
37
|
+
@embedded.render(data: data, output_style: :nested).css
|
38
38
|
end
|
39
39
|
|
40
40
|
assert_raises(ArgumentError) do
|
41
|
-
@embedded.render(data: data, output_style: :compact)
|
41
|
+
@embedded.render(data: data, output_style: :compact).css
|
42
42
|
end
|
43
43
|
|
44
44
|
assert_raises(ArgumentError) do
|
45
|
-
@embedded.render(data: data, output_style: nil)
|
45
|
+
@embedded.render(data: data, output_style: nil).css
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
@@ -55,7 +55,7 @@ module Sass
|
|
55
55
|
SCSS
|
56
56
|
|
57
57
|
def test_output_indent_width
|
58
|
-
assert_equal <<~CSS.chomp, @embedded.render(data: DATA_INDENT_TEST, indent_width: 0)
|
58
|
+
assert_equal <<~CSS.chomp, @embedded.render(data: DATA_INDENT_TEST, indent_width: 0).css
|
59
59
|
@media all {
|
60
60
|
.foo {
|
61
61
|
baz: bang;
|
@@ -63,7 +63,7 @@ module Sass
|
|
63
63
|
}
|
64
64
|
CSS
|
65
65
|
|
66
|
-
assert_equal <<~CSS.chomp, @embedded.render(data: DATA_INDENT_TEST, indent_width: 1)
|
66
|
+
assert_equal <<~CSS.chomp, @embedded.render(data: DATA_INDENT_TEST, indent_width: 1).css
|
67
67
|
@media all {
|
68
68
|
.foo {
|
69
69
|
baz: bang;
|
@@ -71,7 +71,7 @@ module Sass
|
|
71
71
|
}
|
72
72
|
CSS
|
73
73
|
|
74
|
-
assert_equal <<~CSS.chomp, @embedded.render(data: DATA_INDENT_TEST, indent_width: 4)
|
74
|
+
assert_equal <<~CSS.chomp, @embedded.render(data: DATA_INDENT_TEST, indent_width: 4).css
|
75
75
|
@media all {
|
76
76
|
.foo {
|
77
77
|
baz: bang;
|
@@ -79,7 +79,7 @@ module Sass
|
|
79
79
|
}
|
80
80
|
CSS
|
81
81
|
|
82
|
-
assert_equal <<~CSS.chomp, @embedded.render(data: DATA_INDENT_TEST, indent_width: 10)
|
82
|
+
assert_equal <<~CSS.chomp, @embedded.render(data: DATA_INDENT_TEST, indent_width: 10).css
|
83
83
|
@media all {
|
84
84
|
.foo {
|
85
85
|
baz: bang;
|
@@ -88,20 +88,20 @@ module Sass
|
|
88
88
|
CSS
|
89
89
|
|
90
90
|
assert_raises(RangeError) do
|
91
|
-
@embedded.render(data: DATA_INDENT_TEST, indent_width: -1)
|
91
|
+
@embedded.render(data: DATA_INDENT_TEST, indent_width: -1).css
|
92
92
|
end
|
93
93
|
|
94
94
|
assert_raises(RangeError) do
|
95
|
-
@embedded.render(data: DATA_INDENT_TEST, indent_width: 11)
|
95
|
+
@embedded.render(data: DATA_INDENT_TEST, indent_width: 11).css
|
96
96
|
end
|
97
97
|
|
98
98
|
assert_raises(ArgumentError) do
|
99
|
-
@embedded.render(data: DATA_INDENT_TEST, indent_width: 3.14)
|
99
|
+
@embedded.render(data: DATA_INDENT_TEST, indent_width: 3.14).css
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
103
|
def test_output_indent_type
|
104
|
-
assert_equal <<~CSS.chomp, @embedded.render(data: DATA_INDENT_TEST, indent_type: :tab)
|
104
|
+
assert_equal <<~CSS.chomp, @embedded.render(data: DATA_INDENT_TEST, indent_type: :tab).css
|
105
105
|
@media all {
|
106
106
|
\t\t.foo {
|
107
107
|
\t\t\t\tbaz: bang;
|
@@ -109,7 +109,7 @@ module Sass
|
|
109
109
|
}
|
110
110
|
CSS
|
111
111
|
|
112
|
-
assert_equal <<~CSS.chomp, @embedded.render(data: DATA_INDENT_TEST, indent_width: 1, indent_type: 'tab')
|
112
|
+
assert_equal <<~CSS.chomp, @embedded.render(data: DATA_INDENT_TEST, indent_width: 1, indent_type: 'tab').css
|
113
113
|
@media all {
|
114
114
|
\t.foo {
|
115
115
|
\t\tbaz: bang;
|
@@ -127,10 +127,10 @@ module Sass
|
|
127
127
|
}
|
128
128
|
SCSS
|
129
129
|
|
130
|
-
assert_equal ".foo {\n baz: bang;\n}", @embedded.render(data: data, linefeed: :lf)
|
131
|
-
assert_equal ".foo {\n\r baz: bang;\n\r}", @embedded.render(data: data, linefeed: :lfcr)
|
132
|
-
assert_equal ".foo {\r baz: bang;\r}", @embedded.render(data: data, linefeed: :cr)
|
133
|
-
assert_equal ".foo {\r\n baz: bang;\r\n}", @embedded.render(data: data, linefeed: :crlf)
|
130
|
+
assert_equal ".foo {\n baz: bang;\n}", @embedded.render(data: data, linefeed: :lf).css
|
131
|
+
assert_equal ".foo {\n\r baz: bang;\n\r}", @embedded.render(data: data, linefeed: :lfcr).css
|
132
|
+
assert_equal ".foo {\r baz: bang;\r}", @embedded.render(data: data, linefeed: :cr).css
|
133
|
+
assert_equal ".foo {\r\n baz: bang;\r\n}", @embedded.render(data: data, linefeed: :crlf).css
|
134
134
|
end
|
135
135
|
end
|
136
136
|
end
|
data/test/render_test.rb
CHANGED
@@ -5,7 +5,7 @@ require_relative 'test_helper'
|
|
5
5
|
module Sass
|
6
6
|
class RenderTest < MiniTest::Test
|
7
7
|
def test_sass_render
|
8
|
-
assert_equal '', ::Sass.render(data: '')
|
8
|
+
assert_equal '', ::Sass.render(data: '').css
|
9
9
|
|
10
10
|
css = <<~CSS.chomp
|
11
11
|
h1 {
|
@@ -13,7 +13,7 @@ module Sass
|
|
13
13
|
}
|
14
14
|
CSS
|
15
15
|
|
16
|
-
assert_equal css, ::Sass.render(data: 'h1 { font-size: 2rem; }')
|
16
|
+
assert_equal css, ::Sass.render(data: 'h1 { font-size: 2rem; }').css
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
data/test/source_maps_test.rb
CHANGED
@@ -31,8 +31,8 @@ module Sass
|
|
31
31
|
temp_file('style.scss', scss)
|
32
32
|
|
33
33
|
result = @embedded.render(file: 'style.scss')
|
34
|
-
assert_equal css, result
|
35
|
-
assert_nil result
|
34
|
+
assert_equal css, result.css
|
35
|
+
assert_nil result.map
|
36
36
|
end
|
37
37
|
|
38
38
|
def test_source_map_file_as_string
|
@@ -54,8 +54,8 @@ module Sass
|
|
54
54
|
|
55
55
|
result = @embedded.render(file: 'style.scss',
|
56
56
|
source_map: 'out.map')
|
57
|
-
assert_equal css, result
|
58
|
-
JSON.parse(result
|
57
|
+
assert_equal css, result.css
|
58
|
+
JSON.parse(result.map)
|
59
59
|
end
|
60
60
|
|
61
61
|
def test_source_map_true_without_out_file_has_no_effect
|
@@ -76,8 +76,8 @@ module Sass
|
|
76
76
|
|
77
77
|
result = @embedded.render(file: 'style.scss',
|
78
78
|
source_map: true)
|
79
|
-
assert_equal css, result
|
80
|
-
assert_nil result
|
79
|
+
assert_equal css, result.css
|
80
|
+
assert_nil result.map
|
81
81
|
end
|
82
82
|
|
83
83
|
def test_source_map_true_with_out_file
|
@@ -100,8 +100,8 @@ module Sass
|
|
100
100
|
result = @embedded.render(file: 'style.scss',
|
101
101
|
source_map: true,
|
102
102
|
out_file: 'out.css')
|
103
|
-
assert_equal css, result
|
104
|
-
JSON.parse(result
|
103
|
+
assert_equal css, result.css
|
104
|
+
JSON.parse(result.map)
|
105
105
|
end
|
106
106
|
|
107
107
|
def test_omit_source_map_url
|
@@ -123,8 +123,8 @@ module Sass
|
|
123
123
|
result = @embedded.render(file: 'style.scss',
|
124
124
|
source_map: 'out.map',
|
125
125
|
omit_source_map_url: true)
|
126
|
-
assert_equal css, result
|
127
|
-
JSON.parse(result
|
126
|
+
assert_equal css, result.css
|
127
|
+
JSON.parse(result.map)
|
128
128
|
end
|
129
129
|
|
130
130
|
def test_source_map_embedded
|
@@ -147,8 +147,8 @@ module Sass
|
|
147
147
|
result = @embedded.render(file: 'style.scss',
|
148
148
|
source_map: 'out.map',
|
149
149
|
source_map_embed: true)
|
150
|
-
assert result
|
151
|
-
JSON.parse(result
|
150
|
+
assert result.css.start_with? css
|
151
|
+
JSON.parse(result.map)
|
152
152
|
end
|
153
153
|
|
154
154
|
def test_source_map_root
|
@@ -171,8 +171,8 @@ module Sass
|
|
171
171
|
result = @embedded.render(file: 'style.scss',
|
172
172
|
source_map: 'out.map',
|
173
173
|
source_map_root: 'assets')
|
174
|
-
assert_equal css, result
|
175
|
-
assert_equal 'assets', JSON.parse(result
|
174
|
+
assert_equal css, result.css
|
175
|
+
assert_equal 'assets', JSON.parse(result.map)['sourceRoot']
|
176
176
|
end
|
177
177
|
end
|
178
178
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sass-embedded
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- なつき
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-05-
|
11
|
+
date: 2021-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-protobuf
|
@@ -161,6 +161,8 @@ files:
|
|
161
161
|
- lib/sass/observer.rb
|
162
162
|
- lib/sass/platform.rb
|
163
163
|
- lib/sass/render.rb
|
164
|
+
- lib/sass/result.rb
|
165
|
+
- lib/sass/struct.rb
|
164
166
|
- lib/sass/transport.rb
|
165
167
|
- lib/sass/util.rb
|
166
168
|
- lib/sass/version.rb
|
@@ -176,7 +178,7 @@ files:
|
|
176
178
|
- test/render_test.rb
|
177
179
|
- test/source_maps_test.rb
|
178
180
|
- test/test_helper.rb
|
179
|
-
homepage: https://github.com/ntkme/embedded-host-ruby
|
181
|
+
homepage: https://github.com/ntkme/sass-embedded-host-ruby
|
180
182
|
licenses:
|
181
183
|
- MIT
|
182
184
|
metadata: {}
|