sass-embedded 0.7.1 → 0.7.2
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/lib/sass/version.rb +1 -1
- metadata +6 -33
- data/.github/workflows/build.yml +0 -44
- data/.gitignore +0 -45
- data/.rubocop.yml +0 -11
- data/Gemfile +0 -4
- data/Rakefile +0 -23
- data/ext/.gitignore +0 -3
- data/sass-embedded.gemspec +0 -38
- data/test/concurrency_test.rb +0 -34
- data/test/functions_test.rb +0 -387
- data/test/importer_test.rb +0 -155
- data/test/include_paths_test.rb +0 -81
- data/test/indented_syntax_test.rb +0 -61
- data/test/input_test.rb +0 -56
- data/test/output_test.rb +0 -136
- data/test/render_error_test.rb +0 -44
- data/test/render_test.rb +0 -19
- data/test/source_maps_test.rb +0 -182
- data/test/test_helper.rb +0 -30
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 420195776d51e7fcd3d510db9445f0a7bb4c926613515e1a849a865f4bd6447d
|
4
|
+
data.tar.gz: 518333274bb5f2b521894075bce89314a47e993b29c84fd54ebdfd38aeab33f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52ab4ccf5f0ffd05554749a5669dd474a5e5c8c027e55fd93a8665070182f973a37be5e11a93066d485b89d5144ef893c0cc26fc5892b2fb31b8c6824799462a
|
7
|
+
data.tar.gz: 83f042430fa1e8339ea31d63752714ce842994b230e66ba8745695dac997617e9ecc28aad732c7dffc558fb3660471970ec1109d9a2f8f42e172c5ce1dc9f192
|
data/lib/sass/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sass-embedded
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- なつき
|
@@ -136,7 +136,8 @@ dependencies:
|
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
|
-
description:
|
139
|
+
description: A Ruby library that will communicate with Embedded Dart Sass using the
|
140
|
+
Embedded Sass protocol.
|
140
141
|
email:
|
141
142
|
- i@ntk.me
|
142
143
|
executables: []
|
@@ -144,14 +145,8 @@ extensions:
|
|
144
145
|
- ext/extconf.rb
|
145
146
|
extra_rdoc_files: []
|
146
147
|
files:
|
147
|
-
- ".github/workflows/build.yml"
|
148
|
-
- ".gitignore"
|
149
|
-
- ".rubocop.yml"
|
150
|
-
- Gemfile
|
151
148
|
- LICENSE
|
152
149
|
- README.md
|
153
|
-
- Rakefile
|
154
|
-
- ext/.gitignore
|
155
150
|
- ext/Makefile
|
156
151
|
- ext/extconf.rb
|
157
152
|
- lib/sass.rb
|
@@ -166,22 +161,11 @@ files:
|
|
166
161
|
- lib/sass/transport.rb
|
167
162
|
- lib/sass/util.rb
|
168
163
|
- lib/sass/version.rb
|
169
|
-
- sass-embedded.gemspec
|
170
|
-
- test/concurrency_test.rb
|
171
|
-
- test/functions_test.rb
|
172
|
-
- test/importer_test.rb
|
173
|
-
- test/include_paths_test.rb
|
174
|
-
- test/indented_syntax_test.rb
|
175
|
-
- test/input_test.rb
|
176
|
-
- test/output_test.rb
|
177
|
-
- test/render_error_test.rb
|
178
|
-
- test/render_test.rb
|
179
|
-
- test/source_maps_test.rb
|
180
|
-
- test/test_helper.rb
|
181
164
|
homepage: https://github.com/ntkme/sass-embedded-host-ruby
|
182
165
|
licenses:
|
183
166
|
- MIT
|
184
|
-
metadata:
|
167
|
+
metadata:
|
168
|
+
source_code_uri: https://github.com/ntkme/sass-embedded-host-ruby/tree/v0.7.2
|
185
169
|
post_install_message:
|
186
170
|
rdoc_options: []
|
187
171
|
require_paths:
|
@@ -201,15 +185,4 @@ rubygems_version: 3.2.15
|
|
201
185
|
signing_key:
|
202
186
|
specification_version: 4
|
203
187
|
summary: Use dart-sass with Ruby!
|
204
|
-
test_files:
|
205
|
-
- test/concurrency_test.rb
|
206
|
-
- test/functions_test.rb
|
207
|
-
- test/importer_test.rb
|
208
|
-
- test/include_paths_test.rb
|
209
|
-
- test/indented_syntax_test.rb
|
210
|
-
- test/input_test.rb
|
211
|
-
- test/output_test.rb
|
212
|
-
- test/render_error_test.rb
|
213
|
-
- test/render_test.rb
|
214
|
-
- test/source_maps_test.rb
|
215
|
-
- test/test_helper.rb
|
188
|
+
test_files: []
|
data/.github/workflows/build.yml
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
name: build
|
2
|
-
|
3
|
-
on:
|
4
|
-
push:
|
5
|
-
branches: [ main ]
|
6
|
-
pull_request:
|
7
|
-
branches: [ main ]
|
8
|
-
|
9
|
-
jobs:
|
10
|
-
build:
|
11
|
-
|
12
|
-
runs-on: ${{ matrix.os }}
|
13
|
-
|
14
|
-
strategy:
|
15
|
-
matrix:
|
16
|
-
os: [macos-latest, ubuntu-latest, windows-latest]
|
17
|
-
ruby-version: ['2.6', '2.7', '3.0']
|
18
|
-
|
19
|
-
steps:
|
20
|
-
- name: Checkout
|
21
|
-
uses: actions/checkout@v2
|
22
|
-
|
23
|
-
- name: Set up Ruby
|
24
|
-
uses: ruby/setup-ruby@v1
|
25
|
-
with:
|
26
|
-
ruby-version: ${{ matrix.ruby-version }}
|
27
|
-
bundler-cache: true
|
28
|
-
|
29
|
-
- name: Download dart-sass-embedded
|
30
|
-
run: bundle exec rake extconf
|
31
|
-
env:
|
32
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
33
|
-
|
34
|
-
- name: Test
|
35
|
-
run: bundle exec rake
|
36
|
-
|
37
|
-
- name: Install Gem
|
38
|
-
run: rake install
|
39
|
-
env:
|
40
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
41
|
-
|
42
|
-
- name: Test Gem
|
43
|
-
run: |-
|
44
|
-
ruby -r sass -e "puts Sass.render(data: 'h1 { color: black; }')[:css]"
|
data/.gitignore
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
*.gem
|
2
|
-
*.rbc
|
3
|
-
/.config
|
4
|
-
/coverage/
|
5
|
-
/InstalledFiles
|
6
|
-
/pkg/
|
7
|
-
/spec/reports/
|
8
|
-
/spec/examples.txt
|
9
|
-
/test/tmp/
|
10
|
-
/test/version_tmp/
|
11
|
-
/tmp/
|
12
|
-
|
13
|
-
# Used by dotenv library to load environment variables.
|
14
|
-
# .env
|
15
|
-
|
16
|
-
# Ignore Byebug command history file.
|
17
|
-
.byebug_history
|
18
|
-
|
19
|
-
## Specific to RubyMotion:
|
20
|
-
.dat*
|
21
|
-
.repl_history
|
22
|
-
build/
|
23
|
-
*.bridgesupport
|
24
|
-
build-iPhoneOS/
|
25
|
-
build-iPhoneSimulator/
|
26
|
-
|
27
|
-
## Documentation cache and generated files:
|
28
|
-
/.yardoc/
|
29
|
-
/_yardoc/
|
30
|
-
/doc/
|
31
|
-
/rdoc/
|
32
|
-
|
33
|
-
## Environment normalization:
|
34
|
-
/.bundle/
|
35
|
-
/vendor/bundle
|
36
|
-
/lib/bundler/man/
|
37
|
-
|
38
|
-
# for a library or gem, you might want to ignore these files since the code is
|
39
|
-
# intended to run in multiple environments; otherwise, check them in:
|
40
|
-
/Gemfile.lock
|
41
|
-
/.ruby-version
|
42
|
-
/.ruby-gemset
|
43
|
-
|
44
|
-
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
45
|
-
.rvmrc
|
data/.rubocop.yml
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'bundler/gem_tasks'
|
4
|
-
|
5
|
-
task default: %i[rubocop test]
|
6
|
-
|
7
|
-
desc 'Download dart-sass-embedded'
|
8
|
-
task :extconf do
|
9
|
-
system('make', '-C', 'ext')
|
10
|
-
end
|
11
|
-
|
12
|
-
desc 'Run all tests'
|
13
|
-
task test: :extconf do
|
14
|
-
$LOAD_PATH.unshift('lib', 'test')
|
15
|
-
Dir.glob('./test/**/*_test.rb').sort.each { |f| require f }
|
16
|
-
end
|
17
|
-
|
18
|
-
begin
|
19
|
-
require 'rubocop/rake_task'
|
20
|
-
RuboCop::RakeTask.new
|
21
|
-
rescue LoadError
|
22
|
-
nil
|
23
|
-
end
|
data/ext/.gitignore
DELETED
data/sass-embedded.gemspec
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
lib = File.expand_path('lib', __dir__)
|
4
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require 'sass/version'
|
6
|
-
|
7
|
-
Gem::Specification.new do |spec|
|
8
|
-
spec.name = 'sass-embedded'
|
9
|
-
spec.version = Sass::VERSION
|
10
|
-
spec.authors = ['なつき']
|
11
|
-
spec.email = ['i@ntk.me']
|
12
|
-
spec.summary = 'Use dart-sass with Ruby!'
|
13
|
-
spec.description = 'Use dart-sass with Ruby!'
|
14
|
-
spec.homepage = 'https://github.com/ntkme/sass-embedded-host-ruby'
|
15
|
-
spec.license = 'MIT'
|
16
|
-
|
17
|
-
spec.files = `git ls-files -z`.split("\x0")
|
18
|
-
spec.extensions = ['ext/extconf.rb']
|
19
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
20
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
-
|
22
|
-
spec.required_ruby_version = '>= 2.6.0'
|
23
|
-
|
24
|
-
spec.require_paths = ['lib']
|
25
|
-
|
26
|
-
spec.platform = Gem::Platform::RUBY
|
27
|
-
|
28
|
-
spec.add_dependency 'google-protobuf', '~> 3.17.0'
|
29
|
-
|
30
|
-
spec.add_development_dependency 'bundler'
|
31
|
-
spec.add_development_dependency 'minitest', '~> 5.14.4'
|
32
|
-
spec.add_development_dependency 'minitest-around'
|
33
|
-
spec.add_development_dependency 'rake'
|
34
|
-
spec.add_development_dependency 'rake-compiler'
|
35
|
-
spec.add_development_dependency 'rubocop'
|
36
|
-
spec.add_development_dependency 'rubocop-minitest'
|
37
|
-
spec.add_development_dependency 'rubocop-rake'
|
38
|
-
end
|
data/test/concurrency_test.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'test_helper'
|
4
|
-
|
5
|
-
module Sass
|
6
|
-
class ConcurrencyTest < MiniTest::Test
|
7
|
-
include TempFileTest
|
8
|
-
|
9
|
-
def setup
|
10
|
-
@embedded = Embedded.new
|
11
|
-
end
|
12
|
-
|
13
|
-
def teardown
|
14
|
-
@embedded.close
|
15
|
-
end
|
16
|
-
|
17
|
-
def render(data)
|
18
|
-
@embedded.render(data: data).css
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_concurrency
|
22
|
-
10.times do
|
23
|
-
threads = []
|
24
|
-
10.times do |i|
|
25
|
-
threads << Thread.new(i) do |id|
|
26
|
-
output = @embedded.render(data: "div { width: #{id} }").css
|
27
|
-
assert_match(/#{id}/, output)
|
28
|
-
end
|
29
|
-
end
|
30
|
-
threads.each(&:join)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
data/test/functions_test.rb
DELETED
@@ -1,387 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'test_helper'
|
4
|
-
|
5
|
-
module Sass
|
6
|
-
class FunctionsTest < MiniTest::Test
|
7
|
-
def setup
|
8
|
-
@embedded = Embedded.new
|
9
|
-
end
|
10
|
-
|
11
|
-
def teardown
|
12
|
-
@embedded.close
|
13
|
-
end
|
14
|
-
|
15
|
-
# rubocop:disable Layout/LineLength
|
16
|
-
|
17
|
-
def render(sass)
|
18
|
-
@embedded.render(data: sass,
|
19
|
-
functions: {
|
20
|
-
'javascript_path($path)': lambda { |path|
|
21
|
-
path.string.text = "/js/#{path.string.text}"
|
22
|
-
path
|
23
|
-
},
|
24
|
-
'stylesheet_path($path)': lambda { |path|
|
25
|
-
path.string.text = "/css/#{path.string.text}"
|
26
|
-
path
|
27
|
-
},
|
28
|
-
'sass_return_path($path)': lambda { |path|
|
29
|
-
path
|
30
|
-
},
|
31
|
-
'no_return_path($path)': lambda { |_path|
|
32
|
-
EmbeddedProtocol::Value.new(
|
33
|
-
singleton: EmbeddedProtocol::SingletonValue::NULL
|
34
|
-
)
|
35
|
-
},
|
36
|
-
'optional_arguments($path, $optional: null)': lambda { |path, optional|
|
37
|
-
EmbeddedProtocol::Value.new(
|
38
|
-
string: EmbeddedProtocol::Value::String.new(
|
39
|
-
text: "#{path.string.text}/#{optional.singleton == :NULL ? 'bar' : optional.string.text}",
|
40
|
-
quoted: true
|
41
|
-
)
|
42
|
-
)
|
43
|
-
},
|
44
|
-
'function_that_raises_errors()': lambda {
|
45
|
-
raise StandardError,
|
46
|
-
'Intentional wrong thing happened somewhere inside the custom function'
|
47
|
-
},
|
48
|
-
'nice_color_argument($color)': lambda { |color|
|
49
|
-
color
|
50
|
-
},
|
51
|
-
'returns_a_color()': lambda {
|
52
|
-
EmbeddedProtocol::Value.new(
|
53
|
-
rgb_color: EmbeddedProtocol::Value::RgbColor.new(
|
54
|
-
red: 0,
|
55
|
-
green: 0,
|
56
|
-
blue: 0,
|
57
|
-
alpha: 1
|
58
|
-
)
|
59
|
-
)
|
60
|
-
},
|
61
|
-
'returns_a_number()': lambda {
|
62
|
-
EmbeddedProtocol::Value.new(
|
63
|
-
number: EmbeddedProtocol::Value::Number.new(
|
64
|
-
value: -312,
|
65
|
-
numerators: ['rem']
|
66
|
-
)
|
67
|
-
)
|
68
|
-
},
|
69
|
-
'returns_a_bool()': lambda {
|
70
|
-
EmbeddedProtocol::Value.new(
|
71
|
-
singleton: EmbeddedProtocol::SingletonValue::TRUE
|
72
|
-
)
|
73
|
-
},
|
74
|
-
'inspect_bool($argument)': lambda { |argument|
|
75
|
-
unless argument&.singleton == :TRUE || argument.singleton == :FALSE
|
76
|
-
raise StandardError,
|
77
|
-
'passed value is not a EmbeddedProtocol::SingletonValue::TRUE or EmbeddedProtocol::SingletonValue::FALSE'
|
78
|
-
end
|
79
|
-
|
80
|
-
argument
|
81
|
-
},
|
82
|
-
'inspect_number($argument)': lambda { |argument|
|
83
|
-
unless argument&.number.is_a? EmbeddedProtocol::Value::Number
|
84
|
-
raise StandardError,
|
85
|
-
'passed value is not a EmbeddedProtocol::Value::Number'
|
86
|
-
end
|
87
|
-
|
88
|
-
argument
|
89
|
-
},
|
90
|
-
'inspect_map($argument)': lambda { |argument|
|
91
|
-
unless argument&.map.is_a? EmbeddedProtocol::Value::Map
|
92
|
-
raise StandardError,
|
93
|
-
'passed value is not a EmbeddedProtocol::Value::Map'
|
94
|
-
end
|
95
|
-
|
96
|
-
argument
|
97
|
-
},
|
98
|
-
'inspect_list($argument)': lambda { |argument|
|
99
|
-
unless argument&.list.is_a? EmbeddedProtocol::Value::List
|
100
|
-
raise StandardError,
|
101
|
-
'passed value is not a EmbeddedProtocol::Value::List'
|
102
|
-
end
|
103
|
-
|
104
|
-
argument
|
105
|
-
},
|
106
|
-
'returns_sass_value()': lambda {
|
107
|
-
EmbeddedProtocol::Value.new(
|
108
|
-
rgb_color: EmbeddedProtocol::Value::RgbColor.new(
|
109
|
-
red: 0,
|
110
|
-
green: 0,
|
111
|
-
blue: 0,
|
112
|
-
alpha: 1
|
113
|
-
)
|
114
|
-
)
|
115
|
-
},
|
116
|
-
'returns_sass_map()': lambda {
|
117
|
-
EmbeddedProtocol::Value.new(
|
118
|
-
map: EmbeddedProtocol::Value::Map.new(
|
119
|
-
entries: [
|
120
|
-
EmbeddedProtocol::Value::Map::Entry.new(
|
121
|
-
key: EmbeddedProtocol::Value.new(
|
122
|
-
string: EmbeddedProtocol::Value::String.new(
|
123
|
-
text: 'color',
|
124
|
-
quoted: true
|
125
|
-
)
|
126
|
-
),
|
127
|
-
value: EmbeddedProtocol::Value.new(
|
128
|
-
rgb_color: EmbeddedProtocol::Value::RgbColor.new(
|
129
|
-
red: 0,
|
130
|
-
green: 0,
|
131
|
-
blue: 0,
|
132
|
-
alpha: 1
|
133
|
-
)
|
134
|
-
)
|
135
|
-
)
|
136
|
-
]
|
137
|
-
)
|
138
|
-
)
|
139
|
-
},
|
140
|
-
'returns_sass_list()': lambda {
|
141
|
-
EmbeddedProtocol::Value.new(
|
142
|
-
list: EmbeddedProtocol::Value::List.new(
|
143
|
-
separator: EmbeddedProtocol::ListSeparator::COMMA,
|
144
|
-
has_brackets: true,
|
145
|
-
contents: [
|
146
|
-
EmbeddedProtocol::Value.new(
|
147
|
-
number: EmbeddedProtocol::Value::Number.new(
|
148
|
-
value: 10
|
149
|
-
)
|
150
|
-
),
|
151
|
-
EmbeddedProtocol::Value.new(
|
152
|
-
number: EmbeddedProtocol::Value::Number.new(
|
153
|
-
value: 20
|
154
|
-
)
|
155
|
-
),
|
156
|
-
EmbeddedProtocol::Value.new(
|
157
|
-
number: EmbeddedProtocol::Value::Number.new(
|
158
|
-
value: 30
|
159
|
-
)
|
160
|
-
)
|
161
|
-
]
|
162
|
-
)
|
163
|
-
)
|
164
|
-
}
|
165
|
-
}).css
|
166
|
-
end
|
167
|
-
|
168
|
-
# rubocop:enable Layout/LineLength
|
169
|
-
|
170
|
-
def test_functions_may_return_sass_string_type
|
171
|
-
assert_sass <<-SCSS, <<-CSS
|
172
|
-
div { url: url(sass_return_path("foo.svg")); }
|
173
|
-
SCSS
|
174
|
-
div { url: url("foo.svg"); }
|
175
|
-
CSS
|
176
|
-
end
|
177
|
-
|
178
|
-
def test_functions_work_with_varying_quotes_and_string_types
|
179
|
-
assert_sass <<-SCSS, <<-CSS
|
180
|
-
div {
|
181
|
-
url: url(asset-path("foo.svg"));
|
182
|
-
url: url(image-path("foo.png"));
|
183
|
-
url: url(video-path("foo.mov"));
|
184
|
-
url: url(audio-path("foo.mp3"));
|
185
|
-
url: url(font-path("foo.woff"));
|
186
|
-
url: url(javascript-path('foo.js'));
|
187
|
-
url: url(javascript-path("foo.js"));
|
188
|
-
url: url(stylesheet-path("foo.css"));
|
189
|
-
}
|
190
|
-
SCSS
|
191
|
-
div {
|
192
|
-
url: url(asset-path("foo.svg"));
|
193
|
-
url: url(image-path("foo.png"));
|
194
|
-
url: url(video-path("foo.mov"));
|
195
|
-
url: url(audio-path("foo.mp3"));
|
196
|
-
url: url(font-path("foo.woff"));
|
197
|
-
url: url("/js/foo.js");
|
198
|
-
url: url("/js/foo.js");
|
199
|
-
url: url("/css/foo.css");
|
200
|
-
}
|
201
|
-
CSS
|
202
|
-
end
|
203
|
-
|
204
|
-
def test_function_with_empty_unquoted_string
|
205
|
-
assert_sass <<-SCSS, <<-CSS
|
206
|
-
div {url: url(no-return-path('foo.svg'));}
|
207
|
-
SCSS
|
208
|
-
div { url: url(); }
|
209
|
-
CSS
|
210
|
-
end
|
211
|
-
|
212
|
-
def test_function_that_returns_a_color
|
213
|
-
assert_sass <<-SCSS, <<-CSS
|
214
|
-
div { background: returns-a-color(); }
|
215
|
-
SCSS
|
216
|
-
div { background: black; }
|
217
|
-
CSS
|
218
|
-
end
|
219
|
-
|
220
|
-
def test_function_that_returns_a_number
|
221
|
-
assert_sass <<-SCSS, <<-CSS
|
222
|
-
div { width: returns-a-number(); }
|
223
|
-
SCSS
|
224
|
-
div { width: -312rem; }
|
225
|
-
CSS
|
226
|
-
end
|
227
|
-
|
228
|
-
def test_function_that_takes_a_number
|
229
|
-
assert_sass <<-SCSS, <<-CSS
|
230
|
-
div { display: inspect-number(42.1px); }
|
231
|
-
SCSS
|
232
|
-
div { display: 42.1px; }
|
233
|
-
CSS
|
234
|
-
end
|
235
|
-
|
236
|
-
def test_function_that_returns_a_bool
|
237
|
-
assert_sass <<-SCSS, <<-CSS
|
238
|
-
div { width: returns-a-bool(); }
|
239
|
-
SCSS
|
240
|
-
div { width: true; }
|
241
|
-
CSS
|
242
|
-
end
|
243
|
-
|
244
|
-
def test_function_that_takes_a_bool
|
245
|
-
assert_sass <<-SCSS, <<-CSS
|
246
|
-
div { display: inspect-bool(true)}
|
247
|
-
SCSS
|
248
|
-
div { display: true; }
|
249
|
-
CSS
|
250
|
-
end
|
251
|
-
|
252
|
-
def test_function_with_optional_arguments
|
253
|
-
assert_sass <<-SCSS, <<-EXPECTED_CSS
|
254
|
-
div {
|
255
|
-
url: optional_arguments('first');
|
256
|
-
url: optional_arguments('second', 'qux');
|
257
|
-
}
|
258
|
-
SCSS
|
259
|
-
div {
|
260
|
-
url: "first/bar";
|
261
|
-
url: "second/qux";
|
262
|
-
}
|
263
|
-
EXPECTED_CSS
|
264
|
-
end
|
265
|
-
|
266
|
-
def test_functions_may_accept_sass_color_type
|
267
|
-
assert_sass <<-SCSS, <<-EXPECTED_CSS
|
268
|
-
div { color: nice_color_argument(red); }
|
269
|
-
SCSS
|
270
|
-
div { color: red; }
|
271
|
-
EXPECTED_CSS
|
272
|
-
end
|
273
|
-
|
274
|
-
def test_function_with_error
|
275
|
-
assert_raises(RenderError) do
|
276
|
-
render('div {url: function_that_raises_errors();}')
|
277
|
-
end
|
278
|
-
end
|
279
|
-
|
280
|
-
def test_function_that_returns_a_sass_value
|
281
|
-
assert_sass <<-SCSS, <<-CSS
|
282
|
-
div { background: returns-sass-value(); }
|
283
|
-
SCSS
|
284
|
-
div { background: black; }
|
285
|
-
CSS
|
286
|
-
end
|
287
|
-
|
288
|
-
def test_function_that_returns_a_sass_map
|
289
|
-
assert_sass <<-SCSS, <<-CSS
|
290
|
-
$my-map: returns-sass-map();
|
291
|
-
div { background: map-get( $my-map, color ); }
|
292
|
-
SCSS
|
293
|
-
div { background: black; }
|
294
|
-
CSS
|
295
|
-
end
|
296
|
-
|
297
|
-
def test_function_that_takes_a_sass_map
|
298
|
-
assert_sass <<-SCSS, <<-CSS
|
299
|
-
div { background-color: map-get( inspect-map(( color: black, number: 1.23px, string: "abc", map: ( x: 'y' ))), color ); }
|
300
|
-
SCSS
|
301
|
-
div { background-color: black; }
|
302
|
-
CSS
|
303
|
-
end
|
304
|
-
|
305
|
-
def test_function_that_returns_a_sass_list
|
306
|
-
assert_sass <<-SCSS, <<-CSS
|
307
|
-
$my-list: returns-sass-list();
|
308
|
-
div { width: nth( $my-list, 2 ); }
|
309
|
-
SCSS
|
310
|
-
div { width: 20; }
|
311
|
-
CSS
|
312
|
-
end
|
313
|
-
|
314
|
-
def test_function_that_takes_a_sass_list
|
315
|
-
assert_sass <<-SCSS, <<-CSS
|
316
|
-
div { width: nth(inspect-list((10 20 30)), 2); }
|
317
|
-
SCSS
|
318
|
-
div { width: 20; }
|
319
|
-
CSS
|
320
|
-
end
|
321
|
-
|
322
|
-
def test_concurrency
|
323
|
-
10.times do
|
324
|
-
threads = []
|
325
|
-
10.times do |i|
|
326
|
-
threads << Thread.new(i) do |id|
|
327
|
-
output = @embedded.render(data: 'div { url: test-function() }',
|
328
|
-
functions: {
|
329
|
-
'test_function()': lambda {
|
330
|
-
EmbeddedProtocol::Value.new(
|
331
|
-
string: EmbeddedProtocol::Value::String.new(
|
332
|
-
text: "{test_key1: 'test_value', test_key2: #{id}}",
|
333
|
-
quoted: true
|
334
|
-
)
|
335
|
-
)
|
336
|
-
}
|
337
|
-
}).css
|
338
|
-
assert_match(/test_key1/, output)
|
339
|
-
assert_match(/test_key2/, output)
|
340
|
-
assert_match(/test_value/, output)
|
341
|
-
assert_match(/#{id}/, output)
|
342
|
-
end
|
343
|
-
end
|
344
|
-
threads.each(&:join)
|
345
|
-
end
|
346
|
-
end
|
347
|
-
|
348
|
-
def test_pass_custom_functions_as_a_parameter
|
349
|
-
output = @embedded.render(data: 'div { url: test-function(); }',
|
350
|
-
functions: {
|
351
|
-
'test_function()': lambda {
|
352
|
-
EmbeddedProtocol::Value.new(
|
353
|
-
string: EmbeddedProtocol::Value::String.new(
|
354
|
-
text: 'custom_function',
|
355
|
-
quoted: true
|
356
|
-
)
|
357
|
-
)
|
358
|
-
}
|
359
|
-
}).css
|
360
|
-
|
361
|
-
assert_match(/custom_function/, output)
|
362
|
-
end
|
363
|
-
|
364
|
-
def test_pass_incompatible_type_to_custom_functions
|
365
|
-
assert_raises(RenderError) do
|
366
|
-
@embedded.render(data: 'div { url: test-function(); }',
|
367
|
-
functions: {
|
368
|
-
'test_function()': lambda {
|
369
|
-
Class.new
|
370
|
-
}
|
371
|
-
}).css
|
372
|
-
end
|
373
|
-
end
|
374
|
-
|
375
|
-
private
|
376
|
-
|
377
|
-
def assert_sass(sass, expected_css)
|
378
|
-
output = render(sass)
|
379
|
-
assert_equal expected_css.strip.gsub!(/\s+/, ' '), # poor man's String#squish
|
380
|
-
output.strip.gsub!(/\s+/, ' ')
|
381
|
-
end
|
382
|
-
|
383
|
-
def stderr_output
|
384
|
-
$stderr.string.gsub("\u0000\n", '').chomp
|
385
|
-
end
|
386
|
-
end
|
387
|
-
end
|