sassc 0.0.10 → 0.0.11

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