sassc 1.3.0 → 1.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b426c4e47a4d6d041b25565605d6fe708847faaa
4
- data.tar.gz: 36fd1baaa0ba7aaeb6b9100ee60aaeea8fa3d974
3
+ metadata.gz: 0f19dcd28af296ad0c551e0daecbc3664ea4f2c5
4
+ data.tar.gz: d59cb88bcf48437ee1973c72db482a0bcdbafba9
5
5
  SHA512:
6
- metadata.gz: 54261aec807408c986d337a75e9051062ea0d5cb45affc510285a310cc5b0d95b6d1b810afe24f9e9d0f4762a6f2bbf3615ebbabc51a9bac5d26ac08a41fe0c4
7
- data.tar.gz: 8264a970a2f76968e9eab211983c0f2c09c5f5a2ed634891146f239c25a5db7d8aa0bfa2a970e4136b1568dff97613e51e20578b112436cdffd10fa3e5db54c3
6
+ metadata.gz: 43a8b1b9b66f099ffc77547c6d53f540510c7a712e8c727fc307dcadfd69c17e39d943120e76bd4dfb004842b8465a73bba1381546edc78d20d3d5556c342f6f
7
+ data.tar.gz: 42f028720b8ed0d9a35551c00b288ffa591598f13e4f0fab7094c420ac5772c702ddd6c907ce88af07ff1b03f4b41d06cda77cf7ec2b5eeb5d8418a076cf8b2b
data/lib/sassc/engine.rb CHANGED
@@ -23,6 +23,7 @@ module SassC
23
23
  Native.option_set_input_path(native_options, filename) if filename
24
24
  Native.option_set_include_path(native_options, load_paths)
25
25
  Native.option_set_output_style(native_options, output_style_enum)
26
+ Native.option_set_source_comments(native_options, true) if line_comments?
26
27
 
27
28
  import_handler.setup(native_options)
28
29
  functions_handler.setup(native_options)
@@ -64,6 +65,10 @@ module SassC
64
65
  @options[:syntax] && @options[:syntax].to_sym == :sass
65
66
  end
66
67
 
68
+ def line_comments?
69
+ @options[:line_comments]
70
+ end
71
+
67
72
  def import_handler
68
73
  @import_handler ||= ImportHandler.new(@options)
69
74
  end
data/lib/sassc/error.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'sass/error'
2
+
1
3
  module SassC
2
4
  class SyntaxError < StandardError; end
3
5
  class NotRenderedError < StandardError; end
@@ -29,6 +29,13 @@ module SassC
29
29
  native_string = Native.string_get_value(native_value)
30
30
  argument = Script::String.new(Script::String.unquote(native_string), Script::String.type(native_string))
31
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
+
32
39
  custom_function_arguments << argument
33
40
  else
34
41
  error_tag = error("Sass argument of type #{value_tag} unsupported")
@@ -24,6 +24,19 @@ module SassC
24
24
  # ADDAPI const char* ADDCALL sass_string_get_value (const union Sass_Value* v);
25
25
  attach_function :sass_string_get_value, [:sass_value_ptr], :string
26
26
 
27
+ # ADDAPI double ADDCALL sass_color_get_r (const union Sass_Value* v);
28
+ # ADDAPI void ADDCALL sass_color_set_r (union Sass_Value* v, double r);
29
+ # ADDAPI double ADDCALL sass_color_get_g (const union Sass_Value* v);
30
+ # ADDAPI void ADDCALL sass_color_set_g (union Sass_Value* v, double g);
31
+ # ADDAPI double ADDCALL sass_color_get_b (const union Sass_Value* v);
32
+ # ADDAPI void ADDCALL sass_color_set_b (union Sass_Value* v, double b);
33
+ # ADDAPI double ADDCALL sass_color_get_a (const union Sass_Value* v);
34
+ # ADDAPI void ADDCALL sass_color_set_a (union Sass_Value* v, double a);
35
+ ['r', 'g', 'b', 'a'].each do |color_channel|
36
+ attach_function "sass_color_get_#{color_channel}".to_sym, [:sass_value_ptr], :double
37
+ attach_function "sass_color_set_#{color_channel}".to_sym, [:sass_value_ptr, :double], :void
38
+ end
39
+
27
40
  # ADDAPI size_t ADDCALL sass_list_get_length(const union Sass_Value* v)
28
41
  # ADDAPI union Sass_Value* ADDCALL sass_list_get_value (const union Sass_Value* v, size_t i);
29
42
  attach_function :sass_list_get_length, [:sass_value_ptr], :size_t
data/lib/sassc/script.rb CHANGED
@@ -18,3 +18,12 @@ end
18
18
 
19
19
  require_relative "script/functions"
20
20
  require_relative "script/string"
21
+
22
+ module Sass
23
+ module Script
24
+ end
25
+ end
26
+
27
+ require 'sass/util'
28
+ require 'sass/script/value/base'
29
+ require_relative "script/color"
@@ -0,0 +1,11 @@
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
data/lib/sassc/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module SassC
2
- VERSION = "1.3.0"
2
+ VERSION = "1.4.0"
3
3
  end
data/sassc.gemspec CHANGED
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
29
29
 
30
30
  spec.add_dependency "bundler"
31
31
  spec.add_dependency "ffi", "~> 1.9.6"
32
+ spec.add_dependency "sass", ">= 3.3.0"
32
33
 
33
34
  gem_dir = File.expand_path(File.dirname(__FILE__)) + "/"
34
35
  `git submodule --quiet foreach pwd`.split($\).each do |submodule_path|
data/test/engine_test.rb CHANGED
@@ -8,6 +8,20 @@ module SassC
8
8
  Engine.new(data).render
9
9
  end
10
10
 
11
+ def test_line_comments
12
+ template = <<-SCSS
13
+ .foo {
14
+ baz: bang; }
15
+ SCSS
16
+ expected_output = <<-CSS
17
+ /* line 1, stdin */
18
+ .foo {
19
+ baz: bang; }
20
+ CSS
21
+ output = Engine.new(template, line_comments: true).render
22
+ assert_equal expected_output, output
23
+ end
24
+
11
25
  def test_one_line_comments
12
26
  assert_equal <<CSS, render(<<SCSS)
13
27
  .foo {
@@ -62,16 +62,24 @@ div {
62
62
  EOS
63
63
  end
64
64
 
65
+ 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
71
+ end
72
+
65
73
  def test_function_with_unsupported_tag
66
- engine = Engine.new("div {url: function_with_unsupported_tag(red);}")
74
+ engine = Engine.new("div {url: function_with_unsupported_tag(1);}")
67
75
 
68
76
  exception = assert_raises(SassC::SyntaxError) do
69
77
  engine.render
70
78
  end
71
79
 
72
- assert_equal "Error: error in C function function_with_unsupported_tag: Sass argument of type sass_color 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(red);}\n ----------^\n", exception.message
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
73
81
 
74
- assert_equal "[SassC::FunctionsHandler] Sass argument of type sass_color unsupported", stderr_output
82
+ assert_equal "[SassC::FunctionsHandler] Sass argument of type sass_number unsupported", stderr_output
75
83
  end
76
84
 
77
85
  def test_function_with_error
@@ -122,7 +130,11 @@ div {
122
130
  raise StandardError, "Intentional wrong thing happened somewhere inside the custom function"
123
131
  end
124
132
 
125
- def function_with_unsupported_tag(color)
133
+ def function_with_unsupported_tag(number)
134
+ end
135
+
136
+ def nice_color_argument(color)
137
+ return Script::String.new(color.to_s, :string)
126
138
  end
127
139
 
128
140
  module Compass
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.3.0
4
+ version: 1.4.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-06-24 00:00:00.000000000 Z
11
+ date: 2015-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: 1.9.6
111
+ - !ruby/object:Gem::Dependency
112
+ name: sass
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: 3.3.0
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: 3.3.0
111
125
  description: Use libsass with Ruby!
112
126
  email:
113
127
  - bolandryanm@gmail.com
@@ -287,6 +301,7 @@ files:
287
301
  - lib/sassc/native/string_list.rb
288
302
  - lib/sassc/sass_2_scss.rb
289
303
  - lib/sassc/script.rb
304
+ - lib/sassc/script/color.rb
290
305
  - lib/sassc/script/functions.rb
291
306
  - lib/sassc/script/string.rb
292
307
  - lib/sassc/version.rb