sassc 1.5.1 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 400e2204f0a92e520fb185afaa0fd63514065b2b
4
- data.tar.gz: 1b6c396aaf27bbd1823245d10c544ae9f8a82180
3
+ metadata.gz: bac3ffe63156b284a72c2c8496c06a5b14bccc62
4
+ data.tar.gz: 55a875b297d4253f639461174e5ddd33dbe464e6
5
5
  SHA512:
6
- metadata.gz: c8fb262c7f5bf9aa3f1dc4ee6fdee6e9e65dcc8e839257089abb3c449d3b55dfb3c6a621bd421538ffed5cb79e59c8c9ae7cfd8ff96c9e94c5215fe538a40702
7
- data.tar.gz: 646e9431d13e7bff22f1209193ab0a5c1f63ddafd1aaf36318719c1a6d7009039de1ff00fedf1ed78d356b4bbdb3497bdf1e7896087679274b95ba420c9ffab0
6
+ metadata.gz: fe168c4733030c3fe7132a38c3ea09ebf03113e665cbb3df82abfdf114a32a361dc1673083037b8c9d1d6174b87e7f86e75ecdfacf23a4c3144fe1d2e7b3c499
7
+ data.tar.gz: 3159f2ef6faf4f214b1a788104f1d14511fe3d4e50503e81843821e0a05959e339b1b98514b8e8d502e278003557c0bdacb31015909d6aa440f5a79d1725dbb4
data/README.md CHANGED
@@ -18,11 +18,22 @@ to CSS. To compile, use a `SassC::Engine`.
18
18
 
19
19
  Additionally, you can use `SassC::Sass2Scss` to convert Sass syntax to Scss syntax.
20
20
 
21
+ ## Credits
22
+
23
+ This gem is maintained by [Ryan Boland](https://ryanboland.com)
24
+ and [awesome contributors](https://github.com/bolandrm/sassc-ruby/graphs/contributors).
25
+
21
26
  ## Changelog
22
27
 
28
+ - **1.6.0**
29
+ - [Support Sass Color types](https://github.com/bolandrm/sassc-ruby/pull/14)
30
+ - [Support quoted strings](https://github.com/bolandrm/sassc-ruby/pull/13)
31
+ - [Improve custom function error handling](https://github.com/bolandrm/sassc-ruby/pull/15)
32
+ - **1.5.1**
33
+ - 2nd attempt at fixing compilation bug (issue [#12](https://github.com/bolandrm/sassc-ruby/issues/12))
23
34
  - **1.5.0**
24
35
  - Add support for inline source maps
25
- - Fix compilation bug (issue #12[](https://github.com/bolandrm/sassc-ruby/issues/12))
36
+ - Fix compilation bug (issue [#12](https://github.com/bolandrm/sassc-ruby/issues/12))
26
37
  - **1.4.0**
27
38
  - Add support for line number comments
28
39
  - **1.3.0**
data/lib/sassc/error.rb CHANGED
@@ -1,7 +1,9 @@
1
1
  require 'sass/error'
2
2
 
3
3
  module SassC
4
- class SyntaxError < StandardError; end
5
- class NotRenderedError < StandardError; end
6
- class InvalidStyleError < StandardError; end
4
+ class BaseError < StandardError; end
5
+ class SyntaxError < BaseError; end
6
+ class NotRenderedError < BaseError; end
7
+ class InvalidStyleError < BaseError; end
8
+ class UnsupportedValue < BaseError; end
7
9
  end
@@ -15,46 +15,13 @@ module SassC
15
15
 
16
16
  Script.custom_functions.each_with_index do |custom_function, i|
17
17
  @callbacks[custom_function] = FFI::Function.new(:pointer, [:pointer, :pointer]) do |native_argument_list, cookie|
18
- native_argument_list_length = Native.list_get_length(native_argument_list)
19
- custom_function_arguments = []
20
- error_tag = nil
21
-
22
- (0...native_argument_list_length).each do |i|
23
- native_value = Native.list_get_value(native_argument_list, i)
24
-
25
- case value_tag = Native.value_get_tag(native_value)
26
- when :sass_null
27
- # no-op
28
- when :sass_string
29
- native_string = Native.string_get_value(native_value)
30
- argument = Script::String.new(Script::String.unquote(native_string), Script::String.type(native_string))
31
-
32
- custom_function_arguments << argument
33
- when :sass_color
34
- red, green, blue, alpha = Native.color_get_r(native_value), Native.color_get_g(native_value), Native.color_get_b(native_value), Native.color_get_a(native_value)
35
-
36
- argument = Script::Color.new([red, green, blue, alpha])
37
- argument.options = @options
38
-
39
- custom_function_arguments << argument
40
- else
41
- error_tag = error("Sass argument of type #{value_tag} unsupported")
42
- break
43
- end
44
- end
45
-
46
- next error_tag if error_tag
47
-
48
18
  begin
49
- value = functions.send(custom_function, *custom_function_arguments)
50
-
51
- if value
52
- value = Script::String.new(Script::String.unquote(value.to_s), value.type)
53
- value.to_native
54
- else
55
- Script::String.new("").to_native
56
- end
19
+ function_arguments = arguments_from_native_list(native_argument_list)
20
+ result = functions.send(custom_function, *function_arguments)
21
+ to_native_value(result)
57
22
  rescue StandardError => exception
23
+ # This rescues any exceptions that occur either in value conversion
24
+ # or during the execution of a custom function.
58
25
  error(exception.message)
59
26
  end
60
27
  end
@@ -75,19 +42,27 @@ module SassC
75
42
 
76
43
  private
77
44
 
78
- def error(message)
79
- value = Native::SassValue.new
80
- value[:unknown] = Native::SassUnknown.new
45
+ def arguments_from_native_list(native_argument_list)
46
+ native_argument_list_length = Native.list_get_length(native_argument_list)
81
47
 
82
- error = Native::SassError.new
83
- error[:tag] = :sass_error
48
+ (0...native_argument_list_length).map do |i|
49
+ native_value = Native.list_get_value(native_argument_list, i)
50
+ Script::ValueConversion.from_native(native_value, @options)
51
+ end.compact
52
+ end
84
53
 
85
- Native.error_set_message(error, Native.native_string(message))
86
- $stderr.puts "[SassC::FunctionsHandler] #{message}"
54
+ def to_native_value(sass_value)
55
+ # if the custom function returns nil, we provide a "default" return
56
+ # value of an empty string
57
+ sass_value ||= Script::String.new("")
87
58
 
88
- value[:unknown][:tag] = :sass_error
89
- value[:error] = error
90
- value.pointer
59
+ sass_value.options = @options
60
+ Script::ValueConversion.to_native(sass_value)
61
+ end
62
+
63
+ def error(message)
64
+ $stderr.puts "[SassC::FunctionsHandler] #{message}"
65
+ Native.make_error(message)
91
66
  end
92
67
 
93
68
  class FunctionWrapper
@@ -14,8 +14,18 @@ module SassC
14
14
 
15
15
  # ADDAPI union Sass_Value* ADDCALL sass_make_number (double val, const char* unit);
16
16
  attach_function :sass_make_number, [:double, :string], :sass_value_ptr
17
+
18
+ # ADDAPI union Sass_Value* ADDCALL sass_make_string (const char* val);
17
19
  attach_function :sass_make_string, [:string], :sass_value_ptr
18
20
 
21
+ # ADDAPI union Sass_Value* ADDCALL sass_make_qstring (const char* val);
22
+ attach_function :sass_make_qstring, [:string], :sass_value_ptr
23
+
24
+ # ADDAPI union Sass_Value* ADDCALL sass_make_color (double r, double g, double b, double a);
25
+ attach_function :sass_make_color, [:double, :double, :double, :double], :sass_value_ptr
26
+
27
+ # ADDAPI union Sass_Value* ADDCALL sass_make_error (const char* msg);
28
+ attach_function :sass_make_error, [:string], :sass_value_ptr
19
29
 
20
30
  # ADDAPI enum Sass_Tag ADDCALL sass_value_get_tag (const union Sass_Value* v);
21
31
  attach_function :sass_value_get_tag, [:sass_value_ptr], SassTag
@@ -24,6 +34,13 @@ module SassC
24
34
  # ADDAPI const char* ADDCALL sass_string_get_value (const union Sass_Value* v);
25
35
  attach_function :sass_string_get_value, [:sass_value_ptr], :string
26
36
 
37
+ # ADDAPI bool ADDCALL sass_string_is_quoted(const union Sass_Value* v);
38
+ attach_function :sass_string_is_quoted, [:sass_value_ptr], :bool
39
+
40
+ def self.string_get_type(native_value)
41
+ string_is_quoted(native_value) ? :string : :identifier
42
+ end
43
+
27
44
  # ADDAPI double ADDCALL sass_color_get_r (const union Sass_Value* v);
28
45
  # ADDAPI void ADDCALL sass_color_set_r (union Sass_Value* v, double r);
29
46
  # ADDAPI double ADDCALL sass_color_get_g (const union Sass_Value* v);
data/lib/sassc/script.rb CHANGED
@@ -13,11 +13,14 @@ module SassC
13
13
 
14
14
  "#{function_name}(#{params})"
15
15
  end
16
+
17
+ module Value
18
+ end
16
19
  end
17
20
  end
18
21
 
19
22
  require_relative "script/functions"
20
- require_relative "script/string"
23
+ require_relative "script/value_conversion"
21
24
 
22
25
  module Sass
23
26
  module Script
@@ -26,4 +29,11 @@ end
26
29
 
27
30
  require 'sass/util'
28
31
  require 'sass/script/value/base'
29
- require_relative "script/color"
32
+ require 'sass/script/value/string'
33
+ require 'sass/script/value/color'
34
+
35
+ SassC::Script::String = Sass::Script::Value::String
36
+ SassC::Script::Value::String = Sass::Script::Value::String
37
+
38
+ SassC::Script::Color = Sass::Script::Value::Color
39
+ SassC::Script::Value::Color = Sass::Script::Value::Color
@@ -0,0 +1,42 @@
1
+ module SassC
2
+ module Script
3
+ module ValueConversion
4
+ def self.from_native(native_value, options)
5
+ case value_tag = Native.value_get_tag(native_value)
6
+ when :sass_null
7
+ # no-op
8
+ when :sass_string
9
+ value = Native.string_get_value(native_value)
10
+ type = Native.string_get_type(native_value)
11
+ argument = Script::String.new(value, type)
12
+
13
+ argument
14
+ when :sass_color
15
+ red, green, blue, alpha = Native.color_get_r(native_value), Native.color_get_g(native_value), Native.color_get_b(native_value), Native.color_get_a(native_value)
16
+
17
+ argument = Script::Color.new([red, green, blue, alpha])
18
+ argument.options = options
19
+
20
+ argument
21
+ else
22
+ raise UnsupportedValue.new("Sass argument of type #{value_tag} unsupported")
23
+ end
24
+ end
25
+
26
+ def self.to_native(value)
27
+ case value_name = value.class.name.split("::").last
28
+ when "String"
29
+ String.new(value).to_native
30
+ when "Color"
31
+ Color.new(value).to_native
32
+ else
33
+ raise UnsupportedValue.new("Sass return type #{value_name} unsupported")
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+
40
+ require_relative "value_conversion/base"
41
+ require_relative "value_conversion/string"
42
+ require_relative "value_conversion/color"
@@ -0,0 +1,11 @@
1
+ module SassC
2
+ module Script
3
+ module ValueConversion
4
+ class Base
5
+ def initialize(value)
6
+ @value = value
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,16 @@
1
+ module SassC
2
+ module Script
3
+ module ValueConversion
4
+ class Color < Base
5
+ def to_native
6
+ Native::make_color(
7
+ @value.red,
8
+ @value.green,
9
+ @value.blue,
10
+ @value.alpha
11
+ )
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ module SassC
2
+ module Script
3
+ module ValueConversion
4
+ class String < Base
5
+ def to_native(opts = {})
6
+ if opts[:quote] == :none || @value.type == :identifier
7
+ Native::make_string(@value.to_s)
8
+ else
9
+ Native::make_qstring(@value.to_s)
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
data/lib/sassc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module SassC
2
- VERSION = "1.5.1"
2
+ VERSION = "1.6.0"
3
3
  end
@@ -14,60 +14,75 @@ module SassC
14
14
  end
15
15
 
16
16
  def test_functions_may_return_sass_string_type
17
- engine = Engine.new("div {url: url(sass_return_path('foo.svg'));}")
18
-
19
- assert_equal <<-EOS, engine.render
20
- div {
21
- url: url("foo.svg"); }
22
- EOS
17
+ assert_sass <<-SCSS, <<-CSS
18
+ div { url: url(sass_return_path("foo.svg")); }
19
+ SCSS
20
+ div { url: url("foo.svg"); }
21
+ CSS
23
22
  end
24
23
 
25
24
  def test_functions_work_with_varying_quotes_and_string_types
26
- filename = fixture_path('paths.scss')
27
- data = File.read(filename)
28
-
29
- engine = Engine.new(data, {
30
- filename: filename,
31
- syntax: :scss
32
- })
33
-
34
- assert_equal <<-EOS, engine.render
35
- div {
36
- url: url(asset-path("foo.svg"));
37
- url: url(image-path("foo.png"));
38
- url: url(video-path("foo.mov"));
39
- url: url(audio-path("foo.mp3"));
40
- url: url(font-path("foo.woff"));
41
- url: url("/js/foo.js");
42
- url: url("/js/foo.js");
43
- url: url(/css/foo.css); }
44
- EOS
25
+ assert_sass <<-SCSS, <<-CSS
26
+ div {
27
+ url: url(asset-path("foo.svg"));
28
+ url: url(image-path("foo.png"));
29
+ url: url(video-path("foo.mov"));
30
+ url: url(audio-path("foo.mp3"));
31
+ url: url(font-path("foo.woff"));
32
+ url: url(javascript-path('foo.js'));
33
+ url: url(javascript-path("foo.js"));
34
+ url: url(stylesheet-path("foo.css"));
35
+ }
36
+ SCSS
37
+ div {
38
+ url: url(asset-path("foo.svg"));
39
+ url: url(image-path("foo.png"));
40
+ url: url(video-path("foo.mov"));
41
+ url: url(audio-path("foo.mp3"));
42
+ url: url(font-path("foo.woff"));
43
+ url: url("/js/foo.js");
44
+ url: url("/js/foo.js");
45
+ url: url(/css/foo.css);
46
+ }
47
+ CSS
45
48
  end
46
49
 
47
50
  def test_function_with_no_return_value
48
- engine = Engine.new("div {url: url(no-return-path('foo.svg'));}")
51
+ assert_sass <<-SCSS, <<-CSS
52
+ div {url: url(no-return-path('foo.svg'));}
53
+ SCSS
54
+ div { url: url(); }
55
+ CSS
56
+ end
49
57
 
50
- assert_equal <<-EOS, engine.render
51
- div {
52
- url: url(); }
53
- EOS
58
+ def test_function_that_returns_a_color
59
+ assert_sass <<-SCSS, <<-CSS
60
+ div { background: returns-a-color(); }
61
+ SCSS
62
+ div { background: black; }
63
+ CSS
54
64
  end
55
65
 
56
66
  def test_function_with_optional_arguments
57
- engine = Engine.new("div {url: optional_arguments('first'); url: optional_arguments('second', 'qux')}")
58
- assert_equal <<-EOS, engine.render
59
- div {
60
- url: "first/bar";
61
- url: "second/qux"; }
62
- EOS
67
+ assert_sass <<-SCSS, <<-EXPECTED_CSS
68
+ div {
69
+ url: optional_arguments('first');
70
+ url: optional_arguments('second', 'qux');
71
+ }
72
+ SCSS
73
+ div {
74
+ url: "first/bar";
75
+ url: "second/qux";
76
+ }
77
+ EXPECTED_CSS
63
78
  end
64
79
 
65
80
  def test_functions_may_accept_sass_color_type
66
- engine = Engine.new("div { color: nice_color_argument(red); }")
67
- assert_equal <<-EOS, engine.render
68
- div {
69
- color: "red"; }
70
- EOS
81
+ assert_sass <<-SCSS, <<-EXPECTED_CSS
82
+ div { color: nice_color_argument(red); }
83
+ SCSS
84
+ div { color: "red"; }
85
+ EXPECTED_CSS
71
86
  end
72
87
 
73
88
  def test_function_with_unsupported_tag
@@ -77,36 +92,40 @@ div {
77
92
  engine.render
78
93
  end
79
94
 
80
- assert_equal "Error: error in C function function_with_unsupported_tag: Sass argument of type sass_number unsupported\n\n Backtrace:\n \tstdin:1, in function `function_with_unsupported_tag`\n \tstdin:1\n on line 1 of stdin\n>> div {url: function_with_unsupported_tag(1);}\n ----------^\n", exception.message
81
-
95
+ assert_match /Sass argument of type sass_number unsupported/, exception.message
82
96
  assert_equal "[SassC::FunctionsHandler] Sass argument of type sass_number unsupported", stderr_output
83
97
  end
84
98
 
85
99
  def test_function_with_error
86
100
  engine = Engine.new("div {url: function_that_raises_errors();}")
101
+
87
102
  exception = assert_raises(SassC::SyntaxError) do
88
103
  engine.render
89
104
  end
90
105
 
91
- assert_equal "Error: error in C function function_that_raises_errors: Intentional wrong thing happened somewhere inside the custom function
92
-
93
- Backtrace:
94
- \tstdin:1, in function `function_that_raises_errors`
95
- \tstdin:1
96
- on line 1 of stdin
97
- >> div {url: function_that_raises_errors();}
98
- ----------^
99
- ", exception.message
100
-
106
+ assert_match /Error: error in C function function_that_raises_errors/, exception.message
107
+ assert_match /Intentional wrong thing happened somewhere inside the custom function/, exception.message
101
108
  assert_equal "[SassC::FunctionsHandler] Intentional wrong thing happened somewhere inside the custom function", stderr_output
102
109
  end
103
110
 
111
+ def test_function_that_returns_a_sass_value
112
+ assert_sass <<-SCSS, <<-CSS
113
+ div { background: returns-sass-value(); }
114
+ SCSS
115
+ div { background: black; }
116
+ CSS
117
+ end
118
+
104
119
  private
105
120
 
106
- SassString = Struct.new(:value, :type) do
107
- def to_s
108
- value
109
- end
121
+ def assert_sass(sass, expected_css)
122
+ engine = Engine.new(sass)
123
+ assert_equal expected_css.strip.gsub!(/\s+/, " "), # poor man's String#squish
124
+ engine.render.strip.gsub!(/\s+/, " ")
125
+ end
126
+
127
+ def stderr_output
128
+ $stderr.string.gsub("\u0000\n", '').chomp
110
129
  end
111
130
 
112
131
  module Script::Functions
@@ -119,14 +138,14 @@ div {
119
138
  end
120
139
 
121
140
  def sass_return_path(path)
122
- return SassString.new("'#{path.value}'", :string)
141
+ Script::String.new("#{path.value}", :string)
123
142
  end
124
143
 
125
144
  def optional_arguments(path, optional = "bar")
126
- return SassString.new("#{path}/#{optional}", :string)
145
+ Script::String.new("#{path.value}/#{optional}", :string)
127
146
  end
128
147
 
129
- def function_that_raises_errors()
148
+ def function_that_raises_errors
130
149
  raise StandardError, "Intentional wrong thing happened somewhere inside the custom function"
131
150
  end
132
151
 
@@ -137,6 +156,14 @@ div {
137
156
  return Script::String.new(color.to_s, :string)
138
157
  end
139
158
 
159
+ def returns_a_color
160
+ return Script::Color.new(red: 0, green: 0, blue: 0)
161
+ end
162
+
163
+ def returns_sass_value
164
+ return Sass::Script::Value::Color.new(red: 0, green: 0, blue: 0)
165
+ end
166
+
140
167
  module Compass
141
168
  def stylesheet_path(path)
142
169
  Script::String.new("/css/#{path.value}", :identifier)
@@ -144,9 +171,5 @@ div {
144
171
  end
145
172
  include Compass
146
173
  end
147
-
148
- def stderr_output
149
- $stderr.string.gsub("\u0000\n", '')
150
- end
151
174
  end
152
175
  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: 1.5.1
4
+ version: 1.6.0
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-07-12 00:00:00.000000000 Z
11
+ date: 2015-07-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -301,9 +301,11 @@ files:
301
301
  - lib/sassc/native/string_list.rb
302
302
  - lib/sassc/sass_2_scss.rb
303
303
  - lib/sassc/script.rb
304
- - lib/sassc/script/color.rb
305
304
  - lib/sassc/script/functions.rb
306
- - lib/sassc/script/string.rb
305
+ - lib/sassc/script/value_conversion.rb
306
+ - lib/sassc/script/value_conversion/base.rb
307
+ - lib/sassc/script/value_conversion/color.rb
308
+ - lib/sassc/script/value_conversion/string.rb
307
309
  - lib/sassc/version.rb
308
310
  - lib/tasks/libsass.rb
309
311
  - sassc.gemspec
@@ -1,11 +0,0 @@
1
- require 'sass/script/value/color'
2
-
3
- module SassC
4
- module Script
5
- class Color < ::Sass::Script::Value::Color
6
- def to_native
7
- Native::make_string(to_s)
8
- end
9
- end
10
- end
11
- end
@@ -1,103 +0,0 @@
1
- module SassC
2
- module Script
3
- class String
4
- # The Ruby value of the string.
5
- #
6
- # @return [String]
7
- attr_reader :value
8
-
9
- # Whether this is a CSS string or a CSS identifier.
10
- # The difference is that strings are written with double-quotes,
11
- # while identifiers aren't.
12
- #
13
- # @return [Symbol] `:string` or `:identifier`
14
- attr_reader :type
15
-
16
- def self.value(contents)
17
- contents.gsub("\\\n", "").gsub(/\\(?:([0-9a-fA-F]{1,6})\s?|(.))/) do
18
- next $2 if $2
19
- # Handle unicode escapes as per CSS Syntax Level 3 section 4.3.8.
20
- code_point = $1.to_i(16)
21
- if code_point == 0 || code_point > 0x10FFFF ||
22
- (code_point >= 0xD800 && code_point <= 0xDFFF)
23
- '�'
24
- else
25
- [code_point].pack("U")
26
- end
27
- end
28
- end
29
-
30
- def self.quote(contents, quote = nil)
31
- # Short-circuit if there are no characters that need quoting.
32
- unless contents =~ /[\n\\"']/
33
- quote ||= '"'
34
- return "#{quote}#{contents}#{quote}"
35
- end
36
-
37
- if quote.nil?
38
- if contents.include?('"')
39
- if contents.include?("'")
40
- quote = '"'
41
- else
42
- quote = "'"
43
- end
44
- else
45
- quote = '"'
46
- end
47
- end
48
-
49
- # Replace single backslashes with multiples.
50
- contents = contents.gsub("\\", "\\\\\\\\")
51
-
52
- if quote == '"'
53
- contents = contents.gsub('"', "\\\"")
54
- else
55
- contents = contents.gsub("'", "\\'")
56
- end
57
-
58
- contents = contents.gsub(/\n(?![a-fA-F0-9\s])/, "\\a").gsub("\n", "\\a ")
59
- "#{quote}#{contents}#{quote}"
60
- end
61
-
62
- def self.type(contents)
63
- unquote(contents) == contents ? :identifier : :string
64
- end
65
-
66
- def self.unquote(contents)
67
- s = contents.dup
68
-
69
- case contents[0, 1]
70
- when "'", '"', '`'
71
- s[0] = ''
72
- end
73
-
74
- case contents[-1, 1]
75
- when "'", '"', '`'
76
- s[-1] = ''
77
- end
78
-
79
- return s
80
- end
81
-
82
- # Creates a new string.
83
- #
84
- # @param value [String] See \{#value}
85
- # @param type [Symbol] See \{#type}
86
- def initialize(value, type = :identifier)
87
- value.freeze unless value.nil? || value == true || value == false
88
- @value = value
89
- @type = type
90
- end
91
-
92
- def to_native
93
- Native::make_string(to_s)
94
- end
95
-
96
- # @see Value#to_s
97
- def to_s(opts = {})
98
- return @value.gsub(/\n\s*/, ' ') if opts[:quote] == :none || @type == :identifier
99
- SassC::Script::String.quote(value, opts[:quote])
100
- end
101
- end
102
- end
103
- end