sass 3.3.0.rc.2 → 3.3.0.rc.3

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.
Files changed (76) hide show
  1. checksums.yaml +15 -0
  2. data/CONTRIBUTING +1 -1
  3. data/README.md +7 -7
  4. data/Rakefile +4 -2
  5. data/VERSION +1 -1
  6. data/VERSION_DATE +1 -1
  7. data/bin/sass +5 -1
  8. data/bin/sass-convert +5 -1
  9. data/bin/scss +5 -1
  10. data/ext/mkrf_conf.rb +23 -0
  11. data/lib/sass/css.rb +1 -1
  12. data/lib/sass/engine.rb +19 -9
  13. data/lib/sass/environment.rb +8 -0
  14. data/lib/sass/exec.rb +4 -4
  15. data/lib/sass/features.rb +0 -1
  16. data/lib/sass/importers/base.rb +13 -6
  17. data/lib/sass/importers/deprecated_path.rb +8 -2
  18. data/lib/sass/importers/filesystem.rb +33 -7
  19. data/lib/sass/logger.rb +1 -4
  20. data/lib/sass/logger/base.rb +0 -2
  21. data/lib/sass/logger/log_level.rb +0 -2
  22. data/lib/sass/plugin.rb +2 -2
  23. data/lib/sass/plugin/compiler.rb +23 -11
  24. data/lib/sass/plugin/configuration.rb +0 -1
  25. data/lib/sass/railtie.rb +1 -0
  26. data/lib/sass/script/css_lexer.rb +0 -1
  27. data/lib/sass/script/css_parser.rb +0 -1
  28. data/lib/sass/script/functions.rb +158 -96
  29. data/lib/sass/script/lexer.rb +29 -35
  30. data/lib/sass/script/parser.rb +10 -3
  31. data/lib/sass/script/tree.rb +0 -1
  32. data/lib/sass/script/tree/funcall.rb +21 -5
  33. data/lib/sass/script/tree/list_literal.rb +0 -1
  34. data/lib/sass/script/value/arg_list.rb +7 -3
  35. data/lib/sass/script/value/bool.rb +0 -1
  36. data/lib/sass/script/value/null.rb +0 -1
  37. data/lib/sass/script/value/number.rb +2 -6
  38. data/lib/sass/scss/css_parser.rb +0 -1
  39. data/lib/sass/scss/parser.rb +5 -5
  40. data/lib/sass/scss/script_lexer.rb +0 -1
  41. data/lib/sass/scss/script_parser.rb +0 -1
  42. data/lib/sass/selector.rb +11 -1
  43. data/lib/sass/selector/comma_sequence.rb +3 -4
  44. data/lib/sass/selector/sequence.rb +11 -7
  45. data/lib/sass/selector/simple_sequence.rb +42 -11
  46. data/lib/sass/source/map.rb +6 -19
  47. data/lib/sass/tree/at_root_node.rb +1 -1
  48. data/lib/sass/tree/mixin_node.rb +2 -2
  49. data/lib/sass/tree/prop_node.rb +0 -1
  50. data/lib/sass/tree/variable_node.rb +0 -5
  51. data/lib/sass/tree/visitors/check_nesting.rb +0 -1
  52. data/lib/sass/tree/visitors/convert.rb +2 -2
  53. data/lib/sass/tree/visitors/cssize.rb +184 -84
  54. data/lib/sass/tree/visitors/deep_copy.rb +0 -1
  55. data/lib/sass/tree/visitors/perform.rb +14 -44
  56. data/lib/sass/util.rb +59 -12
  57. data/lib/sass/util/cross_platform_random.rb +19 -0
  58. data/lib/sass/util/normalized_map.rb +17 -1
  59. data/test/sass/compiler_test.rb +10 -0
  60. data/test/sass/conversion_test.rb +36 -0
  61. data/test/sass/css2sass_test.rb +19 -0
  62. data/test/sass/engine_test.rb +54 -105
  63. data/test/sass/functions_test.rb +233 -26
  64. data/test/sass/importer_test.rb +72 -10
  65. data/test/sass/plugin_test.rb +14 -0
  66. data/test/sass/script_conversion_test.rb +4 -4
  67. data/test/sass/script_test.rb +58 -21
  68. data/test/sass/scss/css_test.rb +8 -1
  69. data/test/sass/scss/scss_test.rb +376 -179
  70. data/test/sass/source_map_test.rb +8 -0
  71. data/test/sass/templates/subdir/import_up1.scss +1 -0
  72. data/test/sass/templates/subdir/import_up2.scss +1 -0
  73. data/test/sass/util_test.rb +16 -0
  74. data/test/test_helper.rb +12 -4
  75. metadata +269 -287
  76. data/lib/sass/script/tree/selector.rb +0 -30
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MDU0OWFlNWFmNTQ3YzkyMzA1ZTQyYmRkNzk0ZDM5MGM4MGEyMzdmMQ==
5
+ data.tar.gz: !binary |-
6
+ Yzg5MzQ5NDBhNmZkMWJiMGQ0NzYxNmY4MmFmMWU4MTIzNGQ1OGRmNw==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZDQwYWRlNWYwODlmMzhiOTJiNmUyOWFhOTExZmU2NmRhZTVhYTdkMTNlOTUy
10
+ MjAxMDQyMTQyN2Y3ZTIwOGM0ZTVjNjJkN2Q1YWU2ZjNjMWI4ZTRjZmQ4YjM0
11
+ NjE4ZDUyZjQ1NTNlODBiMGM2YzYzYzExYjQ4N2MwODNiNDBhNGI=
12
+ data.tar.gz: !binary |-
13
+ YjhjMzNhMDU2ZDdlNmJiNmExNjYyMTAyMzg3NjhhZWJjNzFmMGFjMzU3Y2Zk
14
+ NzE5MzA3YTY5ZWJkNGQyNTc0ZmVmODliYzRkYWQ4MDAwZjQyMmFlMWIwMjE2
15
+ MzBlZjE5YmU5OWFjZjdhODQ4N2E4Mjg1YjY0YmZhYjQxZDE4Zjk=
@@ -1,3 +1,3 @@
1
1
  Contributions are welcomed. Please see the following sites for guidelines:
2
2
 
3
- http://sass-lang.com/development.html#contributing
3
+ http://sass-lang.com/community#Contribute
data/README.md CHANGED
@@ -57,7 +57,7 @@ Then any Sass files in `public/stylesheets/sass`
57
57
  will be compiled into CSS files in `public/stylesheets` on every request.
58
58
 
59
59
  To use Sass programmatically,
60
- check out the [YARD documentation](http://sass-lang.com/docs/yardoc/).
60
+ check out the [YARD documentation](http://sass-lang.com/documentation/file.SASS_REFERENCE.html#using_sass).
61
61
 
62
62
  ## Formatting
63
63
 
@@ -71,10 +71,10 @@ and get small stylesheets up and running quickly,
71
71
  particularly with the help of
72
72
  [the Compass style library](http://compass-style.org).
73
73
 
74
- [vars]: http://beta.sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#variables_
75
- [nested]: http://beta.sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#nested_rules_
76
- [mixins]: http://beta.sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#mixins
77
- [imports]: http://beta.sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#import
74
+ [vars]: http://sass-lang.com/documentation/file.SASS_REFERENCE.html#variables_
75
+ [nested]: http://sass-lang.com/documentation/file.SASS_REFERENCE.html#nested_rules
76
+ [mixins]: http://sass-lang.com/documentation/file.SASS_REFERENCE.html#mixins
77
+ [imports]: http://sass-lang.com/documentation/file.SASS_REFERENCE.html#import
78
78
 
79
79
  Sass has two syntaxes.
80
80
  The one presented here, known as "SCSS" (for "Sassy CSS"),
@@ -83,7 +83,7 @@ The other (older) syntax, known as the indented syntax or just "Sass",
83
83
  is whitespace-sensitive and indentation-based.
84
84
  For more information, see the [reference documentation][syntax].
85
85
 
86
- [syntax]: http://beta.sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html#syntax
86
+ [syntax]: http://sass-lang.com/documentation/file.SASS_REFERENCE.html#syntax
87
87
 
88
88
  To run the following examples and see the CSS they produce,
89
89
  put them in a file called `test.scss` and run `sass test.scss`.
@@ -152,7 +152,7 @@ You can even give them arguments.
152
152
  }
153
153
 
154
154
  A comprehensive list of features is available
155
- in the [Sass reference](http://beta.sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html).
155
+ in the [Sass reference](http://sass-lang.com/documentation/file.SASS_REFERENCE.html).
156
156
 
157
157
  ## Executables
158
158
 
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ require 'rubygems/package'
2
+
1
3
  # ----- Utility Functions -----
2
4
 
3
5
  def scope(path)
@@ -21,7 +23,7 @@ end
21
23
 
22
24
  # ----- Code Style Enforcement -----
23
25
 
24
- if RUBY_VERSION !~ /^(1\.8|2\.1)/ && (ENV.has_key?("RUBOCOP") && ENV["RUBOCOP"] == "true" || !(ENV.has_key?("RUBOCOP") || ENV.has_key?("TEST")))
26
+ if RUBY_VERSION !~ /^(1\.8)/ && (ENV.has_key?("RUBOCOP") && ENV["RUBOCOP"] == "true" || !(ENV.has_key?("RUBOCOP") || ENV.has_key?("TEST")))
25
27
  require 'rubocop/rake_task'
26
28
  Rubocop::RakeTask.new do |t|
27
29
  t.patterns = FileList["lib/**/*"]
@@ -47,7 +49,7 @@ task :package => [:revision_file, :date_file, :submodules, :permissions] do
47
49
  version = get_version
48
50
  File.open(scope('VERSION'), 'w') {|f| f.puts(version)}
49
51
  load scope('sass.gemspec')
50
- Gem::Builder.new(SASS_GEMSPEC).build
52
+ Gem::Package.build(SASS_GEMSPEC)
51
53
  sh %{git checkout VERSION}
52
54
 
53
55
  pkg = "#{SASS_GEMSPEC.name}-#{SASS_GEMSPEC.version}"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.3.0.rc.2
1
+ 3.3.0.rc.3
@@ -1 +1 @@
1
- 23 November 2013 02:13:52 UTC
1
+ 07 February 2014 23:53:37 UTC
data/bin/sass CHANGED
@@ -2,7 +2,11 @@
2
2
  # The command line Sass parser.
3
3
 
4
4
  THIS_FILE = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
5
- require File.dirname(THIS_FILE) + '/../lib/sass'
5
+ begin
6
+ require File.dirname(THIS_FILE) + '/../lib/sass'
7
+ rescue LoadError
8
+ require 'sass'
9
+ end
6
10
  require 'sass/exec'
7
11
 
8
12
  opts = Sass::Exec::Sass.new(ARGV)
@@ -1,7 +1,11 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  THIS_FILE = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
4
- require File.dirname(THIS_FILE) + '/../lib/sass'
4
+ begin
5
+ require File.dirname(THIS_FILE) + '/../lib/sass'
6
+ rescue LoadError
7
+ require 'sass'
8
+ end
5
9
  require 'sass/exec'
6
10
 
7
11
  opts = Sass::Exec::SassConvert.new(ARGV)
data/bin/scss CHANGED
@@ -2,7 +2,11 @@
2
2
  # The command line Sass parser.
3
3
 
4
4
  THIS_FILE = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
5
- require File.dirname(THIS_FILE) + '/../lib/sass'
5
+ begin
6
+ require File.dirname(THIS_FILE) + '/../lib/sass'
7
+ rescue LoadError
8
+ require 'sass'
9
+ end
6
10
  require 'sass/exec'
7
11
 
8
12
  opts = Sass::Exec::Scss.new(ARGV)
@@ -0,0 +1,23 @@
1
+ require 'rubygems'
2
+ require 'rubygems/command.rb'
3
+ require 'rubygems/dependency_installer.rb'
4
+
5
+ # This script installs the correct version of listen. Listen versions
6
+ # beyond 1.1 don't support Ruby 1.8, any RubyGems isn't clever enough
7
+ # to install the most recent version that works, so we have to do it
8
+ # manually.
9
+
10
+ Gem::Command.build_args = ARGV
11
+ inst = Gem::DependencyInstaller.new
12
+ if RUBY_VERSION < "1.9"
13
+ puts "Installing listen ~> 1.1.0"
14
+ inst.install "listen", "~> 1.1.0"
15
+ else
16
+ puts "Installing listen >= 1.1.0, < 2.5"
17
+ inst.install "listen", Gem::Requirement.new(">= 1.1.0", "< 2.5")
18
+ end
19
+
20
+ # Create a dummy rakefile to indicate success.
21
+ f = File.open(File.join(File.dirname(__FILE__), "Rakefile"), "w")
22
+ f.write("task :default\n")
23
+ f.close
@@ -293,7 +293,7 @@ module Sass
293
293
  def bubble_subject(root)
294
294
  root.children.each do |child|
295
295
  bubble_subject(child) if child.is_a?(Tree::RuleNode) || child.is_a?(Tree::DirectiveNode)
296
- next unless child.is_a?(Tree::RuleNode)
296
+ next unless child.is_a?(Tree::RuleNode) && !child.children.empty?
297
297
  next unless child.children.all? do |c|
298
298
  next unless c.is_a?(Tree::RuleNode)
299
299
  first_simple_sel(c).is_a?(Sass::Selector::Parent) && first_sseq(c).subject?
@@ -51,7 +51,6 @@ require 'sass/media'
51
51
  require 'sass/supports'
52
52
 
53
53
  module Sass
54
-
55
54
  # A Sass mixin or function.
56
55
  #
57
56
  # `name`: `String`
@@ -346,16 +345,24 @@ module Sass
346
345
  private
347
346
 
348
347
  def _render_with_sourcemap(sourcemap_uri)
349
- if @options[:filename].nil?
348
+ filename = @options[:filename]
349
+ importer = @options[:importer]
350
+ sourcemap_dir = @options[:sourcemap_filename] &&
351
+ File.dirname(File.expand_path(@options[:sourcemap_filename]))
352
+ if filename.nil?
350
353
  raise Sass::SyntaxError.new(<<ERR)
351
354
  Error generating source map: couldn't determine public URL for the source stylesheet.
352
355
  No filename is available so there's nothing for the source map to link to.
353
356
  ERR
354
- elsif @options[:importer].nil? ||
355
- !(@options[:importer].public_url(@options[:filename]) ||
356
- @options[:importer].is_a?(Sass::Importers::Filesystem))
357
+ elsif importer.nil?
358
+ raise Sass::SyntaxError.new(<<ERR)
359
+ Error generating source map: couldn't determine public URL for "#{filename}".
360
+ Without a public URL, there's nothing for the source map to link to.
361
+ An importer was not set for this file.
362
+ ERR
363
+ elsif Sass::Util.silence_warnings {importer.public_url(filename, sourcemap_dir).nil?}
357
364
  raise Sass::SyntaxError.new(<<ERR)
358
- Error generating source map: couldn't determine public URL for "#{@options[:filename]}".
365
+ Error generating source map: couldn't determine public URL for "#{filename}".
359
366
  Without a public URL, there's nothing for the source map to link to.
360
367
  Custom importers should define the #public_url method.
361
368
  ERR
@@ -367,7 +374,7 @@ ERR
367
374
  rendered << "\n" unless compressed
368
375
  rendered << "/*# sourceMappingURL="
369
376
  rendered << Sass::Util.escape_uri(sourcemap_uri)
370
- rendered << " */"
377
+ rendered << " */\n"
371
378
  rendered = encode_and_set_charset(rendered)
372
379
  return rendered, sourcemap
373
380
  end
@@ -575,6 +582,8 @@ MSG
575
582
  if continued_comment &&
576
583
  child.line == continued_comment.line +
577
584
  continued_comment.lines + 1
585
+ continued_comment.value.last.sub!(/ \*\/\Z/, '')
586
+ child.value.first.gsub!(/\A\/\*/, ' *')
578
587
  continued_comment.value += ["\n"] + child.value
579
588
  next
580
589
  end
@@ -789,6 +798,7 @@ WARNING
789
798
  # rubocop:disable MethodLength
790
799
  def parse_directive(parent, line, root)
791
800
  directive, whitespace, value = line.text[1..-1].split(/(\s+)/, 2)
801
+ raise SyntaxError.new("Invalid directive: '@'.") unless directive
792
802
  offset = directive.size + whitespace.size + 1 if whitespace
793
803
 
794
804
  directive_name = directive.gsub('-', '_').to_sym
@@ -1127,12 +1137,12 @@ WARNING
1127
1137
  content.shift
1128
1138
  end
1129
1139
 
1130
- return silent ? "//" : "/* */" if content.empty?
1140
+ return "/* */" if content.empty?
1131
1141
  content.last.gsub!(/ ?\*\/ *$/, '')
1132
1142
  content.map! {|l| l.gsub!(/^\*( ?)/, '\1') || (l.empty? ? "" : " ") + l}
1133
1143
  content.first.gsub!(/^ /, '') unless removed_first
1134
1144
  if silent
1135
- "//" + content.join("\n//")
1145
+ "/*" + content.join("\n *") + " */"
1136
1146
  else
1137
1147
  # The #gsub fixes the case of a trailing */
1138
1148
  "/*" + content.join("\n *").gsub(/ \*\Z/, '') + " */"
@@ -76,6 +76,13 @@ module Sass
76
76
  # Sass::Callable
77
77
  inherited_hash_reader :function
78
78
 
79
+ # Whether a warning has been emitted for assigning to the given
80
+ # global variable. This is a set of tuples containing the name of
81
+ # the variable, its filename, and its line number.
82
+ #
83
+ # @return [Set<[String, String, int]>]
84
+ attr_reader :global_warning_given
85
+
79
86
  # @param options [{Symbol => Object}] The options hash. See
80
87
  # {file:SASS_REFERENCE.md#sass_options the Sass options documentation}.
81
88
  # @param parent [Environment] See \{#parent}
@@ -83,6 +90,7 @@ module Sass
83
90
  @parent = parent
84
91
  @options = options || (parent && parent.options) || {}
85
92
  @stack = Sass::Stack.new if @parent.nil?
93
+ @global_warning_given = Set.new
86
94
  end
87
95
 
88
96
  # The environment of the caller of this environment's mixin or function.
@@ -316,7 +316,7 @@ END
316
316
  else
317
317
  'Specify the default encoding for Sass files.'
318
318
  end
319
- opts.on('-E encoding', encoding_desc) do |encoding|
319
+ opts.on('-E', '--default-encoding ENCODING', encoding_desc) do |encoding|
320
320
  if ::Sass::Util.ruby1_8?
321
321
  $stderr.puts "Specifying the encoding is not supported in ruby 1.8."
322
322
  exit 1
@@ -347,6 +347,7 @@ END
347
347
  super
348
348
  @options[:for_engine][:filename] = @options[:filename]
349
349
  @options[:for_engine][:css_filename] = @options[:output] if @options[:output].is_a?(String)
350
+ @options[:for_engine][:sourcemap_filename] = @options[:sourcemap_filename]
350
351
 
351
352
  begin
352
353
  input = @options[:input]
@@ -535,15 +536,14 @@ MSG
535
536
  end
536
537
 
537
538
  def default_sass_path
538
- if ENV['SASSPATH']
539
+ if ENV['SASS_PATH']
539
540
  # The select here prevents errors when the environment's
540
541
  # load paths specified do not exist.
541
- ENV['SASSPATH'].split(File::PATH_SEPARATOR).select {|d| File.directory?(d)}
542
+ ENV['SASS_PATH'].split(File::PATH_SEPARATOR).select {|d| File.directory?(d)}
542
543
  else
543
544
  [::Sass::Importers::DeprecatedPath.new(".")]
544
545
  end
545
546
  end
546
-
547
547
  end
548
548
 
549
549
  class Scss < Sass
@@ -3,7 +3,6 @@ module Sass
3
3
  # Provides `Sass.has_feature?` which allows for simple feature detection
4
4
  # by providing a feature name.
5
5
  module Features
6
-
7
6
  # This is the set of features that can be detected.
8
7
  KNOWN_FEATURES = Set[*%w{
9
8
  }]
@@ -15,13 +15,9 @@ module Sass
15
15
  # They should also implement the \{#find\_relative} method.
16
16
  #
17
17
  # Importers should be serializable via `Marshal.dump`.
18
- # In addition to the standard `_dump` and `_load` methods,
19
- # importers can define `_before_dump`, `_after_dump`, `_around_dump`,
20
- # and `_after_load` methods as per {Sass::Util#dump} and {Sass::Util#load}.
21
18
  #
22
19
  # @abstract
23
20
  class Base
24
-
25
21
  # Find a Sass file relative to another file.
26
22
  # Importers without a notion of "relative paths"
27
23
  # should just return nil here.
@@ -129,8 +125,19 @@ module Sass
129
125
  # from this importer.
130
126
  #
131
127
  # @param uri [String] A URI known to be valid for this importer.
132
- # @return [String?] The publicly-visible URL for this file.
133
- def public_url(uri)
128
+ # @param sourcemap_directory [String, NilClass] The absolute path to a
129
+ # directory on disk where the sourcemap will be saved. If uri refers to
130
+ # a file on disk that's accessible relative to sourcemap_directory, this
131
+ # may return a relative URL. This may be `nil` if the sourcemap's
132
+ # eventual location is unknown.
133
+ # @return [String?] The publicly-visible URL for this file, or `nil`
134
+ # indicating that no publicly-visible URL exists.
135
+ def public_url(uri, sourcemap_directory = nil)
136
+ return if @public_url_warning_issued
137
+ @public_url_warning_issued = true
138
+ Sass::Util.sass_warn <<WARNING
139
+ WARNING: #{self.class.name} should define the #public_url method.
140
+ WARNING
134
141
  nil
135
142
  end
136
143
 
@@ -4,7 +4,6 @@ module Sass
4
4
  # import a file. It is used to deprecate the current working
5
5
  # directory from the list of automatic sass load paths.
6
6
  class DeprecatedPath < Filesystem
7
-
8
7
  # @param root [String] The absolute, expanded path to the folder that is deprecated.
9
8
  def initialize(root)
10
9
  @specified_root = root
@@ -22,6 +21,13 @@ module Sass
22
21
  found
23
22
  end
24
23
 
24
+ # @see Base#directories_to_watch
25
+ def directories_to_watch
26
+ # The current working directory was not watched in Sass 3.2,
27
+ # so we continue not to watch it while it's deprecated.
28
+ []
29
+ end
30
+
25
31
  # @see Sass::Importers::Base#to_s
26
32
  def to_s
27
33
  "#{@root} (DEPRECATED)"
@@ -36,7 +42,7 @@ module Sass
36
42
  <<WARNING
37
43
  DEPRECATION WARNING: Importing from #{path} will not be
38
44
  automatic in future versions of Sass. To avoid future errors, you can add it
39
- to your environment explicitly by setting `SASSPATH=#{@specified_root}`, by using the -I command
45
+ to your environment explicitly by setting `SASS_PATH=#{@specified_root}`, by using the -I command
40
46
  line option, or by changing your Sass configuration options.
41
47
  WARNING
42
48
  end
@@ -6,7 +6,6 @@ module Sass
6
6
  # The default importer, used for any strings found in the load path.
7
7
  # Simply loads Sass files from the filesystem using the default logic.
8
8
  class Filesystem < Base
9
-
10
9
  attr_accessor :root
11
10
 
12
11
  # Creates a new filesystem importer that imports files relative to a given path.
@@ -66,6 +65,21 @@ module Sass
66
65
  filename.start_with?(root + File::SEPARATOR)
67
66
  end
68
67
 
68
+ def public_url(name, sourcemap_directory = nil)
69
+ if sourcemap_directory.nil?
70
+ warn_about_public_url(name)
71
+ else
72
+ file_pathname = Pathname.new(Sass::Util.absolute_path(name, @root)).cleanpath
73
+ sourcemap_pathname = Pathname.new(sourcemap_directory).cleanpath
74
+ begin
75
+ file_pathname.relative_path_from(sourcemap_pathname).to_s
76
+ rescue ArgumentError # when a relative path cannot be constructed
77
+ warn_about_public_url(name)
78
+ nil
79
+ end
80
+ end
81
+ end
82
+
69
83
  protected
70
84
 
71
85
  # If a full uri is passed, this removes the root from it
@@ -130,10 +144,10 @@ module Sass
130
144
  dir = dir.gsub(File::ALT_SEPARATOR, File::SEPARATOR) unless File::ALT_SEPARATOR.nil?
131
145
 
132
146
  found = possible_files(remove_root(name)).map do |f, s|
133
- path = dir == "." || Pathname.new(f).absolute? ? f : "#{dir}/#{f}"
147
+ path = dir == "." || Pathname.new(f).absolute? ? f : "#{escape_glob_characters(dir)}/#{f}"
134
148
  Dir[path].map do |full_path|
135
149
  full_path.gsub!(REDUNDANT_DIRECTORY, File::SEPARATOR)
136
- [full_path, s]
150
+ [Pathname.new(full_path).cleanpath.to_s, s]
137
151
  end
138
152
  end
139
153
  found = Sass::Util.flatten(found, 1)
@@ -181,6 +195,22 @@ WARNING
181
195
  [dirname, basename, extension]
182
196
  end
183
197
 
198
+ # Issues a warning about being unable to determine a public url.
199
+ #
200
+ # @param uri [String] A URI known to be valid for this importer.
201
+ # @return [NilClass] nil
202
+ def warn_about_public_url(uri)
203
+ @warnings_issued ||= Set.new
204
+ unless @warnings_issued.include?(uri)
205
+ Sass::Util.sass_warn <<WARNING
206
+ WARNING: Couldn't determine public URL for "#{uri}" while generating sourcemap.
207
+ Without a public URL, there's nothing for the source map to link to.
208
+ WARNING
209
+ @warnings_issued << uri
210
+ end
211
+ nil
212
+ end
213
+
184
214
  private
185
215
 
186
216
  def _find(dir, name, options)
@@ -192,10 +222,6 @@ WARNING
192
222
  options[:importer] = self
193
223
  Sass::Engine.new(File.read(full_filename), options)
194
224
  end
195
-
196
- def join(base, path)
197
- Pathname.new(base).join(path).to_s
198
- end
199
225
  end
200
226
  end
201
227
  end