sass 3.3.0.alpha.64 → 3.3.0.alpha.67

Sign up to get free protection for your applications and to get access to all the features.
data/REVISION CHANGED
@@ -1 +1 @@
1
- 62e36b0efe872f1be55de2a82b01d88f2b08d9b1
1
+ f2051741fd9b7025a9ad2a9601cabeaea16a9c35
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.3.0.alpha.64
1
+ 3.3.0.alpha.67
data/VERSION_DATE CHANGED
@@ -1 +1 @@
1
- 27 December 2012 22:38:55 GMT
1
+ 28 December 2012 21:03:29 GMT
data/lib/sass/engine.rb CHANGED
@@ -273,7 +273,8 @@ module Sass
273
273
  # to the location of the CSS file.
274
274
  # @return [(String, Sass::Source::Map)] The rendered CSS and the associated
275
275
  # source map
276
- # @raise [Sass::SyntaxError] if there's an error in the document
276
+ # @raise [Sass::SyntaxError] if there's an error in the document, or if the
277
+ # public URL for this document couldn't be determined.
277
278
  # @raise [Encoding::UndefinedConversionError] if the source encoding
278
279
  # cannot be converted to UTF-8
279
280
  # @raise [ArgumentError] if the document uses an unknown encoding with `@charset`
@@ -332,6 +333,21 @@ module Sass
332
333
  private
333
334
 
334
335
  def _render_with_sourcemap(sourcemap_uri)
336
+ if @options[:filename].nil?
337
+ raise Sass::SyntaxError.new(<<ERR)
338
+ Error generating source map: couldn't determine public URL for the source stylesheet.
339
+ No filename is available so there's nothing for the source map to link to.
340
+ ERR
341
+ elsif @options[:importer].nil? ||
342
+ !(@options[:importer].public_url(@options[:filename]) ||
343
+ @options[:importer].is_a?(Sass::Importers::Filesystem))
344
+ raise Sass::SyntaxError.new(<<ERR)
345
+ Error generating source map: couldn't determine public URL for "#{@options[:filename]}".
346
+ Without a public URL, there's nothing for the source map to link to.
347
+ Custom importers should define the #public_url method.
348
+ ERR
349
+ end
350
+
335
351
  rendered, sourcemap = _to_tree.render_with_sourcemap
336
352
  compressed = @options[:style] == :compressed
337
353
  rendered << "\n" if rendered[-1] != ?\n
@@ -331,7 +331,7 @@ module Sass::Plugin
331
331
  end
332
332
 
333
333
  write_file(css, rendered)
334
- write_file(sourcemap, mapping.to_json(css)) if mapping
334
+ write_file(sourcemap, mapping.to_json(:css_path => css, :sourcemap_path => sourcemap)) if mapping
335
335
  run_updated_stylesheet(filename, css, sourcemap) unless compilation_error_occured
336
336
  end
337
337
 
@@ -76,9 +76,9 @@ module Sass::Source
76
76
  # layout of the server for the purposes of linking to source stylesheets
77
77
  # that use the filesystem importer.
78
78
  #
79
- # Regardless of which options are passed to this method, sourcemap
80
- # generation will fail if the source stylesheet contains any import that
81
- # uses a non-default importer that doesn't implement
79
+ # Regardless of which options are passed to this method, source stylesheets
80
+ # that are imported using a non-default importer will only be linked to in
81
+ # the source map if their importers implement
82
82
  # \{Sass::Importers::Base#public\_url\}.
83
83
  #
84
84
  # @option options :css_uri [String]
@@ -88,10 +88,8 @@ module Sass::Source
88
88
  # @option options :sourcemap_path [String]
89
89
  # The (eventual) local path of the sourcemap file.
90
90
  # @return [String] The JSON string.
91
- # @raise [ArgumentError] If neither `:css_uri` nor `:css_path` are
92
- # specified.
93
- # @raise [Sass::SyntaxError] If the public URL of a stylesheet cannot be
94
- # determined.
91
+ # @raise [ArgumentError] If neither `:css_uri` nor `:css_path` and
92
+ # `:sourcemap_path` are specified.
95
93
  def to_json(options)
96
94
  css_uri, css_path, sourcemap_path = [:css_uri, :css_path, :sourcemap_path].map {|o| options[o]}
97
95
  unless css_uri || (css_path && sourcemap_path)
@@ -110,6 +108,7 @@ module Sass::Source
110
108
  next_source_id = 0
111
109
  line_data = []
112
110
  segment_data_for_line = []
111
+ no_public_url = Set.new
113
112
 
114
113
  # These track data necessary for the delta coding.
115
114
  previous_target_line = nil
@@ -124,10 +123,16 @@ module Sass::Source
124
123
  if importer.is_a?(Sass::Importers::Filesystem) && sourcemap_path
125
124
  file_path = Pathname.new(importer.root).join(file)
126
125
  source_uri = file_path.relative_path_from(sourcemap_path.dirname).to_s
126
+ elsif no_public_url.include?(file)
127
+ next
127
128
  else
128
- raise Sass::SyntaxError.new(<<ERR)
129
- Error generating source map: couldn't determine public URL for "#{file}".
130
- ERR
129
+ no_public_url << file
130
+ Sass::Util.sass_warn <<WARNING
131
+ WARNING: Couldn't determine public URL for "#{file}" while generating sourcemap.
132
+ Without a public URL, there's nothing for the source map to link to.
133
+ Custom importers should define the #public_url method.
134
+ WARNING
135
+ next
131
136
  end
132
137
  end
133
138
 
@@ -225,9 +225,11 @@ SCSS
225
225
 
226
226
  rendered, sourcemap = engine.render_with_sourcemap('http://1.example.com/style.map')
227
227
 
228
- assert_raise_message(Sass::SyntaxError, <<MESSAGE) {sourcemap.to_json(:css_uri => 'css_uri')}
229
- Error generating source map: couldn't determine public URL for "#{filename_for_test(:scss)}".
230
- MESSAGE
228
+ assert_warning(<<WARNING) {sourcemap.to_json(:css_uri => 'css_uri')}
229
+ WARNING: Couldn't determine public URL for "#{filename_for_test(:scss)}" while generating sourcemap.
230
+ Without a public URL, there's nothing for the source map to link to.
231
+ Custom importers should define the #public_url method.
232
+ WARNING
231
233
  end
232
234
 
233
235
  def test_source_map_with_css_uri_and_css_path_doesnt_support_filesystem_importer
@@ -244,9 +246,11 @@ SCSS
244
246
 
245
247
  rendered, sourcemap = engine.render_with_sourcemap('http://1.example.com/style.map')
246
248
 
247
- assert_raise_message(Sass::SyntaxError, <<MESSAGE) {sourcemap.to_json(:css_uri => 'css_uri', :css_path => 'css_path')}
248
- Error generating source map: couldn't determine public URL for "#{filename_for_test(:scss)}".
249
- MESSAGE
249
+ assert_warning(<<WARNING) {sourcemap.to_json(:css_uri => 'css_uri', :css_path => 'css_path')}
250
+ WARNING: Couldn't determine public URL for "#{filename_for_test(:scss)}" while generating sourcemap.
251
+ Without a public URL, there's nothing for the source map to link to.
252
+ Custom importers should define the #public_url method.
253
+ WARNING
250
254
  end
251
255
 
252
256
  def test_source_map_with_css_uri_and_sourcemap_path_supports_filesystem_importer
@@ -302,6 +306,24 @@ SCSS
302
306
  JSON
303
307
  end
304
308
 
309
+ def test_render_with_sourcemap_requires_filename
310
+ file_system_importer = Sass::Importers::Filesystem.new('.')
311
+ engine = Sass::Engine.new(".foo {a: b}", :syntax => :scss, :importer => file_system_importer)
312
+ assert_raise_message(Sass::SyntaxError, <<MESSAGE) {engine.render_with_sourcemap('sourcemap_url')}
313
+ Error generating source map: couldn't determine public URL for the source stylesheet.
314
+ No filename is available so there's nothing for the source map to link to.
315
+ MESSAGE
316
+ end
317
+
318
+ def test_render_with_sourcemap_requires_importer_with_public_url
319
+ class_importer = ClassImporter.new({"pear" => "color: green;"}, {"pear" => Time.now})
320
+ assert_raise_message(Sass::SyntaxError, <<MESSAGE) {class_importer.find("pear", {}).render_with_sourcemap('sourcemap_url')}
321
+ Error generating source map: couldn't determine public URL for "pear".
322
+ Without a public URL, there's nothing for the source map to link to.
323
+ Custom importers should define the #public_url method.
324
+ MESSAGE
325
+ end
326
+
305
327
  def fixture_dir
306
328
  File.join(File.dirname(__FILE__), "fixtures")
307
329
  end
@@ -375,7 +375,7 @@ CSS
375
375
  def test_extend_sourcemap_scss
376
376
  assert_parses_with_mapping <<'SCSS', <<'CSS'
377
377
  .error {
378
- {{1}}border{{/1}}: {{2}}1px #f00{{/2}};
378
+ {{1}}border{{/1}}: {{2}}1px #ff00aa{{/2}};
379
379
  {{3}}background-color{{/3}}: {{4}}#fdd{{/4}};
380
380
  }
381
381
  .seriousError {
@@ -384,7 +384,7 @@ CSS
384
384
  }
385
385
  SCSS
386
386
  .error, .seriousError {
387
- {{1}}border{{/1}}: {{2}}1px #f00{{/2}};
387
+ {{1}}border{{/1}}: {{2}}1px #ff00aa{{/2}};
388
388
  {{3}}background-color{{/3}}: {{4}}#fdd{{/4}}; }
389
389
 
390
390
  .seriousError {
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sass
3
3
  version: !ruby/object:Gem::Version
4
- hash: 592302989
4
+ hash: 592302987
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 3
8
8
  - 3
9
9
  - 0
10
10
  - alpha
11
- - 64
12
- version: 3.3.0.alpha.64
11
+ - 67
12
+ version: 3.3.0.alpha.67
13
13
  platform: ruby
14
14
  authors:
15
15
  - Nathan Weizenbaum
@@ -19,7 +19,7 @@ autorequire:
19
19
  bindir: bin
20
20
  cert_chain: []
21
21
 
22
- date: 2012-12-27 00:00:00 -05:00
22
+ date: 2012-12-28 00:00:00 -05:00
23
23
  default_executable:
24
24
  dependencies:
25
25
  - !ruby/object:Gem::Dependency