sassc 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/ext/libsass/.gitignore +6 -0
- data/ext/libsass/.travis.yml +5 -1
- data/ext/libsass/Makefile +12 -3
- data/ext/libsass/Makefile.am +16 -28
- data/ext/libsass/Readme.md +1 -0
- data/ext/libsass/appveyor.yml +1 -2
- data/ext/libsass/ast.cpp +9 -0
- data/ext/libsass/ast.hpp +152 -55
- data/ext/libsass/ast_factory.hpp +2 -0
- data/ext/libsass/ast_fwd_decl.hpp +1 -0
- data/ext/libsass/backtrace.hpp +2 -2
- data/ext/libsass/bind.cpp +15 -13
- data/ext/libsass/configure.ac +17 -5
- data/ext/libsass/constants.cpp +22 -2
- data/ext/libsass/constants.hpp +21 -2
- data/ext/libsass/context.cpp +79 -57
- data/ext/libsass/context.hpp +23 -9
- data/ext/libsass/contextualize.cpp +2 -28
- data/ext/libsass/contextualize.hpp +6 -10
- data/ext/libsass/contextualize_eval.cpp +93 -0
- data/ext/libsass/contextualize_eval.hpp +44 -0
- data/ext/libsass/contrib/plugin.cpp +57 -0
- data/ext/libsass/cssize.cpp +3 -1
- data/ext/libsass/debugger.hpp +242 -83
- data/ext/libsass/emitter.cpp +1 -1
- data/ext/libsass/emitter.hpp +1 -1
- data/ext/libsass/environment.hpp +109 -25
- data/ext/libsass/error_handling.cpp +3 -3
- data/ext/libsass/error_handling.hpp +0 -1
- data/ext/libsass/eval.cpp +145 -61
- data/ext/libsass/eval.hpp +9 -1
- data/ext/libsass/expand.cpp +134 -60
- data/ext/libsass/expand.hpp +5 -2
- data/ext/libsass/extend.cpp +7 -5
- data/ext/libsass/file.cpp +176 -123
- data/ext/libsass/file.hpp +44 -7
- data/ext/libsass/functions.cpp +36 -17
- data/ext/libsass/functions.hpp +2 -2
- data/ext/libsass/inspect.cpp +23 -14
- data/ext/libsass/inspect.hpp +1 -0
- data/ext/libsass/json.cpp +132 -135
- data/ext/libsass/lexer.cpp +133 -0
- data/ext/libsass/lexer.hpp +239 -0
- data/ext/libsass/listize.cpp +83 -0
- data/ext/libsass/listize.hpp +41 -0
- data/ext/libsass/operation.hpp +2 -0
- data/ext/libsass/output.cpp +5 -6
- data/ext/libsass/parser.cpp +426 -388
- data/ext/libsass/parser.hpp +97 -109
- data/ext/libsass/plugins.cpp +15 -2
- data/ext/libsass/plugins.hpp +6 -4
- data/ext/libsass/position.cpp +52 -17
- data/ext/libsass/position.hpp +19 -17
- data/ext/libsass/prelexer.cpp +202 -235
- data/ext/libsass/prelexer.hpp +73 -333
- data/ext/libsass/sass.cpp +21 -11
- data/ext/libsass/sass.h +6 -6
- data/ext/libsass/sass_context.cpp +167 -81
- data/ext/libsass/sass_context.h +26 -6
- data/ext/libsass/sass_functions.cpp +49 -40
- data/ext/libsass/sass_functions.h +55 -43
- data/ext/libsass/sass_interface.cpp +9 -8
- data/ext/libsass/sass_interface.h +3 -3
- data/ext/libsass/sass_version.h +8 -0
- data/ext/libsass/sass_version.h.in +8 -0
- data/ext/libsass/script/ci-build-libsass +3 -3
- data/ext/libsass/script/ci-report-coverage +2 -1
- data/ext/libsass/source_map.cpp +2 -2
- data/ext/libsass/util.cpp +60 -11
- data/ext/libsass/util.hpp +6 -1
- data/ext/libsass/win/libsass.filters +12 -0
- data/ext/libsass/win/libsass.vcxproj +10 -0
- data/lib/sassc.rb +3 -1
- data/lib/sassc/cache_stores/base.rb +2 -0
- data/lib/sassc/dependency.rb +3 -1
- data/lib/sassc/engine.rb +31 -16
- data/lib/sassc/error.rb +3 -2
- data/lib/sassc/functions_handler.rb +54 -0
- data/lib/sassc/import_handler.rb +41 -0
- data/lib/sassc/importer.rb +4 -31
- data/lib/sassc/native.rb +1 -1
- data/lib/sassc/native/native_context_api.rb +3 -2
- data/lib/sassc/script.rb +0 -51
- data/lib/sassc/version.rb +1 -1
- data/sassc.gemspec +1 -0
- data/test/custom_importer_test.rb +72 -69
- data/test/engine_test.rb +53 -54
- data/test/functions_test.rb +40 -39
- data/test/native_test.rb +145 -149
- data/test/output_style_test.rb +98 -0
- data/test/test_helper.rb +21 -7
- metadata +28 -2
data/test/functions_test.rb
CHANGED
@@ -1,55 +1,55 @@
|
|
1
1
|
require_relative "test_helper"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
value
|
7
|
-
end
|
8
|
-
end
|
3
|
+
module SassC
|
4
|
+
class FunctionsTest < MiniTest::Test
|
5
|
+
include FixtureHelper
|
9
6
|
|
10
|
-
|
11
|
-
|
12
|
-
|
7
|
+
SassString = Struct.new(:value, :type) do
|
8
|
+
def to_s
|
9
|
+
value
|
10
|
+
end
|
13
11
|
end
|
14
12
|
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
module Script::Functions
|
14
|
+
def javascript_path(path)
|
15
|
+
Script::String.new("/js/#{path.value}", :string)
|
16
|
+
end
|
18
17
|
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
def no_return_path(path)
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
|
22
|
+
def sass_return_path(path)
|
23
|
+
return SassString.new("'#{path.value}'", :string)
|
24
|
+
end
|
22
25
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
+
module Compass
|
27
|
+
def stylesheet_path(path)
|
28
|
+
Script::String.new("/css/#{path.value}", :identifier)
|
29
|
+
end
|
26
30
|
end
|
31
|
+
include Compass
|
27
32
|
end
|
28
|
-
include Compass
|
29
|
-
end
|
30
33
|
|
31
|
-
|
32
|
-
|
34
|
+
def test_functions_may_return_sass_string_type
|
35
|
+
engine = Engine.new("div {url: url(sass_return_path('foo.svg'));}")
|
33
36
|
|
34
|
-
|
37
|
+
assert_equal <<-EOS, engine.render
|
35
38
|
div {
|
36
39
|
url: url("foo.svg"); }
|
37
40
|
EOS
|
38
|
-
|
39
|
-
|
40
|
-
def test_functions_work
|
41
|
-
filename = fixture_path('paths.scss')
|
42
|
-
data = File.read(filename)
|
41
|
+
end
|
43
42
|
|
44
|
-
|
45
|
-
filename
|
46
|
-
|
47
|
-
})
|
43
|
+
def test_functions_work_with_varying_quotes_and_string_types
|
44
|
+
filename = fixture_path('paths.scss')
|
45
|
+
data = File.read(filename)
|
48
46
|
|
49
|
-
|
50
|
-
|
47
|
+
engine = Engine.new(data, {
|
48
|
+
filename: filename,
|
49
|
+
syntax: :scss
|
50
|
+
})
|
51
51
|
|
52
|
-
|
52
|
+
assert_equal <<-EOS, engine.render
|
53
53
|
div {
|
54
54
|
url: url(asset-path("foo.svg"));
|
55
55
|
url: url(image-path("foo.png"));
|
@@ -60,14 +60,15 @@ div {
|
|
60
60
|
url: url("/js/foo.js");
|
61
61
|
url: url(/css/foo.css); }
|
62
62
|
EOS
|
63
|
-
|
63
|
+
end
|
64
64
|
|
65
|
-
|
66
|
-
|
65
|
+
def test_function_with_no_return_value
|
66
|
+
engine = Engine.new("div {url: url(no-return-path('foo.svg'));}")
|
67
67
|
|
68
|
-
|
68
|
+
assert_equal <<-EOS, engine.render
|
69
69
|
div {
|
70
70
|
url: url(); }
|
71
71
|
EOS
|
72
|
+
end
|
72
73
|
end
|
73
74
|
end
|
data/test/native_test.rb
CHANGED
@@ -1,205 +1,201 @@
|
|
1
1
|
require_relative "test_helper"
|
2
2
|
|
3
|
-
module
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
class DataContext < SassCTest
|
15
|
-
def teardown
|
16
|
-
SassC::Native.delete_data_context(@data_context)
|
3
|
+
module SassC
|
4
|
+
module NativeTest
|
5
|
+
SAMPLE_SASS_STRING = "$size: 30px; .hi { width: $size; }"
|
6
|
+
SAMPLE_CSS_OUTPUT = ".hi {\n width: 30px; }\n"
|
7
|
+
BAD_SASS_STRING = "$size = 30px;"
|
8
|
+
|
9
|
+
class General < MiniTest::Test
|
10
|
+
def test_it_reports_the_libsass_version
|
11
|
+
assert_equal "3.2.0-beta.6", Native.version
|
12
|
+
end
|
17
13
|
end
|
18
14
|
|
19
|
-
|
20
|
-
|
21
|
-
|
15
|
+
class DataContext < MiniTest::Test
|
16
|
+
def teardown
|
17
|
+
Native.delete_data_context(@data_context)
|
18
|
+
end
|
22
19
|
|
23
|
-
|
24
|
-
|
20
|
+
def test_compile_status_is_zero_when_successful
|
21
|
+
@data_context = Native.make_data_context(SAMPLE_SASS_STRING)
|
22
|
+
context = Native.data_context_get_context(@data_context)
|
25
23
|
|
26
|
-
|
27
|
-
|
28
|
-
end
|
24
|
+
status = Native.compile_data_context(@data_context)
|
25
|
+
assert_equal 0, status
|
29
26
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
SassC::Native.compile_data_context(@data_context)
|
27
|
+
status = Native.context_get_error_status(context)
|
28
|
+
assert_equal 0, status
|
29
|
+
end
|
34
30
|
|
35
|
-
|
36
|
-
|
37
|
-
|
31
|
+
def test_compiled_css_is_correct
|
32
|
+
@data_context = Native.make_data_context(SAMPLE_SASS_STRING)
|
33
|
+
context = Native.data_context_get_context(@data_context)
|
34
|
+
Native.compile_data_context(@data_context)
|
38
35
|
|
39
|
-
|
40
|
-
|
41
|
-
|
36
|
+
css = Native.context_get_output_string(context)
|
37
|
+
assert_equal SAMPLE_CSS_OUTPUT, css
|
38
|
+
end
|
42
39
|
|
43
|
-
|
44
|
-
|
40
|
+
def test_compile_status_is_one_if_failed
|
41
|
+
@data_context = Native.make_data_context(BAD_SASS_STRING)
|
42
|
+
context = Native.data_context_get_context(@data_context)
|
45
43
|
|
46
|
-
|
47
|
-
|
48
|
-
end
|
44
|
+
status = Native.compile_data_context(@data_context)
|
45
|
+
refute_equal 0, status
|
49
46
|
|
50
|
-
|
51
|
-
|
47
|
+
status = Native.context_get_error_status(context)
|
48
|
+
refute_equal 0, status
|
49
|
+
end
|
52
50
|
|
53
|
-
|
54
|
-
|
55
|
-
context = SassC::Native.data_context_get_context(data_context)
|
56
|
-
options = SassC::Native.context_get_options(context)
|
51
|
+
def test_failed_compile_gives_error_message
|
52
|
+
end
|
57
53
|
|
58
|
-
|
54
|
+
def test_custom_function
|
55
|
+
data_context = Native.make_data_context("foo { margin: foo(); }")
|
56
|
+
context = Native.data_context_get_context(data_context)
|
57
|
+
options = Native.context_get_options(context)
|
59
58
|
|
60
|
-
|
61
|
-
SassC::Native.make_number(43, "px")
|
62
|
-
end
|
59
|
+
random_thing = FFI::MemoryPointer.from_string("hi")
|
63
60
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
random_thing
|
68
|
-
)
|
61
|
+
funct = FFI::Function.new(:pointer, [:pointer, :pointer]) do |s_args, cookie|
|
62
|
+
Native.make_number(43, "px")
|
63
|
+
end
|
69
64
|
|
70
|
-
|
71
|
-
|
72
|
-
|
65
|
+
callback = Native.make_function(
|
66
|
+
"foo()",
|
67
|
+
funct,
|
68
|
+
random_thing
|
69
|
+
)
|
73
70
|
|
74
|
-
|
71
|
+
list = Native.make_function_list(1)
|
72
|
+
Native::function_set_list_entry(list, 0, callback);
|
73
|
+
Native::option_set_c_functions(options, list)
|
75
74
|
|
76
|
-
|
77
|
-
assert_equal SassC::Native.function_get_function(first_list_entry),
|
78
|
-
funct
|
79
|
-
assert_equal SassC::Native.function_get_signature(first_list_entry),
|
80
|
-
"foo()"
|
81
|
-
assert_equal SassC::Native.function_get_cookie(first_list_entry),
|
82
|
-
random_thing
|
75
|
+
assert_equal Native.option_get_c_functions(options), list
|
83
76
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
77
|
+
first_list_entry = Native.function_get_list_entry(list, 0)
|
78
|
+
assert_equal Native.function_get_function(first_list_entry),
|
79
|
+
funct
|
80
|
+
assert_equal Native.function_get_signature(first_list_entry),
|
81
|
+
"foo()"
|
82
|
+
assert_equal Native.function_get_cookie(first_list_entry),
|
83
|
+
random_thing
|
88
84
|
|
89
|
-
|
85
|
+
string = Native.make_string("hello")
|
86
|
+
assert_equal :sass_string, Native.value_get_tag(string)
|
87
|
+
assert_equal "hello", Native.string_get_value(string)
|
90
88
|
|
91
|
-
|
92
|
-
assert_equal "foo {\n margin: 43px; }\n", css
|
93
|
-
end
|
94
|
-
end
|
89
|
+
Native.compile_data_context(data_context)
|
95
90
|
|
96
|
-
|
97
|
-
|
98
|
-
within_construct do |construct|
|
99
|
-
@construct = construct
|
100
|
-
yield
|
91
|
+
css = Native.context_get_output_string(context)
|
92
|
+
assert_equal "foo {\n margin: 43px; }\n", css
|
101
93
|
end
|
102
|
-
|
103
|
-
@construct = nil
|
104
94
|
end
|
105
95
|
|
106
|
-
|
107
|
-
|
108
|
-
end
|
96
|
+
class FileContext < MiniTest::Test
|
97
|
+
include TempFileTest
|
109
98
|
|
110
|
-
|
111
|
-
|
99
|
+
def teardown
|
100
|
+
Native.delete_file_context(@file_context)
|
101
|
+
end
|
112
102
|
|
113
|
-
|
114
|
-
|
103
|
+
def test_compile_status_is_zero_when_successful
|
104
|
+
temp_file("style.scss", SAMPLE_SASS_STRING)
|
115
105
|
|
116
|
-
|
117
|
-
|
106
|
+
@file_context = Native.make_file_context("style.scss")
|
107
|
+
context = Native.file_context_get_context(@file_context)
|
118
108
|
|
119
|
-
|
120
|
-
|
121
|
-
end
|
109
|
+
status = Native.compile_file_context(@file_context)
|
110
|
+
assert_equal 0, status
|
122
111
|
|
123
|
-
|
124
|
-
|
112
|
+
status = Native.context_get_error_status(context)
|
113
|
+
assert_equal 0, status
|
114
|
+
end
|
125
115
|
|
126
|
-
|
127
|
-
|
128
|
-
SassC::Native.compile_file_context(@file_context)
|
116
|
+
def test_compiled_css_is_correct
|
117
|
+
temp_file("style.scss", SAMPLE_SASS_STRING)
|
129
118
|
|
130
|
-
|
131
|
-
|
132
|
-
|
119
|
+
@file_context = Native.make_file_context("style.scss")
|
120
|
+
context = Native.file_context_get_context(@file_context)
|
121
|
+
Native.compile_file_context(@file_context)
|
133
122
|
|
134
|
-
|
135
|
-
|
123
|
+
css = Native.context_get_output_string(context)
|
124
|
+
assert_equal SAMPLE_CSS_OUTPUT, css
|
125
|
+
end
|
136
126
|
|
137
|
-
|
138
|
-
|
139
|
-
status = SassC::Native.compile_file_context(@file_context)
|
127
|
+
def test_invalid_file_name
|
128
|
+
temp_file("style.scss", SAMPLE_SASS_STRING)
|
140
129
|
|
141
|
-
|
130
|
+
@file_context = Native.make_file_context("style.jajaja")
|
131
|
+
context = Native.file_context_get_context(@file_context)
|
132
|
+
status = Native.compile_file_context(@file_context)
|
142
133
|
|
143
|
-
|
134
|
+
refute_equal 0, status
|
144
135
|
|
145
|
-
|
146
|
-
error
|
147
|
-
end
|
136
|
+
error = Native.context_get_error_message(context)
|
148
137
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
@construct.file("import.scss", "@import 'import_parent'; $size: 30px;")
|
153
|
-
@construct.file("styles.scss", "@import 'import.scss'; .hi { width: $size; }")
|
138
|
+
assert_match "Error: File to read not found or unreadable: style.jajaja",
|
139
|
+
error
|
140
|
+
end
|
154
141
|
|
155
|
-
|
156
|
-
|
157
|
-
|
142
|
+
def test_file_import
|
143
|
+
temp_file("not_included.scss", "$size: 30px;")
|
144
|
+
temp_file("import_parent.scss", "$size: 30px;")
|
145
|
+
temp_file("import.scss", "@import 'import_parent'; $size: 30px;")
|
146
|
+
temp_file("styles.scss", "@import 'import.scss'; .hi { width: $size; }")
|
158
147
|
|
159
|
-
|
148
|
+
@file_context = Native.make_file_context("styles.scss")
|
149
|
+
context = Native.file_context_get_context(@file_context)
|
150
|
+
status = Native.compile_file_context(@file_context)
|
160
151
|
|
161
|
-
|
162
|
-
assert_equal SAMPLE_CSS_OUTPUT, css
|
152
|
+
assert_equal 0, status
|
163
153
|
|
164
|
-
|
165
|
-
|
154
|
+
css = Native.context_get_output_string(context)
|
155
|
+
assert_equal SAMPLE_CSS_OUTPUT, css
|
166
156
|
|
167
|
-
|
168
|
-
|
169
|
-
assert_match /styles.scss/, included_files[2]
|
170
|
-
end
|
157
|
+
included_files = Native.context_get_included_files(context)
|
158
|
+
included_files.sort!
|
171
159
|
|
172
|
-
|
173
|
-
|
174
|
-
|
160
|
+
assert_match /import.scss/, included_files[0]
|
161
|
+
assert_match /import_parent.scss/, included_files[1]
|
162
|
+
assert_match /styles.scss/, included_files[2]
|
163
|
+
end
|
175
164
|
|
176
|
-
|
177
|
-
|
178
|
-
|
165
|
+
def test_custom_importer
|
166
|
+
temp_file("not_included.scss", "$size: $var + 25;")
|
167
|
+
temp_file("styles.scss", "@import 'import.scss'; .hi { width: $size; }")
|
179
168
|
|
180
|
-
|
181
|
-
|
169
|
+
@file_context = Native.make_file_context("styles.scss")
|
170
|
+
context = Native.file_context_get_context(@file_context)
|
171
|
+
options = Native.context_get_options(context)
|
182
172
|
|
183
|
-
|
184
|
-
|
185
|
-
data.write_string(str)
|
173
|
+
funct = FFI::Function.new(:pointer, [:pointer, :pointer, :pointer]) do |url, prev, cookie|
|
174
|
+
list = Native.make_import_list(2)
|
186
175
|
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
176
|
+
str = "$var: 5px;\0"
|
177
|
+
data = Native::LibC.malloc(str.size)
|
178
|
+
data.write_string(str)
|
179
|
+
|
180
|
+
entry0 = Native.make_import_entry("fake_includ.scss", data, nil)
|
181
|
+
entry1 = Native.make_import_entry("not_included.scss", nil, nil)
|
182
|
+
Native.import_set_list_entry(list, 0, entry0)
|
183
|
+
Native.import_set_list_entry(list, 1, entry1)
|
184
|
+
list
|
185
|
+
end
|
193
186
|
|
194
|
-
|
187
|
+
callback = Native.make_importer(funct, nil)
|
188
|
+
list = Native.make_function_list(1)
|
189
|
+
Native::function_set_list_entry(list, 0, callback)
|
195
190
|
|
196
|
-
|
191
|
+
Native.option_set_c_importers(options, list)
|
197
192
|
|
198
|
-
|
199
|
-
|
193
|
+
status = Native.compile_file_context(@file_context)
|
194
|
+
assert_equal 0, status
|
200
195
|
|
201
|
-
|
202
|
-
|
196
|
+
css = Native.context_get_output_string(context)
|
197
|
+
assert_equal SAMPLE_CSS_OUTPUT, css
|
198
|
+
end
|
203
199
|
end
|
204
200
|
end
|
205
201
|
end
|