sass 3.2.19 → 3.3.0.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CONTRIBUTING +1 -1
- data/MIT-LICENSE +2 -2
- data/README.md +13 -14
- data/REVISION +1 -1
- data/Rakefile +4 -6
- data/VERSION +1 -1
- data/VERSION_DATE +1 -1
- data/VERSION_NAME +1 -1
- data/bin/sass +1 -6
- data/bin/sass-convert +1 -6
- data/bin/scss +1 -6
- data/lib/sass/cache_stores/base.rb +0 -2
- data/lib/sass/cache_stores/chain.rb +1 -1
- data/lib/sass/cache_stores/filesystem.rb +3 -6
- data/lib/sass/callbacks.rb +1 -1
- data/lib/sass/css.rb +1 -1
- data/lib/sass/engine.rb +4 -11
- data/lib/sass/error.rb +2 -2
- data/lib/sass/exec.rb +10 -40
- data/lib/sass/importers/filesystem.rb +15 -52
- data/lib/sass/logger/log_level.rb +3 -3
- data/lib/sass/media.rb +4 -1
- data/lib/sass/plugin.rb +1 -2
- data/lib/sass/plugin/compiler.rb +18 -40
- data/lib/sass/plugin/staleness_checker.rb +5 -21
- data/lib/sass/railtie.rb +0 -1
- data/lib/sass/script/funcall.rb +8 -62
- data/lib/sass/script/functions.rb +457 -557
- data/lib/sass/script/lexer.rb +30 -25
- data/lib/sass/script/list.rb +1 -2
- data/lib/sass/script/literal.rb +18 -0
- data/lib/sass/script/null.rb +1 -4
- data/lib/sass/script/operation.rb +1 -0
- data/lib/sass/script/parser.rb +35 -42
- data/lib/sass/script/string.rb +1 -1
- data/lib/sass/script/unary_operation.rb +3 -8
- data/lib/sass/scss/parser.rb +14 -33
- data/lib/sass/scss/rx.rb +10 -3
- data/lib/sass/selector.rb +16 -19
- data/lib/sass/selector/sequence.rb +7 -16
- data/lib/sass/selector/simple.rb +1 -1
- data/lib/sass/selector/simple_sequence.rb +15 -25
- data/lib/sass/tree/comment_node.rb +2 -2
- data/lib/sass/tree/import_node.rb +2 -9
- data/lib/sass/tree/visitors/check_nesting.rb +2 -3
- data/lib/sass/tree/visitors/convert.rb +4 -9
- data/lib/sass/tree/visitors/cssize.rb +15 -36
- data/lib/sass/tree/visitors/perform.rb +20 -23
- data/lib/sass/tree/visitors/set_options.rb +0 -8
- data/lib/sass/tree/visitors/to_css.rb +1 -0
- data/lib/sass/util.rb +2 -120
- data/lib/sass/util/multibyte_string_scanner.rb +8 -29
- data/test/sass/conversion_test.rb +8 -33
- data/test/sass/css2sass_test.rb +0 -19
- data/test/sass/engine_test.rb +17 -129
- data/test/sass/extend_test.rb +24 -169
- data/test/sass/functions_test.rb +73 -93
- data/test/sass/plugin_test.rb +11 -72
- data/test/sass/script_conversion_test.rb +0 -14
- data/test/sass/script_test.rb +1 -40
- data/test/sass/scss/css_test.rb +3 -44
- data/test/sass/scss/scss_test.rb +3 -134
- data/test/sass/util_test.rb +0 -93
- data/vendor/listen/CHANGELOG.md +2 -83
- data/vendor/listen/Gemfile +1 -8
- data/vendor/listen/Guardfile +1 -1
- data/vendor/listen/LICENSE +1 -1
- data/vendor/listen/README.md +5 -8
- data/vendor/listen/lib/listen.rb +5 -7
- data/vendor/listen/lib/listen/adapter.rb +29 -76
- data/vendor/listen/lib/listen/adapters/darwin.rb +10 -11
- data/vendor/listen/lib/listen/adapters/linux.rb +30 -33
- data/vendor/listen/lib/listen/adapters/polling.rb +1 -2
- data/vendor/listen/lib/listen/adapters/windows.rb +21 -27
- data/vendor/listen/lib/listen/directory_record.rb +10 -63
- data/vendor/listen/lib/listen/listener.rb +0 -22
- data/vendor/listen/lib/listen/multi_listener.rb +0 -22
- data/vendor/listen/lib/listen/version.rb +1 -1
- data/vendor/listen/listen.gemspec +4 -0
- data/vendor/listen/spec/listen/adapter_spec.rb +4 -45
- data/vendor/listen/spec/listen/adapters/darwin_spec.rb +0 -6
- data/vendor/listen/spec/listen/adapters/linux_spec.rb +0 -6
- data/vendor/listen/spec/listen/adapters/windows_spec.rb +1 -7
- data/vendor/listen/spec/listen/directory_record_spec.rb +4 -91
- data/vendor/listen/spec/listen/listener_spec.rb +0 -14
- data/vendor/listen/spec/listen/multi_listener_spec.rb +1 -19
- data/vendor/listen/spec/spec_helper.rb +3 -6
- data/vendor/listen/spec/support/adapter_helper.rb +212 -125
- data/vendor/listen/spec/support/listeners_helper.rb +1 -13
- data/vendor/listen/spec/support/platform_helper.rb +0 -4
- metadata +113 -105
- checksums.yaml +0 -7
- data/lib/sass/util/test.rb +0 -10
- data/test/sass/exec_test.rb +0 -86
- data/test/sass/results/cached_import_option.css +0 -3
- data/test/sass/templates/_cached_import_option_partial.scss +0 -1
- data/test/sass/templates/_same_name_different_partiality.scss +0 -1
- data/test/sass/templates/bork5.sass +0 -3
- data/test/sass/templates/cached_import_option.scss +0 -3
- data/test/sass/templates/same_name_different_ext.sass +0 -2
- data/test/sass/templates/same_name_different_ext.scss +0 -1
- data/test/sass/templates/same_name_different_partiality.scss +0 -1
- data/test/sass/templates/subdir/import_up1.scss +0 -1
- data/test/sass/templates/subdir/import_up2.scss +0 -1
- data/vendor/listen/CONTRIBUTING.md +0 -38
- data/vendor/listen/lib/listen/adapters/bsd.rb +0 -112
- data/vendor/listen/lib/listen/dependency_manager.rb +0 -126
- data/vendor/listen/spec/listen/adapters/bsd_spec.rb +0 -36
- data/vendor/listen/spec/listen/dependency_manager_spec.rb +0 -107
data/CONTRIBUTING
CHANGED
data/MIT-LICENSE
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Copyright (c) 2006-
|
1
|
+
Copyright (c) 2006-2009 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein
|
2
2
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining
|
4
4
|
a copy of this software and associated documentation files (the
|
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
17
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
18
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
19
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Sass
|
1
|
+
# Sass
|
2
2
|
|
3
3
|
**Sass makes CSS fun again**. Sass is an extension of CSS3,
|
4
4
|
adding nested rules, variables, mixins, selector inheritance, and more.
|
@@ -56,8 +56,8 @@ to `config.ru`.
|
|
56
56
|
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
|
-
To use Sass
|
60
|
-
check out the [YARD documentation](http://sass-lang.com/
|
59
|
+
To use Sass programatically,
|
60
|
+
check out the [YARD documentation](http://sass-lang.com/docs/yardoc/).
|
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://sass-lang.com/
|
75
|
-
[nested]: http://sass-lang.com/
|
76
|
-
[mixins]: http://sass-lang.com/
|
77
|
-
[imports]: http://sass-lang.com/
|
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
|
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://sass-lang.com/
|
86
|
+
[syntax]: http://beta.sass-lang.com/docs/yardoc/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://sass-lang.com/
|
155
|
+
in the [Sass reference](http://beta.sass-lang.com/docs/yardoc/file.SASS_REFERENCE.html).
|
156
156
|
|
157
157
|
## Executables
|
158
158
|
|
@@ -173,11 +173,10 @@ See `sass-convert --help` for further information and options.
|
|
173
173
|
|
174
174
|
## Authors
|
175
175
|
|
176
|
-
Sass was envisioned by [Hampton Catlin](http://
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
at [Moovweb](http://www.moovweb.com/).
|
176
|
+
Sass was envisioned by [Hampton Catlin](http://hamptoncatlin.com) (hcatlin).
|
177
|
+
However, Hampton doesn't even know his way around the code anymore and now
|
178
|
+
occasionally consults on the language issues. Hampton lives in Cambridge, UK and
|
179
|
+
is the owner of [Catlin Software](http://www.catlinsoftware.com/).
|
181
180
|
|
182
181
|
[Nathan Weizenbaum](http://nex-3.com) is the primary developer and architect of
|
183
182
|
Sass. His hard work has kept the project alive by endlessly answering forum
|
data/REVISION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
ec80ec8b58b347b4890c8c47a4cb2a6fcfd77406
|
data/Rakefile
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'rubygems/package'
|
2
|
-
|
3
1
|
# ----- Utility Functions -----
|
4
2
|
|
5
3
|
def scope(path)
|
@@ -30,7 +28,7 @@ task :package => [:revision_file, :date_file, :submodules, :permissions] do
|
|
30
28
|
version = get_version
|
31
29
|
File.open(scope('VERSION'), 'w') {|f| f.puts(version)}
|
32
30
|
load scope('sass.gemspec')
|
33
|
-
Gem::
|
31
|
+
Gem::Builder.new(SASS_GEMSPEC).build
|
34
32
|
sh %{git checkout VERSION}
|
35
33
|
|
36
34
|
pkg = "#{SASS_GEMSPEC.name}-#{SASS_GEMSPEC.version}"
|
@@ -87,8 +85,8 @@ desc "Release a new Sass package to Rubyforge."
|
|
87
85
|
task :release => [:check_release, :package] do
|
88
86
|
name = File.read(scope("VERSION_NAME")).strip
|
89
87
|
version = File.read(scope("VERSION")).strip
|
90
|
-
|
91
|
-
|
88
|
+
sh %{rubyforge add_release sass sass "#{name} (v#{version})" pkg/sass-#{version}.gem}
|
89
|
+
sh %{rubyforge add_file sass sass "#{name} (v#{version})" pkg/sass-#{version}.tar.gz}
|
92
90
|
sh %{gem push pkg/sass-#{version}.gem}
|
93
91
|
end
|
94
92
|
|
@@ -142,7 +140,7 @@ task :release_edge do
|
|
142
140
|
sh %{git reset --hard origin/master}
|
143
141
|
sh %{rake package}
|
144
142
|
version = get_version
|
145
|
-
|
143
|
+
sh %{rubyforge add_release sass sass "Bleeding Edge (v#{version})" pkg/sass-#{version}.gem}
|
146
144
|
sh %{gem push pkg/sass-#{version}.gem}
|
147
145
|
end
|
148
146
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.3.0.alpha.1
|
data/VERSION_DATE
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
11 August 2012 01:22:07 GMT
|
data/VERSION_NAME
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
Bleeding Edge
|
data/bin/sass
CHANGED
@@ -1,12 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# The command line Sass parser.
|
3
3
|
|
4
|
-
|
5
|
-
begin
|
6
|
-
require File.dirname(THIS_FILE) + '/../lib/sass'
|
7
|
-
rescue LoadError
|
8
|
-
require 'sass'
|
9
|
-
end
|
4
|
+
require File.dirname(__FILE__) + '/../lib/sass'
|
10
5
|
require 'sass/exec'
|
11
6
|
|
12
7
|
opts = Sass::Exec::Sass.new(ARGV)
|
data/bin/sass-convert
CHANGED
@@ -1,11 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
4
|
-
begin
|
5
|
-
require File.dirname(THIS_FILE) + '/../lib/sass'
|
6
|
-
rescue LoadError
|
7
|
-
require 'sass'
|
8
|
-
end
|
3
|
+
require File.dirname(__FILE__) + '/../lib/sass'
|
9
4
|
require 'sass/exec'
|
10
5
|
|
11
6
|
opts = Sass::Exec::SassConvert.new(ARGV)
|
data/bin/scss
CHANGED
@@ -1,12 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
# The command line Sass parser.
|
3
3
|
|
4
|
-
|
5
|
-
begin
|
6
|
-
require File.dirname(THIS_FILE) + '/../lib/sass'
|
7
|
-
rescue LoadError
|
8
|
-
require 'sass'
|
9
|
-
end
|
4
|
+
require File.dirname(__FILE__) + '/../lib/sass'
|
10
5
|
require 'sass/exec'
|
11
6
|
|
12
7
|
opts = Sass::Exec::Scss.new(ARGV)
|
@@ -51,7 +51,6 @@ module Sass
|
|
51
51
|
_store(key, Sass::VERSION, sha, Marshal.dump(root))
|
52
52
|
rescue TypeError, LoadError => e
|
53
53
|
Sass::Util.sass_warn "Warning. Error encountered while saving cache #{path_to(key)}: #{e}"
|
54
|
-
nil
|
55
54
|
end
|
56
55
|
|
57
56
|
# Retrieve a {Sass::Tree::RootNode}.
|
@@ -64,7 +63,6 @@ module Sass
|
|
64
63
|
Marshal.load(contents) if contents
|
65
64
|
rescue EOFError, TypeError, ArgumentError, LoadError => e
|
66
65
|
Sass::Util.sass_warn "Warning. Error encountered while reading cache #{path_to(key)}: #{e}"
|
67
|
-
nil
|
68
66
|
end
|
69
67
|
|
70
68
|
# Return the key for the sass file.
|
@@ -17,16 +17,13 @@ module Sass
|
|
17
17
|
# @see Base#\_retrieve
|
18
18
|
def _retrieve(key, version, sha)
|
19
19
|
return unless File.readable?(path_to(key))
|
20
|
+
contents = nil
|
20
21
|
File.open(path_to(key), "rb") do |f|
|
21
22
|
if f.readline("\n").strip == version && f.readline("\n").strip == sha
|
22
23
|
return f.read
|
23
24
|
end
|
24
25
|
end
|
25
|
-
|
26
|
-
File.unlink path_to(key)
|
27
|
-
rescue Errno::ENOENT
|
28
|
-
# Already deleted. Race condition?
|
29
|
-
end
|
26
|
+
File.unlink path_to(key)
|
30
27
|
nil
|
31
28
|
rescue EOFError, TypeError, ArgumentError => e
|
32
29
|
Sass::Util.sass_warn "Warning. Error encountered while reading cache #{path_to(key)}: #{e}"
|
@@ -40,7 +37,7 @@ module Sass
|
|
40
37
|
# return if File.exists?(File.dirname(compiled_filename)) && !File.writable?(File.dirname(compiled_filename))
|
41
38
|
# return if File.exists?(compiled_filename) && !File.writable?(compiled_filename)
|
42
39
|
FileUtils.mkdir_p(File.dirname(compiled_filename))
|
43
|
-
|
40
|
+
File.open(compiled_filename, "wb") do |f|
|
44
41
|
f.puts(version)
|
45
42
|
f.puts(sha)
|
46
43
|
f.write(contents)
|
data/lib/sass/callbacks.rb
CHANGED
@@ -48,7 +48,7 @@ module Sass
|
|
48
48
|
# @param name [Symbol] The name of the callback
|
49
49
|
# @return [void]
|
50
50
|
def define_callback(name)
|
51
|
-
class_eval <<RUBY
|
51
|
+
class_eval <<RUBY
|
52
52
|
def on_#{name}(&block)
|
53
53
|
@_sass_callbacks ||= {}
|
54
54
|
(@_sass_callbacks[#{name.inspect}] ||= []) << block
|
data/lib/sass/css.rb
CHANGED
@@ -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)
|
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?
|
data/lib/sass/engine.rb
CHANGED
@@ -293,7 +293,7 @@ module Sass
|
|
293
293
|
# @return [[Sass::Engine]] The dependency documents.
|
294
294
|
def dependencies
|
295
295
|
_dependencies(Set.new, engines = Set.new)
|
296
|
-
|
296
|
+
engines - [self]
|
297
297
|
end
|
298
298
|
|
299
299
|
# Helper for \{#dependencies}.
|
@@ -379,7 +379,7 @@ module Sass
|
|
379
379
|
comment_tab_str = nil
|
380
380
|
first = true
|
381
381
|
lines = []
|
382
|
-
string.gsub(/\r\n|\r
|
382
|
+
string.gsub(/\r|\n|\r\n|\r\n/, "\n").scan(/^[^\n]*?$/).each_with_index do |line, index|
|
383
383
|
index += (@options[:line] || 1)
|
384
384
|
if line.strip.empty?
|
385
385
|
lines.last.text << "\n" if lines.last && lines.last.comment?
|
@@ -637,6 +637,7 @@ WARNING
|
|
637
637
|
value = [line.text]
|
638
638
|
else
|
639
639
|
value = self.class.parse_interp(line.text, line.index, line.offset, :filename => @filename)
|
640
|
+
value[0].slice!(2) if loud # get rid of the "!"
|
640
641
|
end
|
641
642
|
value = with_extracted_values(value) do |str|
|
642
643
|
str = str.gsub(/^#{line.comment_tab_str}/m, '')[2..-1] # get rid of // or /*
|
@@ -712,15 +713,7 @@ WARNING
|
|
712
713
|
when 'media'
|
713
714
|
parser = Sass::SCSS::Parser.new(value, @options[:filename], @line)
|
714
715
|
Tree::MediaNode.new(parser.parse_media_query_list.to_a)
|
715
|
-
when nil
|
716
|
-
raise SyntaxError.new("Invalid directive: '@'.")
|
717
716
|
else
|
718
|
-
unprefixed_directive = directive.gsub(/^-[a-z0-9]+-/i, '')
|
719
|
-
if unprefixed_directive == 'supports'
|
720
|
-
parser = Sass::SCSS::Parser.new(value, @options[:filename], @line)
|
721
|
-
return Tree::SupportsNode.new(directive, parser.parse_supports_condition)
|
722
|
-
end
|
723
|
-
|
724
717
|
Tree::DirectiveNode.new(
|
725
718
|
value.nil? ? ["@#{directive}"] : ["@#{directive} "] + parse_interp(value, offset))
|
726
719
|
end
|
@@ -827,7 +820,7 @@ WARNING
|
|
827
820
|
media_parser = Sass::SCSS::Parser.new(scanner, @options[:filename], @line)
|
828
821
|
media = media_parser.parse_media_query_list
|
829
822
|
Tree::CssImportNode.new(str || uri, media.to_a)
|
830
|
-
elsif val =~ /^
|
823
|
+
elsif val =~ /^http:\/\//
|
831
824
|
Tree::CssImportNode.new("url(#{val})")
|
832
825
|
else
|
833
826
|
Tree::ImportNode.new(val)
|
data/lib/sass/error.rb
CHANGED
data/lib/sass/exec.rb
CHANGED
@@ -108,7 +108,7 @@ module Sass
|
|
108
108
|
@options[:filename] = filename
|
109
109
|
open_file(filename) || $stdin
|
110
110
|
end
|
111
|
-
output ||= args.shift || $stdout
|
111
|
+
output ||= open_file(args.shift, 'w') || $stdout
|
112
112
|
|
113
113
|
@options[:input], @options[:output] = input, output
|
114
114
|
end
|
@@ -125,7 +125,6 @@ module Sass
|
|
125
125
|
def puts_action(name, color, arg)
|
126
126
|
return if @options[:for_engine][:quiet]
|
127
127
|
printf color(color, "%11s %s\n"), name, arg
|
128
|
-
STDOUT.flush
|
129
128
|
end
|
130
129
|
|
131
130
|
# Same as \{Kernel.puts}, but doesn't print anything if the `--quiet` option is set.
|
@@ -155,23 +154,12 @@ module Sass
|
|
155
154
|
return "\e[#{COLORS[color]}m#{str}\e[0m"
|
156
155
|
end
|
157
156
|
|
158
|
-
def write_output(text, destination)
|
159
|
-
if destination.is_a?(String)
|
160
|
-
open_file(destination, 'w') {|file| file.write(text)}
|
161
|
-
else
|
162
|
-
destination.write(text)
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
157
|
private
|
167
158
|
|
168
159
|
def open_file(filename, flag = 'r')
|
169
160
|
return if filename.nil?
|
170
161
|
flag = 'wb' if @options[:unix_newlines] && flag == 'w'
|
171
|
-
|
172
|
-
return file unless block_given?
|
173
|
-
yield file
|
174
|
-
file.close
|
162
|
+
File.open(filename, flag)
|
175
163
|
end
|
176
164
|
|
177
165
|
def handle_load_error(err)
|
@@ -241,10 +229,6 @@ END
|
|
241
229
|
'Only meaningful for --watch and --update.') do
|
242
230
|
@options[:stop_on_error] = true
|
243
231
|
end
|
244
|
-
opts.on('--poll', 'Check for file changes manually, rather than relying on the OS.',
|
245
|
-
'Only meaningful for --watch.') do
|
246
|
-
@options[:poll] = true
|
247
|
-
end
|
248
232
|
opts.on('-f', '--force', 'Recompile all Sass files, even if the CSS file is newer.',
|
249
233
|
'Only meaningful for --update.') do
|
250
234
|
@options[:force] = true
|
@@ -293,16 +277,8 @@ END
|
|
293
277
|
@options[:for_engine][:cache] = false
|
294
278
|
end
|
295
279
|
|
296
|
-
|
297
|
-
'
|
298
|
-
else
|
299
|
-
'Specify the default encoding for Sass files.'
|
300
|
-
end
|
301
|
-
opts.on('-E encoding', encoding_desc) do |encoding|
|
302
|
-
if ::Sass::Util.ruby1_8?
|
303
|
-
$stderr.puts "Specifying the encoding is not supported in ruby 1.8."
|
304
|
-
exit 1
|
305
|
-
else
|
280
|
+
unless ::Sass::Util.ruby1_8?
|
281
|
+
opts.on('-E encoding', 'Specify the default encoding for Sass files.') do |encoding|
|
306
282
|
Encoding.default_external = encoding
|
307
283
|
end
|
308
284
|
end
|
@@ -326,7 +302,6 @@ END
|
|
326
302
|
return watch_or_update if @options[:watch] || @options[:update]
|
327
303
|
super
|
328
304
|
@options[:for_engine][:filename] = @options[:filename]
|
329
|
-
@options[:for_engine][:css_filename] = @options[:output] if @options[:output].is_a?(String)
|
330
305
|
|
331
306
|
begin
|
332
307
|
input = @options[:input]
|
@@ -346,7 +321,8 @@ END
|
|
346
321
|
|
347
322
|
input.close() if input.is_a?(File)
|
348
323
|
|
349
|
-
|
324
|
+
output.write(engine.render)
|
325
|
+
output.close() if output.is_a? File
|
350
326
|
rescue ::Sass::SyntaxError => e
|
351
327
|
raise e if @options[:trace]
|
352
328
|
raise e.sass_backtrace_str("standard input")
|
@@ -381,7 +357,6 @@ END
|
|
381
357
|
require 'sass/plugin'
|
382
358
|
::Sass::Plugin.options.merge! @options[:for_engine]
|
383
359
|
::Sass::Plugin.options[:unix_newlines] = @options[:unix_newlines]
|
384
|
-
::Sass::Plugin.options[:poll] = @options[:poll]
|
385
360
|
|
386
361
|
if @options[:force]
|
387
362
|
raise "The --force flag may only be used with --update." unless @options[:update]
|
@@ -426,13 +401,6 @@ MSG
|
|
426
401
|
::Sass::Plugin.on_creating_directory {|dirname| puts_action :directory, :green, dirname}
|
427
402
|
::Sass::Plugin.on_deleting_css {|filename| puts_action :delete, :yellow, filename}
|
428
403
|
::Sass::Plugin.on_compilation_error do |error, _, _|
|
429
|
-
if error.is_a?(SystemCallError) && !@options[:stop_on_error]
|
430
|
-
had_error = true
|
431
|
-
puts_action :error, :red, error.message
|
432
|
-
STDOUT.flush
|
433
|
-
next
|
434
|
-
end
|
435
|
-
|
436
404
|
raise error unless error.is_a?(::Sass::SyntaxError) && !@options[:stop_on_error]
|
437
405
|
had_error = true
|
438
406
|
puts_action :error, :red, "#{error.sass_filename} (Line #{error.sass_line}: #{error.message})"
|
@@ -620,6 +588,7 @@ END
|
|
620
588
|
end
|
621
589
|
@options[:output] ||= @options[:input]
|
622
590
|
|
591
|
+
from = @options[:from]
|
623
592
|
if @options[:to] == @options[:from] && !@options[:in_place]
|
624
593
|
fmt = @options[:from]
|
625
594
|
raise "Error: converting from #{fmt} to #{fmt} without --in-place"
|
@@ -650,6 +619,7 @@ END
|
|
650
619
|
end
|
651
620
|
|
652
621
|
input = open_file(f)
|
622
|
+
output = @options[:in_place] ? input : open_file(output, "w")
|
653
623
|
process_file(input, output)
|
654
624
|
end
|
655
625
|
end
|
@@ -693,8 +663,8 @@ END
|
|
693
663
|
end
|
694
664
|
end
|
695
665
|
|
696
|
-
output = input.path if @options[:in_place]
|
697
|
-
|
666
|
+
output = File.open(input.path, 'w') if @options[:in_place]
|
667
|
+
output.write(out)
|
698
668
|
rescue ::Sass::SyntaxError => e
|
699
669
|
raise e if @options[:trace]
|
700
670
|
file = " of #{e.sass_filename}" if e.sass_filename
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'pathname'
|
2
|
-
require 'set'
|
3
2
|
|
4
3
|
module Sass
|
5
4
|
module Importers
|
@@ -15,7 +14,6 @@ module Sass
|
|
15
14
|
# This importer will import files relative to this path.
|
16
15
|
def initialize(root)
|
17
16
|
@root = File.expand_path(root)
|
18
|
-
@same_name_warnings = Set.new
|
19
17
|
end
|
20
18
|
|
21
19
|
# @see Base#find_relative
|
@@ -30,7 +28,7 @@ module Sass
|
|
30
28
|
|
31
29
|
# @see Base#mtime
|
32
30
|
def mtime(name, options)
|
33
|
-
file,
|
31
|
+
file, s = find_real_file(@root, name)
|
34
32
|
File.mtime(file) if file
|
35
33
|
rescue Errno::ENOENT
|
36
34
|
nil
|
@@ -91,14 +89,8 @@ module Sass
|
|
91
89
|
sorted_exts = extensions.sort
|
92
90
|
syntax = extensions[extname]
|
93
91
|
|
94
|
-
if syntax
|
95
|
-
|
96
|
-
else
|
97
|
-
ret = sorted_exts.map {|ext, syn| ["#{dirname}/{_,}#{basename}.#{ext}", syn]}
|
98
|
-
end
|
99
|
-
|
100
|
-
# JRuby chokes when trying to import files from JARs when the path starts with './'.
|
101
|
-
ret.map {|f, s| [f.sub(%r{^\./}, ''), s]}
|
92
|
+
return [["#{dirname}/{_,}#{basename}.#{extensions.invert[syntax]}", syntax]] if syntax
|
93
|
+
sorted_exts.map {|ext, syn| ["#{dirname}/{_,}#{basename}.#{ext}", syn]}
|
102
94
|
end
|
103
95
|
|
104
96
|
def escape_glob_characters(name)
|
@@ -114,48 +106,15 @@ module Sass
|
|
114
106
|
# @param dir [String] The directory relative to which to search.
|
115
107
|
# @param name [String] The filename to search for.
|
116
108
|
# @return [(String, Symbol)] A filename-syntax pair.
|
117
|
-
def find_real_file(dir, name
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
Dir[path].map do |full_path|
|
124
|
-
full_path.gsub!(REDUNDANT_DIRECTORY, File::SEPARATOR)
|
125
|
-
[Pathname.new(full_path).cleanpath.to_s, s]
|
126
|
-
end
|
127
|
-
end
|
128
|
-
found = Sass::Util.flatten(found, 1)
|
129
|
-
return if found.empty?
|
130
|
-
|
131
|
-
if found.size > 1 && !@same_name_warnings.include?(found.first.first)
|
132
|
-
found.each {|(f, _)| @same_name_warnings << f}
|
133
|
-
relative_to = Pathname.new(dir)
|
134
|
-
if options[:_line]
|
135
|
-
# If _line exists, we're here due to an actual import in an
|
136
|
-
# import_node and we want to print a warning for a user writing an
|
137
|
-
# ambiguous import.
|
138
|
-
candidates = found.map {|(f, _)| " " + Pathname.new(f).relative_path_from(relative_to).to_s}.join("\n")
|
139
|
-
Sass::Util.sass_warn <<WARNING
|
140
|
-
WARNING: On line #{options[:_line]}#{" of #{options[:filename]}" if options[:filename]}:
|
141
|
-
It's not clear which file to import for '@import "#{name}"'.
|
142
|
-
Candidates:
|
143
|
-
#{candidates}
|
144
|
-
For now I'll choose #{File.basename found.first.first}.
|
145
|
-
This will be an error in future versions of Sass.
|
146
|
-
WARNING
|
147
|
-
else
|
148
|
-
# Otherwise, we're here via StalenessChecker, and we want to print a
|
149
|
-
# warning for a user running `sass --watch` with two ambiguous files.
|
150
|
-
candidates = found.map {|(f, _)| " " + File.basename(f)}.join("\n")
|
151
|
-
Sass::Util.sass_warn <<WARNING
|
152
|
-
WARNING: In #{File.dirname(name)}:
|
153
|
-
There are multiple files that match the name "#{File.basename(name)}":
|
154
|
-
#{candidates}
|
155
|
-
WARNING
|
109
|
+
def find_real_file(dir, name)
|
110
|
+
for (f,s) in possible_files(remove_root(name))
|
111
|
+
path = (dir == "." || Pathname.new(f).absolute?) ? f : "#{dir}/#{f}"
|
112
|
+
if full_path = Dir[path].first
|
113
|
+
full_path.gsub!(REDUNDANT_DIRECTORY,File::SEPARATOR)
|
114
|
+
return full_path, s
|
156
115
|
end
|
157
116
|
end
|
158
|
-
|
117
|
+
nil
|
159
118
|
end
|
160
119
|
|
161
120
|
# Splits a filename into three parts, a directory part, a basename, and an extension
|
@@ -173,7 +132,7 @@ WARNING
|
|
173
132
|
private
|
174
133
|
|
175
134
|
def _find(dir, name, options)
|
176
|
-
full_filename, syntax =
|
135
|
+
full_filename, syntax = find_real_file(dir, name)
|
177
136
|
return unless full_filename && File.readable?(full_filename)
|
178
137
|
|
179
138
|
options[:syntax] = syntax
|
@@ -181,6 +140,10 @@ WARNING
|
|
181
140
|
options[:importer] = self
|
182
141
|
Sass::Engine.new(File.read(full_filename), options)
|
183
142
|
end
|
143
|
+
|
144
|
+
def join(base, path)
|
145
|
+
Pathname.new(base).join(path).to_s
|
146
|
+
end
|
184
147
|
end
|
185
148
|
end
|
186
149
|
end
|