compass-core 1.0.0.alpha.15 → 1.0.0.alpha.16

Sign up to get free protection for your applications and to get access to all the features.
data/RELEASE_VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0.alpha.15
1
+ 1.0.0.alpha.16
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0.alpha.14
1
+ 1.0.0.alpha.15
@@ -63,6 +63,7 @@ module Compass
63
63
  attributes_for_directory(:extensions, nil),
64
64
  # Compilation options
65
65
  :output_style,
66
+ :sourcemap,
66
67
  :environment,
67
68
  :relative_assets,
68
69
  :additional_import_paths,
@@ -35,14 +35,14 @@ module Compass::Core::SassExtensions::Functions::Colors
35
35
  def shade(color, percentage)
36
36
  assert_type color, :Color
37
37
  assert_type percentage, :Number
38
- black = Sass::Script::Color.new([0, 0, 0])
38
+ black = rgb_color(0, 0, 0)
39
39
  mix(black, color, percentage)
40
40
  end
41
41
 
42
42
  def tint(color, percentage)
43
43
  assert_type color, :Color
44
44
  assert_type percentage, :Number
45
- white = Sass::Script::Color.new([255, 255, 255])
45
+ white = rgb_color(255, 255, 255)
46
46
  mix(white, color, percentage)
47
47
  end
48
48
 
@@ -52,7 +52,7 @@ module Compass::Core::SassExtensions::Functions::Colors
52
52
  assert_type color, :Color
53
53
  alpha = (color.alpha * 255).round
54
54
  alphastr = alpha.to_s(16).rjust(2, '0')
55
- Sass::Script::String.new("##{alphastr}#{color.send(:hex_str)[1..-1]}".upcase)
55
+ identifier("##{alphastr}#{color.send(:hex_str)[1..-1]}".upcase)
56
56
  end
57
57
 
58
58
  private
@@ -2,20 +2,20 @@ module Compass::Core::SassExtensions::Functions::Constants
2
2
  POSITIONS = /top|bottom|left|right|center/
3
3
  if defined?(Sass::Script::Value::List)
4
4
  def is_position(position)
5
- Sass::Script::Bool.new(position.is_a?(Sass::Script::String) && !!(position.value =~ POSITIONS))
5
+ bool(position.is_a?(Sass::Script::Value::String) && !!(position.value =~ POSITIONS))
6
6
  end
7
7
  def is_position_list(position_list)
8
- Sass::Script::Bool.new(position_list.is_a?(Sass::Script::List) && position_list.value.all?{|p| is_position(p).to_bool})
8
+ bool(position_list.is_a?(Sass::Script::Value::List) && position_list.value.all?{|p| is_position(p).to_bool})
9
9
  end
10
10
  # returns the opposite position of a side or corner.
11
11
  def opposite_position(position)
12
- position = unless position.is_a?(Sass::Script::List)
13
- Sass::Script::List.new([position], :space)
12
+ position = unless position.is_a?(Sass::Script::Value::List)
13
+ list(position, :space)
14
14
  else
15
- Sass::Script::List.new(position.value.dup, position.separator)
15
+ list(position.value.dup, position.separator)
16
16
  end
17
- position = Sass::Script::List.new(position.value.map do |pos|
18
- if pos.is_a? Sass::Script::String
17
+ position = list(position.value.map do |pos|
18
+ if pos.is_a? Sass::Script::Value::String
19
19
  opposite = case pos.value
20
20
  when "top" then "bottom"
21
21
  when "bottom" then "top"
@@ -26,10 +26,10 @@ module Compass::Core::SassExtensions::Functions::Constants
26
26
  Compass::Util.compass_warn("Cannot determine the opposite position of: #{pos}")
27
27
  pos.value
28
28
  end
29
- Sass::Script::String.new(opposite)
30
- elsif pos.is_a? Sass::Script::Number
29
+ identifier(opposite)
30
+ elsif pos.is_a? Sass::Script::Value::Number
31
31
  if pos.numerator_units == ["%"] && pos.denominator_units == []
32
- Sass::Script::Number.new(100-pos.value, ["%"])
32
+ number(100-pos.value, "%")
33
33
  else
34
34
  Compass::Util.compass_warn("Cannot determine the opposite position of: #{pos}")
35
35
  pos
@@ -47,11 +47,11 @@ module Compass::Core::SassExtensions::Functions::Constants
47
47
  end
48
48
 
49
49
  def is_url(string)
50
- if string.is_a?(Sass::Script::String)
50
+ if string.is_a?(Sass::Script::Value::String)
51
51
  is_url = !!(string.value =~ /^url\(.*\)$/)
52
- Sass::Script::Bool.new(is_url)
52
+ bool(is_url)
53
53
  else
54
- Sass::Script::Bool.new(false)
54
+ bool(false)
55
55
  end
56
56
  end
57
57
  else
@@ -68,7 +68,7 @@ module Compass::Core::SassExtensions::Functions::Constants
68
68
  pos
69
69
  end
70
70
  end
71
- Sass::Script::String.new(opposite.join(" "), position.type)
71
+ identifier(opposite.join(" "))
72
72
  end
73
73
  end
74
74
  end
@@ -1,6 +1,7 @@
1
1
  module Compass::Core::SassExtensions::Functions::CrossBrowserSupport
2
+ extend Compass::Core::SassExtensions::Functions::SassDeclarationHelper
2
3
 
3
- class CSS2FallbackValue < Sass::Script::Literal
4
+ class CSS2FallbackValue < Sass::Script::Value::Base
4
5
  attr_accessor :value, :css2_value
5
6
  def children
6
7
  [value, css2_value]
@@ -31,7 +32,7 @@ module Compass::Core::SassExtensions::Functions::CrossBrowserSupport
31
32
  assert_type prefix, :String
32
33
  aspect = prefix.value.sub(/^-/,"")
33
34
  needed = args.any?{|a| a.respond_to?(:supports?) && a.supports?(aspect)}
34
- Sass::Script::Bool.new(needed)
35
+ bool(needed)
35
36
  end
36
37
 
37
38
  %w(webkit moz o ms svg css2).each do |prefix|
@@ -46,14 +47,14 @@ module Compass::Core::SassExtensions::Functions::CrossBrowserSupport
46
47
 
47
48
  def prefix(prefix, *objects)
48
49
  assert_type prefix, :String if prefix.is_a?(Sass::Script::Value::Base)
49
- prefix = prefix.value if prefix.is_a?(Sass::Script::String)
50
+ prefix = prefix.value if prefix.is_a?(Sass::Script::Value::String)
50
51
  prefix = prefix[1..-1] if prefix[0] == ?-
51
52
  if objects.size > 1
52
- self.prefix(prefix, Sass::Script::List.new(objects, :comma))
53
+ self.prefix(prefix, list(objects, :comma))
53
54
  else
54
55
  object = objects.first
55
- if object.is_a?(Sass::Script::List)
56
- Sass::Script::List.new(object.value.map{|e|
56
+ if object.is_a?(Sass::Script::Value::List)
57
+ list(object.value.map{|e|
57
58
  self.prefix(prefix, e)
58
59
  }, object.separator)
59
60
  elsif object.respond_to?(:supports?) && object.supports?(prefix) && object.respond_to?(:"to_#{prefix}")
@@ -81,14 +82,14 @@ module Compass::Core::SassExtensions::Functions::CrossBrowserSupport
81
82
  end
82
83
  list(browsers.map{|b| identifier(b)}, :comma)
83
84
  end
84
- Sass::Script::Functions.declare(:browsers, [])
85
- Sass::Script::Functions.declare(:browsers, [:prefix])
85
+ declare(:browsers, [])
86
+ declare(:browsers, [:prefix])
86
87
 
87
88
  # The known capabilities of browsers.
88
89
  def browser_capabilities
89
90
  list(Compass::Core::CanIUse.instance.capabilities.map{|c| identifier(c)}, :comma)
90
91
  end
91
- Sass::Script::Functions.declare(:browser_capabilities, [])
92
+ declare(:browser_capabilities, [])
92
93
 
93
94
  # The versions for the given browser.
94
95
  def browser_versions(browser)
@@ -97,7 +98,7 @@ module Compass::Core::SassExtensions::Functions::CrossBrowserSupport
97
98
  rescue ArgumentError => e
98
99
  raise Sass::SyntaxError.new(e.message)
99
100
  end
100
- Sass::Script::Functions.declare(:browser_versions, [:browser])
101
+ declare(:browser_versions, [:browser])
101
102
 
102
103
  # whether the browser uses a prefix for the given capability at the version
103
104
  # specified or a later version. Returns the prefix it requires, or null.
@@ -113,7 +114,7 @@ module Compass::Core::SassExtensions::Functions::CrossBrowserSupport
113
114
  rescue ArgumentError => e
114
115
  raise Sass::SyntaxError.new(e.message)
115
116
  end
116
- Sass::Script::Functions.declare(:browser_requires_prefix, [:browser, :version, :capability])
117
+ declare(:browser_requires_prefix, [:browser, :version, :capability])
117
118
 
118
119
  # the prefix for the given browser.
119
120
  def browser_prefix(browser, version = nil)
@@ -122,8 +123,8 @@ module Compass::Core::SassExtensions::Functions::CrossBrowserSupport
122
123
  rescue ArgumentError => e
123
124
  raise Sass::SyntaxError.new(e.message)
124
125
  end
125
- Sass::Script::Functions.declare(:browser_prefix, [:browser])
126
- Sass::Script::Functions.declare(:browser_prefix, [:browser, :version])
126
+ declare(:browser_prefix, [:browser])
127
+ declare(:browser_prefix, [:browser, :version])
127
128
 
128
129
  # The prefixes used by the given browsers.
129
130
  def browser_prefixes(browsers)
@@ -135,7 +136,7 @@ module Compass::Core::SassExtensions::Functions::CrossBrowserSupport
135
136
  rescue ArgumentError => e
136
137
  raise Sass::SyntaxError.new(e.message)
137
138
  end
138
- Sass::Script::Functions.declare(:browser_prefixes, [:browsers])
139
+ declare(:browser_prefixes, [:browsers])
139
140
 
140
141
  # The percent of users that are omitted by setting the min_version of browser
141
142
  # as specified.
@@ -147,8 +148,8 @@ module Compass::Core::SassExtensions::Functions::CrossBrowserSupport
147
148
  versions << max_version.value if max_version
148
149
  number(Compass::Core::CanIUse.instance.omitted_usage(browser.value, *versions))
149
150
  end
150
- Sass::Script::Functions.declare(:omitted_usage, [:browser, :min_version])
151
- Sass::Script::Functions.declare(:omitted_usage, [:browser, :min_version, :max_version])
151
+ declare(:omitted_usage, [:browser, :min_version])
152
+ declare(:omitted_usage, [:browser, :min_version, :max_version])
152
153
 
153
154
  # The version before the version for the browser specified
154
155
  def previous_version(browser, version)
@@ -157,7 +158,7 @@ module Compass::Core::SassExtensions::Functions::CrossBrowserSupport
157
158
  previous = Compass::Core::CanIUse.instance.previous_version(browser.value, version.value)
158
159
  previous.nil? ? null() : quoted_string(previous)
159
160
  end
160
- Sass::Script::Functions.declare(:previous_version, [:browser, :version])
161
+ declare(:previous_version, [:browser, :version])
161
162
 
162
163
  # The version before the version for the browser specified
163
164
  def next_version(browser, version)
@@ -166,7 +167,7 @@ module Compass::Core::SassExtensions::Functions::CrossBrowserSupport
166
167
  next_version = Compass::Core::CanIUse.instance.next_version(browser.value, version.value)
167
168
  next_version.nil? ? null() : quoted_string(next_version)
168
169
  end
169
- Sass::Script::Functions.declare(:next_version, [:browser, :version])
170
+ declare(:next_version, [:browser, :version])
170
171
 
171
172
  # The percent of users relying on a particular prefix
172
173
  def prefix_usage(prefix, capability, capability_options)
@@ -178,7 +179,7 @@ module Compass::Core::SassExtensions::Functions::CrossBrowserSupport
178
179
  rescue ArgumentError => e
179
180
  raise Sass::SyntaxError.new(e.message)
180
181
  end
181
- Sass::Script::Functions.declare(:prefix_usage, [:prefix, :capability])
182
+ declare(:prefix_usage, [:prefix, :capability])
182
183
 
183
184
  # Compares two browser versions. Returning:
184
185
  #
@@ -203,7 +204,7 @@ module Compass::Core::SassExtensions::Functions::CrossBrowserSupport
203
204
  end
204
205
  number(index1 <=> index2)
205
206
  end
206
- Sass::Script::Functions.declare(:compare_browser_versions, [:browser, :version1, :version2])
207
+ declare(:compare_browser_versions, [:browser, :version1, :version2])
207
208
 
208
209
  # Returns a map of browsers to the first version the capability became available
209
210
  # without a prefix.
@@ -224,8 +225,8 @@ module Compass::Core::SassExtensions::Functions::CrossBrowserSupport
224
225
  m
225
226
  end)
226
227
  end
227
- Sass::Script::Functions.declare(:browser_minimums, [:capability])
228
- Sass::Script::Functions.declare(:browser_minimums, [:capability, :prefix])
228
+ declare(:browser_minimums, [:capability])
229
+ declare(:browser_minimums, [:capability, :prefix])
229
230
 
230
231
  private
231
232
 
@@ -27,6 +27,6 @@ module Compass::Core::SassExtensions::Functions::Display
27
27
  # returns a comma delimited string for all the
28
28
  # elements according to their default css3 display value.
29
29
  def elements_of_type(display)
30
- Sass::Script::String.new(DEFAULT_DISPLAY.fetch(display.value.to_s).join(", "))
30
+ identifier(DEFAULT_DISPLAY.fetch(display.value.to_s).join(", "))
31
31
  end
32
32
  end
@@ -1,7 +1,7 @@
1
1
  module Compass::Core::SassExtensions::Functions::Enumerate
2
2
  def enumerate(prefix, from, through, separator = nil)
3
- separator ||= Sass::Script::String.new("-", :string)
3
+ separator ||= identifier("-")
4
4
  selectors = (from.value..through.value).map{|i| "#{prefix.value}#{separator.value}#{i}"}.join(", ")
5
- Sass::Script::String.new(selectors)
5
+ identifier(selectors)
6
6
  end
7
7
  end
@@ -1,60 +1,52 @@
1
1
  module Compass::Core::SassExtensions::Functions::Env
2
2
  extend Compass::Core::SassExtensions::Functions::SassDeclarationHelper
3
+ extend Sass::Script::Value::Helpers
3
4
 
4
5
  def compass_env
5
6
  compass_opts = options[:compass] || {}
6
- Sass::Script::String.new((compass_opts[:environment] || "development").to_s)
7
+ identifier((compass_opts[:environment] || "development").to_s)
7
8
  end
8
9
  declare :compass_env, []
9
10
 
10
- DEFAULT_TIME = Sass::Script::String.new("%T%:z")
11
+ DEFAULT_TIME = identifier("%T%:z")
11
12
  def current_time(format = DEFAULT_TIME)
12
13
  assert_type format, :String
13
- Sass::Script::String.new(Time.now.strftime(format.value))
14
+ identifier(Time.now.strftime(format.value))
14
15
  end
15
16
  declare :current_time, []
16
17
  declare :current_time, [:format]
17
18
 
18
- DEFAULT_DATE = Sass::Script::String.new("%F")
19
+ DEFAULT_DATE = identifier("%F")
19
20
  def current_date(format = DEFAULT_DATE)
20
21
  current_time(format)
21
22
  end
22
23
  declare :current_date, []
23
24
  declare :current_date, [:format]
24
25
 
25
- NOT_ABSOLUTE = Sass::Script::Bool.new(false)
26
+ NOT_ABSOLUTE = bool(false)
26
27
  def current_source_file(absolute = NOT_ABSOLUTE)
27
28
  if absolute.to_bool
28
- Sass::Script::String.new(options[:original_filename].to_s)
29
+ identifier(options[:original_filename].to_s)
29
30
  else
30
31
  filename = Pathname.new(options[:original_filename].to_s)
31
32
  sass_path = Pathname.new(Compass.configuration.sass_path)
32
33
  relative_filename = filename.relative_path_from(sass_path).to_s rescue filename
33
- Sass::Script::String.new(relative_filename.to_s)
34
+ identifier(relative_filename.to_s)
34
35
  end
35
36
  end
36
37
  declare :current_source_file, []
37
38
  declare :current_source_file, [:absolute]
38
39
 
39
40
  def current_output_file(absolute = NOT_ABSOLUTE)
40
- Sass::Script::String.new(options[:css_filename].to_s)
41
41
  if absolute.to_bool
42
- Sass::Script::String.new(options[:css_filename].to_s)
42
+ identifier(options[:css_filename].to_s)
43
43
  else
44
44
  filename = Pathname.new(options[:css_filename].to_s)
45
45
  css_path = Pathname.new(Compass.configuration.css_path)
46
46
  relative_filename = filename.relative_path_from(css_path).to_s rescue filename
47
- Sass::Script::String.new(relative_filename.to_s)
47
+ identifier(relative_filename.to_s)
48
48
  end
49
49
  end
50
50
  declare :current_output_file, []
51
51
  declare :current_output_file, [:absolute]
52
-
53
- unless Sass::Util.has?(:public_instance_method, Sass::Script::Functions, :inspect)
54
- # This is going to be in sass 3.3, just here temporarily.
55
- def inspect(value)
56
- unquoted_string(value.to_sass)
57
- end
58
- declare :inspect, [:value]
59
- end
60
52
  end
@@ -12,17 +12,18 @@ module Compass::Core::SassExtensions::Functions::FontFiles
12
12
  def font_formats(*args)
13
13
  formats = []
14
14
  with_each_font_file(*args) do |path, type|
15
- formats << Sass::Script::String.new(type)
15
+ formats << identifier(type)
16
16
  end
17
- return Sass::Script::List.new(formats, :comma)
17
+ return list(formats, :comma)
18
18
  end
19
19
 
20
20
  def font_files(*args)
21
+ return null unless args.any?
21
22
  files = []
22
23
  with_each_font_file(*args) do |path, type|
23
- files << "#{font_url(path)} format('#{type}')"
24
+ files << list(font_url(path), identifier("format('#{type}')"), :space)
24
25
  end
25
- Sass::Script::String.new(files.join(", "))
26
+ list(files, :comma)
26
27
  end
27
28
 
28
29
  protected
@@ -2,19 +2,20 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
2
2
 
3
3
  GRADIENT_ASPECTS = %w(webkit moz svg css2 o owg).freeze
4
4
 
5
- class ColorStop < Sass::Script::Literal
5
+ class ColorStop < Sass::Script::Value::Base
6
+ include Sass::Script::Value::Helpers
6
7
  attr_accessor :color, :stop
7
8
  def children
8
9
  [color, stop].compact
9
10
  end
10
11
  def initialize(color, stop = nil)
11
- unless Sass::Script::Color === color ||
12
- Sass::Script::Funcall === color ||
13
- (Sass::Script::String === color && color.value == "currentColor")||
14
- (Sass::Script::String === color && color.value == "transparent")
12
+ unless Sass::Script::Value::Color === color ||
13
+ Sass::Script::Tree::Funcall === color ||
14
+ (Sass::Script::Value::String === color && color.value == "currentColor")||
15
+ (Sass::Script::Value::String === color && color.value == "transparent")
15
16
  raise Sass::SyntaxError, "Expected a color. Got: #{color}"
16
17
  end
17
- if stop && !stop.is_a?(Sass::Script::Number)
18
+ if stop && !stop.is_a?(Sass::Script::Value::Number)
18
19
  raise Sass::SyntaxError, "Expected a number. Got: #{stop}"
19
20
  end
20
21
  self.color, self.stop = color, stop
@@ -26,9 +27,9 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
26
27
  def self.color_to_svg_s(c)
27
28
  # svg doesn't support the "transparent" keyword; we need to manually
28
29
  # refactor it into "transparent black"
29
- if c.is_a?(Sass::Script::String) && c.value == "transparent"
30
+ if c.is_a?(Sass::Script::Value::String) && c.value == "transparent"
30
31
  "black"
31
- elsif c.is_a?(Sass::Script::String)
32
+ elsif c.is_a?(Sass::Script::Value::String)
32
33
  c.value.dup
33
34
  else
34
35
  self.color_to_s(c.with(:alpha => 1))
@@ -38,9 +39,9 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
38
39
  def self.color_to_svg_alpha(c)
39
40
  # svg doesn't support the "transparent" keyword; we need to manually
40
41
  # refactor it into "transparent black"
41
- if c.is_a?(Sass::Script::String) && c.value == "transparent"
42
+ if c.is_a?(Sass::Script::Value::String) && c.value == "transparent"
42
43
  0
43
- elsif c.is_a?(Sass::Script::String) && c.value == "currentColor"
44
+ elsif c.is_a?(Sass::Script::Value::String) && c.value == "currentColor"
44
45
  1
45
46
  else
46
47
  c.alpha
@@ -48,7 +49,7 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
48
49
  end
49
50
 
50
51
  def self.color_to_s(c)
51
- if c.is_a?(Sass::Script::String)
52
+ if c.is_a?(Sass::Script::Value::String)
52
53
  c.value.dup
53
54
  else
54
55
  c.inspect.dup
@@ -60,7 +61,7 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
60
61
  if stop
61
62
  s << " "
62
63
  if stop.unitless?
63
- s << stop.times(Sass::Script::Number.new(100, ["%"])).inspect
64
+ s << stop.times(number(100, "%")).inspect
64
65
  else
65
66
  s << stop.inspect
66
67
  end
@@ -69,11 +70,12 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
69
70
  end
70
71
 
71
72
  def to_sass(options = nil)
72
- Sass::Script::String.new("color-stop(#{color.to_sass rescue nil}, #{stop.to_sass rescue nil})")
73
+ identifier("color-stop(#{color.to_sass rescue nil}, #{stop.to_sass rescue nil})")
73
74
  end
74
75
  end
75
76
 
76
77
  module Gradient
78
+ include Sass::Script::Value::Helpers
77
79
 
78
80
  def self.included(base)
79
81
  base.extend ClassMethods
@@ -83,7 +85,7 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
83
85
  def standardized_prefix(prefix)
84
86
  class_eval %Q{
85
87
  def to_#{prefix}(options = self.options)
86
- Sass::Script::String.new("-#{prefix}-\#{to_s_prefixed(options)}")
88
+ identifier("-#{prefix}-\#{to_s_prefixed(options)}")
87
89
  end
88
90
  }
89
91
  end
@@ -106,7 +108,7 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
106
108
  end
107
109
 
108
110
  def angle?(value)
109
- value.is_a?(Sass::Script::Number) &&
111
+ value.is_a?(Sass::Script::Value::Number) &&
110
112
  value.numerator_units.size == 1 &&
111
113
  value.numerator_units.first == "deg" &&
112
114
  value.denominator_units.empty?
@@ -114,7 +116,7 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
114
116
 
115
117
  end
116
118
 
117
- class RadialGradient < Sass::Script::Literal
119
+ class RadialGradient < Sass::Script::Value::Base
118
120
  include Gradient
119
121
 
120
122
  attr_accessor :position, :shape_and_size, :color_stops
@@ -157,11 +159,11 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
157
159
  end
158
160
 
159
161
  def to_css2(options = self.options)
160
- Sass::Script::String.new("")
162
+ null
161
163
  end
162
164
  end
163
165
 
164
- class LinearGradient < Sass::Script::Literal
166
+ class LinearGradient < Sass::Script::Value::Base
165
167
  include Gradient
166
168
 
167
169
  attr_accessor :color_stops, :position_or_angle, :legacy
@@ -191,10 +193,10 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
191
193
  end
192
194
 
193
195
  def convert_to_or_from_legacy(position_or_angle, options = self.options)
194
- input = if position_or_angle.is_a?(Sass::Script::Number)
196
+ input = if position_or_angle.is_a?(Sass::Script::Value::Number)
195
197
  position_or_angle
196
198
  else
197
- opts(Sass::Script::List.new(position_or_angle.to_s.split(' ').map {|s| Sass::Script::String.new(s) }, :space))
199
+ opts(list(position_or_angle.to_s.split(' ').map {|s| identifier(s) }, :space))
198
200
  end
199
201
  return convert_angle_from_offical(input).to_s(options)
200
202
  end
@@ -216,7 +218,7 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
216
218
 
217
219
  def supports?(aspect)
218
220
  # I don't know how to support degree-based gradients in old webkit gradients (owg) or svg so we just disable them.
219
- if %w(owg svg).include?(aspect) && position_or_angle.is_a?(Sass::Script::Number) && position_or_angle.numerator_units.include?("deg")
221
+ if %w(owg svg).include?(aspect) && position_or_angle.is_a?(Sass::Script::Value::Number) && position_or_angle.numerator_units.include?("deg")
220
222
  false
221
223
  else
222
224
  super
@@ -224,35 +226,36 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
224
226
  end
225
227
 
226
228
  def to_svg(options = self.options)
227
- linear_svg_gradient(color_stops, position_or_angle || Sass::Script::String.new("top"))
229
+ linear_svg_gradient(color_stops, position_or_angle || identifier("top"))
228
230
  end
229
231
 
230
232
  def to_css2(options = self.options)
231
- Sass::Script::String.new("")
233
+ null
232
234
  end
233
235
  end
234
236
 
235
237
  module Functions
238
+ include Sass::Script::Value::Helpers
236
239
 
237
240
  def convert_angle_from_offical(deg)
238
- if deg.is_a?(Sass::Script::Number)
239
- return Sass::Script::Number.new((deg.value.to_f - 450).abs % 360, ['deg'])
241
+ if deg.is_a?(Sass::Script::Value::Number)
242
+ return number((deg.value.to_f - 450).abs % 360, 'deg')
240
243
  else
241
244
  args = deg.value
242
245
  direction = []
243
- if args[0] == Sass::Script::String.new('to')
246
+ if args[0] == identifier('to')
244
247
  if args.size < 2
245
248
  direction = args
246
249
  else
247
250
  direction << opposite_position(args[1])
248
251
  end
249
252
  else
250
- direction << Sass::Script::String.new('to')
253
+ direction << identifier('to')
251
254
  args.each do |pos|
252
255
  direction << opposite_position(pos)
253
256
  end
254
257
  end
255
- return Sass::Script::String.new(direction.join(' '))
258
+ return opts(list(direction, :space))
256
259
  end
257
260
  end
258
261
 
@@ -260,10 +263,10 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
260
263
  # otherwise, returns the original argument
261
264
  def grad_point(position)
262
265
  original_value = position
263
- position = unless position.is_a?(Sass::Script::List)
264
- opts(Sass::Script::List.new([position], :space))
266
+ position = unless position.is_a?(Sass::Script::Value::List)
267
+ opts(list([position], :space))
265
268
  else
266
- opts(Sass::Script::List.new(position.value.dup, position.separator))
269
+ opts(list(position.value.dup, position.separator))
267
270
  end
268
271
  # Handle unknown arguments by passing them along untouched.
269
272
  unless position.value.all?{|p| is_position(p) }
@@ -271,43 +274,41 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
271
274
  end
272
275
  if (position.value.first.value =~ /top|bottom/) or (position.value.last.value =~ /left|right/)
273
276
  # browsers are pretty forgiving of reversed positions so we are too.
274
- position = Sass::Script::List.new(position.value.reverse, position.separator)
277
+ position = opts(list(position.value.reverse, position.separator))
275
278
  end
276
279
  if position.value.size == 1
277
280
  if position.value.first.value =~ /top|bottom/
278
- position = Sass::Script::List.new(
279
- [Sass::Script::String.new("center"), position.value.first], position.separator)
281
+ position = opts(list(identifier("center"), position.value.first, position.separator))
280
282
  elsif position.value.first.value =~ /left|right/
281
- position = Sass::Script::List.new(
282
- [position.value.first, Sass::Script::String.new("center")], position.separator)
283
+ position = opts(list(position.value.first, identifier("center"), position.separator))
283
284
  end
284
285
  end
285
- position = Sass::Script::List.new(position.value.map do |p|
286
+ position = opts(list(position.value.map do |p|
286
287
  case p.value
287
288
  when /top|left/
288
- Sass::Script::Number.new(0, ["%"])
289
+ number(0, "%")
289
290
  when /bottom|right/
290
- Sass::Script::Number.new(100, ["%"])
291
+ number(100, "%")
291
292
  when /center/
292
- Sass::Script::Number.new(50, ["%"])
293
+ number(50, "%")
293
294
  else
294
295
  p
295
296
  end
296
- end, position.separator)
297
+ end, position.separator))
297
298
  position
298
299
  end
299
300
 
300
301
  def color_stops(*args)
301
- opts(Sass::Script::List.new(args.map do |arg|
302
+ opts(list(args.map do |arg|
302
303
  if ColorStop === arg
303
304
  arg
304
- elsif Sass::Script::Color === arg
305
+ elsif Sass::Script::Value::Color === arg
305
306
  ColorStop.new(arg)
306
- elsif Sass::Script::List === arg
307
+ elsif Sass::Script::Value::List === arg
307
308
  ColorStop.new(*arg.value)
308
- elsif Sass::Script::String === arg && arg.value == "transparent"
309
+ elsif Sass::Script::Value::String === arg && arg.value == "transparent"
309
310
  ColorStop.new(arg)
310
- elsif Sass::Script::String === arg && arg.value == "currentColor"
311
+ elsif Sass::Script::Value::String === arg && arg.value == "currentColor"
311
312
  ColorStop.new(arg)
312
313
  else
313
314
  raise Sass::SyntaxError, "Not a valid color stop: #{arg.class.name}: #{arg}"
@@ -375,7 +376,7 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
375
376
  stops = color_stops_in_percentages(color_list).map do |stop, color|
376
377
  "color-stop(#{stop.inspect}, #{ColorStop.color_to_s(color)})"
377
378
  end
378
- Sass::Script::String.new(stops.join(", "))
379
+ opts(list(stops, :comma))
379
380
  end
380
381
 
381
382
  def color_stops_in_percentages(color_list)
@@ -386,7 +387,7 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
386
387
  color_stops = color_list.value.map do |pos|
387
388
  # have to convert absolute units to percentages for use in color stop functions.
388
389
  stop = pos.stop
389
- stop = stop.div(max).times(Sass::Script::Number.new(100,["%"])) if stop.numerator_units == max.numerator_units && max.numerator_units != ["%"]
390
+ stop = stop.div(max).times(number(100, "%")) if stop.numerator_units == max.numerator_units && max.numerator_units != ["%"]
390
391
  # Make sure the color stops are specified in the right order.
391
392
  if last_value && stop.numerator_units == last_value.numerator_units && stop.denominator_units == last_value.denominator_units && (stop.value * 1000).round < (last_value.value * 1000).round
392
393
  raise Sass::SyntaxError.new("Color stops must be specified in increasing order. #{stop.value} came after #{last_value.value}.")
@@ -398,31 +399,31 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
398
399
 
399
400
  # only used for webkit
400
401
  def linear_end_position(position_or_angle, color_list)
401
- start_point = grad_point(position_or_angle || Sass::Script::String.new("top"))
402
- end_point = grad_point(opposite_position(position_or_angle || Sass::Script::String.new("top")))
402
+ start_point = grad_point(position_or_angle || identifier("top"))
403
+ end_point = grad_point(opposite_position(position_or_angle || identifier("top")))
403
404
  end_target = color_list.value.last.stop
404
405
 
405
406
  if color_list.value.last.stop && color_list.value.last.stop.numerator_units == ["px"]
406
407
  new_end = color_list.value.last.stop.value
407
408
  if start_point.value.first == end_point.value.first && start_point.value.last.value == 0
408
409
  # this means top-to-bottom
409
- end_point.value[1] = Sass::Script::Number.new(end_target.value)
410
+ end_point.value[1] = number(end_target.value)
410
411
  elsif start_point.value.last == end_point.value.last && start_point.value.first.value == 0
411
412
  # this implies left-to-right
412
- end_point.value[0] = Sass::Script::Number.new(end_target.value)
413
+ end_point.value[0] = number(end_target.value)
413
414
  end
414
415
  end
415
416
  end_point
416
417
  end
417
418
 
418
419
  # returns the end position of the gradient from the color stop
419
- def grad_end_position(color_list, radial = Sass::Script::Bool.new(false))
420
+ def grad_end_position(color_list, radial = bool(false))
420
421
  assert_type color_list, :List
421
- default = Sass::Script::Number.new(100)
422
- grad_position(color_list, Sass::Script::Number.new(color_list.value.size), default, radial)
422
+ default = number(100)
423
+ grad_position(color_list, number(color_list.value.size), default, radial)
423
424
  end
424
425
 
425
- def grad_position(color_list, index, default, radial = Sass::Script::Bool.new(false))
426
+ def grad_position(color_list, index, default, radial = bool(false))
426
427
  assert_type color_list, :List
427
428
  stop = color_list.value[index.value - 1].stop
428
429
  if stop && radial.to_bool
@@ -430,17 +431,17 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
430
431
  if stop.unitless?
431
432
  if stop.value <= 1
432
433
  # A unitless number is assumed to be a percentage when it's between 0 and 1
433
- stop = stop.times(Sass::Script::Number.new(100, ["%"]))
434
+ stop = stop.times(number(100, "%"))
434
435
  else
435
436
  # Otherwise, a unitless number is assumed to be in pixels
436
- stop = stop.times(Sass::Script::Number.new(1, ["px"]))
437
+ stop = stop.times(number(1, "px"))
437
438
  end
438
439
  end
439
440
  if stop.numerator_units == ["%"] && color_list.value.last.stop && color_list.value.last.stop.numerator_units == ["px"]
440
- stop = stop.times(color_list.value.last.stop).div(Sass::Script::Number.new(100, ["%"]))
441
+ stop = stop.times(color_list.value.last.stop).div(number(100, "%"))
441
442
  end
442
443
  Compass::Logger.new.record(:warning, "Webkit only supports pixels for the start and end stops for radial gradients. Got: #{orig_stop}") if stop.numerator_units != ["px"]
443
- stop.div(Sass::Script::Number.new(1, stop.numerator_units, stop.denominator_units))
444
+ stop.div(Sass::Script::Value::Number.new(1, stop.numerator_units, stop.denominator_units))
444
445
  elsif stop
445
446
  stop
446
447
  else
@@ -459,7 +460,7 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
459
460
 
460
461
  def radial_svg_gradient(color_stops, center)
461
462
  cx, cy = *grad_point(center).value
462
- r = grad_end_position(color_stops, Sass::Script::Bool.new(true))
463
+ r = grad_end_position(color_stops, bool(true))
463
464
  stops = color_stops_in_percentages(color_stops)
464
465
 
465
466
  svg = radial_svg(stops, cx, cy, r)
@@ -470,7 +471,7 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
470
471
 
471
472
  def color_stop?(arg)
472
473
  arg.is_a?(ColorStop) ||
473
- (arg.is_a?(Sass::Script::List) && ColorStop.new(*arg.value)) ||
474
+ (arg.is_a?(Sass::Script::Value::List) && ColorStop.new(*arg.value)) ||
474
475
  ColorStop.new(arg)
475
476
  rescue
476
477
  nil
@@ -479,15 +480,15 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
479
480
  def normalize_stops(color_list)
480
481
  positions = color_list.value.map{|obj| obj.dup}
481
482
  # fill in the start and end positions, if unspecified
482
- positions.first.stop = Sass::Script::Number.new(0) unless positions.first.stop
483
- positions.last.stop = Sass::Script::Number.new(100, ["%"]) unless positions.last.stop
483
+ positions.first.stop = number(0) unless positions.first.stop
484
+ positions.last.stop = number(100, "%") unless positions.last.stop
484
485
  # fill in empty values
485
486
  for i in 0...positions.size
486
487
  if positions[i].stop.nil?
487
488
  num = 2.0
488
489
  for j in (i+1)...positions.size
489
490
  if positions[j].stop
490
- positions[i].stop = positions[i-1].stop.plus((positions[j].stop.minus(positions[i-1].stop)).div(Sass::Script::Number.new(num)))
491
+ positions[i].stop = positions[i-1].stop.plus((positions[j].stop.minus(positions[i-1].stop)).div(number(num)))
491
492
  break
492
493
  else
493
494
  num += 1
@@ -498,33 +499,29 @@ module Compass::Core::SassExtensions::Functions::GradientSupport
498
499
  # normalize unitless numbers
499
500
  positions.each do |pos|
500
501
  if pos.stop.unitless? && pos.stop.value <= 1
501
- pos.stop = pos.stop.times(Sass::Script::Number.new(100, ["%"]))
502
+ pos.stop = pos.stop.times(number(100, "%"))
502
503
  elsif pos.stop.unitless?
503
- pos.stop = pos.stop.times(Sass::Script::Number.new(1, ["px"]))
504
+ pos.stop = pos.stop.times(number(1, "px"))
504
505
  end
505
506
  end
506
- if (positions.last.stop.eq(Sass::Script::Number.new(0, ["px"])).to_bool ||
507
- positions.last.stop.eq(Sass::Script::Number.new(0, ["%"])).to_bool)
507
+ if (positions.last.stop.eq(number(0, "px")).to_bool ||
508
+ positions.last.stop.eq(number(0, "%")).to_bool)
508
509
  raise Sass::SyntaxError.new("Color stops must be specified in increasing order")
509
510
  end
510
- if defined?(Sass::Script::List)
511
- opts(Sass::Script::List.new(positions, color_list.separator))
512
- else
513
- color_list.class.new(*positions)
514
- end
511
+ opts(list(positions, color_list.separator))
515
512
  end
516
513
 
517
514
  def parse_color_stop(arg)
518
- return ColorStop.new(arg) if arg.is_a?(Sass::Script::Color)
519
- return nil unless arg.is_a?(Sass::Script::String)
515
+ return ColorStop.new(arg) if arg.is_a?(Sass::Script::Value::Color)
516
+ return nil unless arg.is_a?(Sass::Script::Value::String)
520
517
  color = stop = nil
521
518
  expr = Sass::Script::Parser.parse(arg.value, 0, 0)
522
519
  case expr
523
- when Sass::Script::Color
520
+ when Sass::Script::Value::Color
524
521
  color = expr
525
- when Sass::Script::Funcall
522
+ when Sass::Script::Tree::Funcall
526
523
  color = expr
527
- when Sass::Script::Operation
524
+ when Sass::Script::Tree::Operation
528
525
  unless [:concat, :space].include?(expr.instance_variable_get("@operator"))
529
526
  # This should never happen.
530
527
  raise Sass::SyntaxError, "Couldn't parse a color stop from: #{arg.value}"
@@ -578,10 +575,7 @@ EOS
578
575
  end
579
576
 
580
577
  def _center_position
581
- opts(Sass::Script::List.new([
582
- Sass::Script::String.new("center"),
583
- Sass::Script::String.new("center")
584
- ],:space))
578
+ opts(list(identifier("center"), identifier("center"), :space))
585
579
  end
586
580
 
587
581
  def opts(v)
@@ -600,14 +594,14 @@ EOS
600
594
  end
601
595
  end
602
596
 
603
- class LinearGradient < Sass::Script::Literal
597
+ class LinearGradient < Sass::Script::Value::Base
604
598
  include Assertions
605
599
  include Functions
606
600
  include Compass::Core::SassExtensions::Functions::Constants
607
601
  include Compass::Core::SassExtensions::Functions::InlineImage
608
602
  end
609
603
 
610
- class RadialGradient < Sass::Script::Literal
604
+ class RadialGradient < Sass::Script::Value::Base
611
605
  include Assertions
612
606
  include Functions
613
607
  include Compass::Core::SassExtensions::Functions::Constants