sass 3.2.0.alpha.7 → 3.2.0.alpha.8

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.
data/REVISION CHANGED
@@ -1 +1 @@
1
- 743da172ee789518d2e99eecb0fdf7f12fea1ee3
1
+ c041cad208c85248ccfd728f9c0a5ffe9eb9d51a
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.2.0.alpha.7
1
+ 3.2.0.alpha.8
@@ -13,7 +13,7 @@ module Sass
13
13
  # @param root [String] The root path.
14
14
  # This importer will import files relative to this path.
15
15
  def initialize(root)
16
- @root = root
16
+ @root = File.expand_path(root)
17
17
  end
18
18
 
19
19
  # @see Base#find_relative
@@ -58,9 +58,8 @@ module Sass
58
58
  # If a full uri is passed, this removes the root from it
59
59
  # otherwise returns the name unchanged
60
60
  def remove_root(name)
61
- root = @root.end_with?('/') ? @root : @root + '/'
62
- if name.index(root) == 0
63
- name[root.length..-1]
61
+ if name.index(@root + "/") == 0
62
+ name[(@root.length + 1)..-1]
64
63
  else
65
64
  name
66
65
  end
@@ -85,6 +84,7 @@ module Sass
85
84
  # The first element of each pair is a filename to look for;
86
85
  # the second element is the syntax that file would be in (`:sass` or `:scss`).
87
86
  def possible_files(name)
87
+ name = escape_glob_characters(name)
88
88
  dirname, basename, extname = split(name)
89
89
  sorted_exts = extensions.sort
90
90
  syntax = extensions[extname]
@@ -93,6 +93,11 @@ module Sass
93
93
  sorted_exts.map {|ext, syn| ["#{dirname}/{_,}#{basename}.#{ext}", syn]}
94
94
  end
95
95
 
96
+ def escape_glob_characters(name)
97
+ name.gsub(/[\*\[\]\{\}\?]/) do |char|
98
+ "\\#{char}"
99
+ end
100
+ end
96
101
 
97
102
  REDUNDANT_DIRECTORY = %r{#{Regexp.escape(File::SEPARATOR)}\.#{Regexp.escape(File::SEPARATOR)}}
98
103
  # Given a base directory and an `@import`ed name,
@@ -57,12 +57,7 @@ MSG
57
57
  "& a\n :b c" => ["Base-level rules cannot contain the parent-selector-referencing character '&'.", 1],
58
58
  "a\n :b\n c" => "Illegal nesting: Only properties may be nested beneath properties.",
59
59
  "$a: b\n :c d\n" => "Illegal nesting: Nothing may be nested beneath variable declarations.",
60
- "@import foo.sass" => "File to import not found or unreadable: foo.sass.",
61
60
  "$a: b\n :c d\n" => "Illegal nesting: Nothing may be nested beneath variable declarations.",
62
- "@import foo.sass" => <<MSG,
63
- File to import not found or unreadable: foo.sass.
64
- Load path: .
65
- MSG
66
61
  "@import templates/basic\n foo" => "Illegal nesting: Nothing may be nested beneath import directives.",
67
62
  "foo\n @import foo.css" => "CSS import directives may only be used at the root of a document.",
68
63
  "@if true\n @import foo" => "Import directives may not be used within control directives or mixins.",
@@ -579,12 +574,21 @@ CSS
579
574
  assert File.exists?(sassc_file)
580
575
  end
581
576
 
577
+ def test_nonexistent_import
578
+ assert_raise_message(Sass::SyntaxError, <<ERR.rstrip) do
579
+ File to import not found or unreadable: nonexistent.sass.
580
+ Load path: #{Dir.pwd}
581
+ ERR
582
+ render("@import nonexistent.sass")
583
+ end
584
+ end
585
+
582
586
  def test_nonexistent_extensionless_import
583
587
  assert_raise_message(Sass::SyntaxError, <<ERR.rstrip) do
584
588
  File to import not found or unreadable: nonexistent.
585
- Load path: .
589
+ Load path: #{Dir.pwd}
586
590
  ERR
587
- assert_equal("@import url(nonexistent.css);\n", render("@import nonexistent"))
591
+ render("@import nonexistent")
588
592
  end
589
593
  end
590
594
 
@@ -0,0 +1 @@
1
+ .pear { color: green; }
@@ -2,6 +2,8 @@
2
2
  require File.dirname(__FILE__) + '/../test_helper'
3
3
  require File.dirname(__FILE__) + '/test_helper'
4
4
 
5
+ require 'sass/plugin'
6
+
5
7
  class ImporterTest < Test::Unit::TestCase
6
8
 
7
9
  class FruitImporter < Sass::Importers::Base
@@ -38,6 +40,72 @@ class ImporterTest < Test::Unit::TestCase
38
40
  end
39
41
  end
40
42
 
43
+ # This importer maps one import to another import
44
+ # based on the mappings passed to importer's constructor.
45
+ class IndirectImporter < Sass::Importers::Base
46
+ def initialize(mappings, mtimes)
47
+ @mappings = mappings
48
+ @mtimes = mtimes
49
+ end
50
+ def find_relative(uri, base, options)
51
+ nil
52
+ end
53
+ def find(name, options)
54
+ if @mappings.has_key?(name)
55
+ Sass::Engine.new(
56
+ %Q[@import "#{@mappings[name]}";],
57
+ options.merge(
58
+ :filename => name,
59
+ :syntax => :scss,
60
+ :importer => self
61
+ )
62
+ )
63
+ end
64
+ end
65
+ def mtime(uri, options)
66
+ @mtimes.fetch(uri, @mtimes.has_key?(uri) ? Time.now : nil)
67
+ end
68
+ def key(uri, options)
69
+ [self.class.name, uri]
70
+ end
71
+ def to_s
72
+ "IndirectImporter(#{@mappings.keys.join(", ")})"
73
+ end
74
+ end
75
+
76
+ # This importer maps the import to single class
77
+ # based on the mappings passed to importer's constructor.
78
+ class ClassImporter < Sass::Importers::Base
79
+ def initialize(mappings, mtimes)
80
+ @mappings = mappings
81
+ @mtimes = mtimes
82
+ end
83
+ def find_relative(uri, base, options)
84
+ nil
85
+ end
86
+ def find(name, options)
87
+ if @mappings.has_key?(name)
88
+ Sass::Engine.new(
89
+ %Q[.#{name}{#{@mappings[name]}}],
90
+ options.merge(
91
+ :filename => name,
92
+ :syntax => :scss,
93
+ :importer => self
94
+ )
95
+ )
96
+ end
97
+ end
98
+ def mtime(uri, options)
99
+ @mtimes.fetch(uri, @mtimes.has_key?(uri) ? Time.now : nil)
100
+ end
101
+ def key(uri, options)
102
+ [self.class.name, uri]
103
+ end
104
+ def to_s
105
+ "ClassImporter(#{@mappings.keys.join(", ")})"
106
+ end
107
+ end
108
+
41
109
  def test_can_resolve_generated_imports
42
110
  scss_file = %Q{
43
111
  $pear-color: green;
@@ -79,4 +147,39 @@ CSS
79
147
  ensure
80
148
  FileUtils.rm_rf(absolutize("tmp"))
81
149
  end
150
+
151
+ def test_staleness_check_across_importers
152
+ file_system_importer = Sass::Importers::Filesystem.new(fixture_dir)
153
+ # Make sure the first import is older
154
+ indirect_importer = IndirectImporter.new({"apple" => "pear"}, {"apple" => Time.now - 1})
155
+ # Make css file is newer so the dependencies are the only way for the css file to be out of date.
156
+ FileUtils.touch(fixture_file("test_staleness_check_across_importers.css"))
157
+ # Make sure the first import is older
158
+ class_importer = ClassImporter.new({"pear" => %Q{color: green;}}, {"pear" => Time.now + 1})
159
+
160
+ options = {
161
+ :style => :compact,
162
+ :filename => fixture_file("test_staleness_check_across_importers.scss"),
163
+ :importer => file_system_importer,
164
+ :load_paths => [file_system_importer, indirect_importer, class_importer],
165
+ :syntax => :scss
166
+ }
167
+
168
+ assert_equal File.read(fixture_file("test_staleness_check_across_importers.css")),
169
+ Sass::Engine.new(File.read(fixture_file("test_staleness_check_across_importers.scss")), options).render
170
+
171
+ checker = Sass::Plugin::StalenessChecker.new(options)
172
+
173
+ assert checker.stylesheet_needs_update?(
174
+ fixture_file("test_staleness_check_across_importers.css"),
175
+ fixture_file("test_staleness_check_across_importers.scss"),
176
+ file_system_importer
177
+ )
178
+ end
179
+ def fixture_dir
180
+ File.join(File.dirname(__FILE__), "fixtures")
181
+ end
182
+ def fixture_file(path)
183
+ File.join(fixture_dir, path)
184
+ end
82
185
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sass
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0.alpha.7
4
+ version: 3.2.0.alpha.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan Weizenbaum
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2011-05-31 00:00:00 -04:00
14
+ date: 2011-06-11 00:00:00 -04:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
@@ -264,6 +264,8 @@ files:
264
264
  - test/sass/test_helper.rb
265
265
  - test/sass/util/subset_map_test.rb
266
266
  - test/sass/util_test.rb
267
+ - test/sass/fixtures/test_staleness_check_across_importers.css
268
+ - test/sass/fixtures/test_staleness_check_across_importers.scss
267
269
  - test/test_helper.rb
268
270
  - extra/update_watch.rb
269
271
  - Rakefile