sassc 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sassc/engine.rb +7 -7
- data/lib/sassc/importer.rb +9 -3
- data/lib/sassc/version.rb +1 -1
- data/test/custom_importer_test.rb +24 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c779167157d51896c8f2f389090e3bbdf10ad30d
|
4
|
+
data.tar.gz: 744962a099ec22bd66708d7954d3561f422e5a9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c122bd12dc2c6ffa15b85d9ed1b0045a1419d7fbd2ad67220e3d332dea6b3fdfe725dd9d143f6680068ee033c41c066f70a30893483c7e757595d79ae9be2f9
|
7
|
+
data.tar.gz: 6a0be2aeab3aa77e953861f328a9e09cffefefc8ef0521ca24e01e3d2e5493c9eca37d6b57c410764a9bd74c9f4a2e8715f672ddedfc18e557ea2c243552d5f4
|
data/lib/sassc/engine.rb
CHANGED
@@ -10,15 +10,15 @@ module SassC
|
|
10
10
|
def render
|
11
11
|
data_context = Native.make_data_context(@template)
|
12
12
|
context = Native.data_context_get_context(data_context)
|
13
|
-
|
13
|
+
native_options = Native.context_get_options(context)
|
14
14
|
|
15
|
-
Native.option_set_is_indented_syntax_src(
|
16
|
-
Native.option_set_input_path(
|
17
|
-
Native.option_set_include_path(
|
15
|
+
Native.option_set_is_indented_syntax_src(native_options, true) if sass?
|
16
|
+
Native.option_set_input_path(native_options, filename) if filename
|
17
|
+
Native.option_set_include_path(native_options, load_paths)
|
18
18
|
|
19
|
-
importer.setup(
|
19
|
+
importer.setup(native_options) if importer
|
20
20
|
|
21
|
-
status = Script.setup_custom_functions(
|
21
|
+
status = Script.setup_custom_functions(native_options, @options) do
|
22
22
|
Native.compile_data_context(data_context)
|
23
23
|
end
|
24
24
|
|
@@ -58,7 +58,7 @@ module SassC
|
|
58
58
|
def importer
|
59
59
|
@importer ||= begin
|
60
60
|
if @options[:importer]
|
61
|
-
@options[:importer].new
|
61
|
+
@options[:importer].new(@options)
|
62
62
|
else
|
63
63
|
nil
|
64
64
|
end
|
data/lib/sassc/importer.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
1
|
module SassC
|
2
2
|
class Importer
|
3
|
-
|
3
|
+
attr_reader :options
|
4
|
+
|
5
|
+
def imports(path, parent_path)
|
4
6
|
# A custom importer must override this method.
|
5
7
|
raise NotImplementedError
|
6
8
|
end
|
7
9
|
|
8
10
|
def setup(native_options)
|
9
|
-
@function = FFI::Function.new(:pointer, [:string, :
|
10
|
-
imports = [*imports(path)]
|
11
|
+
@function = FFI::Function.new(:pointer, [:string, :string, :pointer]) do |path, parent_path, cookie|
|
12
|
+
imports = [*imports(path, parent_path)]
|
11
13
|
self.class.imports_to_native(imports)
|
12
14
|
end
|
13
15
|
|
@@ -15,6 +17,10 @@ module SassC
|
|
15
17
|
SassC::Native.option_set_importer(native_options, callback)
|
16
18
|
end
|
17
19
|
|
20
|
+
def initialize(options)
|
21
|
+
@options = options
|
22
|
+
end
|
23
|
+
|
18
24
|
def self.empty_imports
|
19
25
|
SassC::Native.make_import_list(0)
|
20
26
|
end
|
data/lib/sassc/version.rb
CHANGED
@@ -2,7 +2,7 @@ require_relative "test_helper"
|
|
2
2
|
|
3
3
|
class FunctionsTest < SassCTest
|
4
4
|
class CustomImporter < SassC::Importer
|
5
|
-
def imports(path)
|
5
|
+
def imports(path, parent_path)
|
6
6
|
if path =~ /styles/
|
7
7
|
[
|
8
8
|
Import.new("#{path}1.scss", source: "$var1: #000;"),
|
@@ -15,11 +15,17 @@ class FunctionsTest < SassCTest
|
|
15
15
|
end
|
16
16
|
|
17
17
|
class NoFilesImporter < SassC::Importer
|
18
|
-
def imports(path)
|
18
|
+
def imports(path, parent_path)
|
19
19
|
[]
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
class OptionsImporter < SassC::Importer
|
24
|
+
def imports(path, parent_path)
|
25
|
+
Import.new("name.scss", source: options[:custom_option_source])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
23
29
|
def around
|
24
30
|
within_construct do |construct|
|
25
31
|
@construct = construct
|
@@ -84,4 +90,20 @@ SCSS
|
|
84
90
|
|
85
91
|
assert_equal "", engine.render
|
86
92
|
end
|
93
|
+
|
94
|
+
def test_custom_importer_can_access_sassc_options
|
95
|
+
engine = SassC::Engine.new("@import 'fake.scss';", {
|
96
|
+
importer: OptionsImporter,
|
97
|
+
custom_option_source: ".test { width: 30px; }"
|
98
|
+
})
|
99
|
+
|
100
|
+
assert_equal <<CSS, engine.render
|
101
|
+
.test {
|
102
|
+
width: 30px; }
|
103
|
+
CSS
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_parent_path_is_accessible
|
107
|
+
skip "TBD"
|
108
|
+
end
|
87
109
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sassc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Boland
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-03-
|
11
|
+
date: 2015-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|