sass 3.4.25 → 3.5.0
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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/Rakefile +2 -117
- data/VERSION +1 -1
- data/VERSION_DATE +1 -1
- data/VERSION_NAME +1 -1
- data/lib/sass/cache_stores/filesystem.rb +1 -1
- data/lib/sass/css.rb +1 -2
- data/lib/sass/engine.rb +38 -20
- data/lib/sass/environment.rb +26 -5
- data/lib/sass/error.rb +2 -2
- data/lib/sass/exec/base.rb +2 -11
- data/lib/sass/features.rb +1 -0
- data/lib/sass/importers/filesystem.rb +2 -2
- data/lib/sass/plugin/compiler.rb +20 -50
- data/lib/sass/plugin/configuration.rb +2 -2
- data/lib/sass/railtie.rb +1 -1
- data/lib/sass/script/functions.rb +235 -43
- data/lib/sass/script/lexer.rb +13 -2
- data/lib/sass/script/parser.rb +69 -67
- data/lib/sass/script/tree/funcall.rb +35 -30
- data/lib/sass/script/tree/list_literal.rb +23 -8
- data/lib/sass/script/tree/map_literal.rb +2 -2
- data/lib/sass/script/tree/node.rb +0 -8
- data/lib/sass/script/tree/operation.rb +0 -7
- data/lib/sass/script/value/arg_list.rb +1 -1
- data/lib/sass/script/value/base.rb +17 -0
- data/lib/sass/script/value/callable.rb +25 -0
- data/lib/sass/script/value/color.rb +5 -0
- data/lib/sass/script/value/function.rb +19 -0
- data/lib/sass/script/value/helpers.rb +29 -9
- data/lib/sass/script/value/list.rb +35 -14
- data/lib/sass/script/value/map.rb +2 -2
- data/lib/sass/script/value/number.rb +1 -1
- data/lib/sass/script/value.rb +2 -0
- data/lib/sass/scss/parser.rb +99 -40
- data/lib/sass/scss/rx.rb +4 -10
- data/lib/sass/scss/static_parser.rb +5 -24
- data/lib/sass/selector/abstract_sequence.rb +7 -6
- data/lib/sass/selector/comma_sequence.rb +7 -4
- data/lib/sass/selector/pseudo.rb +19 -2
- data/lib/sass/selector/sequence.rb +35 -6
- data/lib/sass/selector/simple.rb +9 -2
- data/lib/sass/selector/simple_sequence.rb +8 -4
- data/lib/sass/selector.rb +4 -0
- data/lib/sass/source/map.rb +2 -2
- data/lib/sass/stack.rb +21 -1
- data/lib/sass/tree/charset_node.rb +1 -1
- data/lib/sass/tree/prop_node.rb +45 -53
- data/lib/sass/tree/rule_node.rb +3 -2
- data/lib/sass/tree/visitors/check_nesting.rb +1 -1
- data/lib/sass/tree/visitors/convert.rb +2 -3
- data/lib/sass/tree/visitors/cssize.rb +4 -15
- data/lib/sass/tree/visitors/deep_copy.rb +1 -1
- data/lib/sass/tree/visitors/extend.rb +2 -8
- data/lib/sass/tree/visitors/perform.rb +21 -9
- data/lib/sass/tree/visitors/set_options.rb +1 -1
- data/lib/sass/tree/visitors/to_css.rb +47 -13
- data/lib/sass/util/multibyte_string_scanner.rb +127 -131
- data/lib/sass/util/normalized_map.rb +1 -8
- data/lib/sass/util.rb +12 -290
- data/lib/sass/version.rb +0 -2
- data/lib/sass.rb +0 -7
- data/test/sass/cache_test.rb +0 -1
- data/test/sass/callbacks_test.rb +0 -1
- data/test/sass/compiler_test.rb +4 -15
- data/test/sass/conversion_test.rb +113 -163
- data/test/sass/css2sass_test.rb +16 -19
- data/test/sass/css_variable_test.rb +176 -71
- data/test/sass/encoding_test.rb +2 -33
- data/test/sass/engine_test.rb +71 -19
- data/test/sass/exec_test.rb +0 -1
- data/test/sass/extend_test.rb +37 -92
- data/test/sass/functions_test.rb +58 -14
- data/test/sass/importer_test.rb +2 -3
- data/test/sass/logger_test.rb +0 -1
- data/test/sass/plugin_test.rb +6 -10
- data/test/sass/results/script.css +1 -1
- data/test/sass/results/units.css +2 -2
- data/test/sass/script_conversion_test.rb +10 -2
- data/test/sass/script_test.rb +22 -24
- data/test/sass/scss/css_test.rb +3 -18
- data/test/sass/scss/rx_test.rb +0 -1
- data/test/sass/scss/scss_test.rb +49 -16
- data/test/sass/source_map_test.rb +13 -16
- data/test/sass/superselector_test.rb +0 -1
- data/test/sass/util/multibyte_string_scanner_test.rb +121 -124
- data/test/sass/util/normalized_map_test.rb +0 -1
- data/test/sass/util/subset_map_test.rb +0 -1
- data/test/sass/util_test.rb +4 -39
- data/test/sass/value_helpers_test.rb +0 -1
- data/test/sass-spec.yml +1 -1
- data/test/test_helper.rb +39 -0
- metadata +19 -44
- data/lib/sass/script/css_variable_warning.rb +0 -52
- data/lib/sass/util/cross_platform_random.rb +0 -19
- data/lib/sass/util/ordered_hash.rb +0 -192
- data/test/sass/results/import_charset_1_8.css +0 -5
- data/test/sass/templates/import_charset_1_8.sass +0 -6
- data/vendor/listen/CHANGELOG.md +0 -1
- data/vendor/listen/CONTRIBUTING.md +0 -38
- data/vendor/listen/Gemfile +0 -20
- data/vendor/listen/Guardfile +0 -8
- data/vendor/listen/LICENSE +0 -20
- data/vendor/listen/README.md +0 -349
- data/vendor/listen/Rakefile +0 -5
- data/vendor/listen/Vagrantfile +0 -96
- data/vendor/listen/lib/listen/adapter.rb +0 -327
- data/vendor/listen/lib/listen/adapters/bsd.rb +0 -75
- data/vendor/listen/lib/listen/adapters/darwin.rb +0 -48
- data/vendor/listen/lib/listen/adapters/linux.rb +0 -81
- data/vendor/listen/lib/listen/adapters/polling.rb +0 -58
- data/vendor/listen/lib/listen/adapters/windows.rb +0 -91
- data/vendor/listen/lib/listen/directory_record.rb +0 -406
- data/vendor/listen/lib/listen/listener.rb +0 -323
- data/vendor/listen/lib/listen/turnstile.rb +0 -32
- data/vendor/listen/lib/listen/version.rb +0 -3
- data/vendor/listen/lib/listen.rb +0 -54
- data/vendor/listen/listen.gemspec +0 -28
- data/vendor/listen/spec/listen/adapter_spec.rb +0 -149
- data/vendor/listen/spec/listen/adapters/bsd_spec.rb +0 -36
- data/vendor/listen/spec/listen/adapters/darwin_spec.rb +0 -37
- data/vendor/listen/spec/listen/adapters/linux_spec.rb +0 -47
- data/vendor/listen/spec/listen/adapters/polling_spec.rb +0 -68
- data/vendor/listen/spec/listen/adapters/windows_spec.rb +0 -30
- data/vendor/listen/spec/listen/directory_record_spec.rb +0 -1250
- data/vendor/listen/spec/listen/listener_spec.rb +0 -258
- data/vendor/listen/spec/listen/turnstile_spec.rb +0 -56
- data/vendor/listen/spec/listen_spec.rb +0 -67
- data/vendor/listen/spec/spec_helper.rb +0 -25
- data/vendor/listen/spec/support/adapter_helper.rb +0 -666
- data/vendor/listen/spec/support/directory_record_helper.rb +0 -57
- data/vendor/listen/spec/support/fixtures_helper.rb +0 -29
- data/vendor/listen/spec/support/listeners_helper.rb +0 -179
- data/vendor/listen/spec/support/platform_helper.rb +0 -15
data/lib/sass/util.rb
CHANGED
|
@@ -35,17 +35,6 @@ module Sass
|
|
|
35
35
|
File.join(Sass::ROOT_DIR, file)
|
|
36
36
|
end
|
|
37
37
|
|
|
38
|
-
# Converts an array of `[key, value]` pairs to a hash.
|
|
39
|
-
#
|
|
40
|
-
# @example
|
|
41
|
-
# to_hash([[:foo, "bar"], [:baz, "bang"]])
|
|
42
|
-
# #=> {:foo => "bar", :baz => "bang"}
|
|
43
|
-
# @param arr [Array<(Object, Object)>] An array of pairs
|
|
44
|
-
# @return [Hash] A hash
|
|
45
|
-
def to_hash(arr)
|
|
46
|
-
ordered_hash(*arr.compact)
|
|
47
|
-
end
|
|
48
|
-
|
|
49
38
|
# Maps the keys in a hash according to a block.
|
|
50
39
|
#
|
|
51
40
|
# @example
|
|
@@ -301,44 +290,6 @@ module Sass
|
|
|
301
290
|
lcs_backtrace(lcs_table(x, y, &block), x, y, x.size - 1, y.size - 1, &block)
|
|
302
291
|
end
|
|
303
292
|
|
|
304
|
-
# Converts a Hash to an Array. This is usually identical to `Hash#to_a`,
|
|
305
|
-
# with the following exceptions:
|
|
306
|
-
#
|
|
307
|
-
# * In Ruby 1.8, `Hash#to_a` is not deterministically ordered, but this is.
|
|
308
|
-
# * In Ruby 1.9 when running tests, this is ordered in the same way it would
|
|
309
|
-
# be under Ruby 1.8 (sorted key order rather than insertion order).
|
|
310
|
-
#
|
|
311
|
-
# @param hash [Hash]
|
|
312
|
-
# @return [Array]
|
|
313
|
-
def hash_to_a(hash)
|
|
314
|
-
return hash.to_a unless ruby1_8? || defined?(Test::Unit)
|
|
315
|
-
hash.sort_by {|k, _v| k}
|
|
316
|
-
end
|
|
317
|
-
|
|
318
|
-
# Performs the equivalent of `enum.group_by.to_a`, but with a guaranteed
|
|
319
|
-
# order. Unlike {Util#hash_to_a}, the resulting order isn't sorted key order;
|
|
320
|
-
# instead, it's the same order as `#group_by` has under Ruby 1.9 (key
|
|
321
|
-
# appearance order).
|
|
322
|
-
#
|
|
323
|
-
# @param enum [Enumerable]
|
|
324
|
-
# @return [Array<[Object, Array]>] An array of pairs.
|
|
325
|
-
def group_by_to_a(enum)
|
|
326
|
-
return enum.group_by {|e| yield(e)}.to_a unless ruby1_8?
|
|
327
|
-
order = {}
|
|
328
|
-
arr = []
|
|
329
|
-
groups = enum.group_by do |e|
|
|
330
|
-
res = yield(e)
|
|
331
|
-
unless order.include?(res)
|
|
332
|
-
order[res] = order.size
|
|
333
|
-
end
|
|
334
|
-
res
|
|
335
|
-
end
|
|
336
|
-
groups.each do |key, vals|
|
|
337
|
-
arr[order[key]] = [key, vals]
|
|
338
|
-
end
|
|
339
|
-
arr
|
|
340
|
-
end
|
|
341
|
-
|
|
342
293
|
# Like `String.upcase`, but only ever upcases ASCII letters.
|
|
343
294
|
def upcase(string)
|
|
344
295
|
return string.upcase unless ruby2_4?
|
|
@@ -524,8 +475,7 @@ module Sass
|
|
|
524
475
|
#
|
|
525
476
|
# @param msg [String]
|
|
526
477
|
def sass_warn(msg)
|
|
527
|
-
msg
|
|
528
|
-
Sass.logger.warn(msg)
|
|
478
|
+
Sass.logger.warn("#{msg}\n")
|
|
529
479
|
end
|
|
530
480
|
|
|
531
481
|
## Cross Rails Version Compatibility
|
|
@@ -578,24 +528,6 @@ module Sass
|
|
|
578
528
|
version_geq(ActionPack::VERSION::STRING, version)
|
|
579
529
|
end
|
|
580
530
|
|
|
581
|
-
# Returns whether this environment is using Listen
|
|
582
|
-
# version 2.0.0 or greater.
|
|
583
|
-
#
|
|
584
|
-
# @return [Boolean]
|
|
585
|
-
def listen_geq_2?
|
|
586
|
-
return @listen_geq_2 if defined?(@listen_geq_2)
|
|
587
|
-
@listen_geq_2 =
|
|
588
|
-
begin
|
|
589
|
-
# Make sure we're loading listen/version from the same place that
|
|
590
|
-
# we're loading listen itself.
|
|
591
|
-
load_listen!
|
|
592
|
-
require 'listen/version'
|
|
593
|
-
version_geq(::Listen::VERSION, '2.0.0')
|
|
594
|
-
rescue LoadError
|
|
595
|
-
false
|
|
596
|
-
end
|
|
597
|
-
end
|
|
598
|
-
|
|
599
531
|
# Returns an ActionView::Template* class.
|
|
600
532
|
# In pre-3.0 versions of Rails, most of these classes
|
|
601
533
|
# were of the form `ActionView::TemplateFoo`,
|
|
@@ -739,7 +671,7 @@ module Sass
|
|
|
739
671
|
def file_uri_from_path(path)
|
|
740
672
|
path = path.to_s if path.is_a?(Pathname)
|
|
741
673
|
path = path.tr('\\', '/') if windows?
|
|
742
|
-
path =
|
|
674
|
+
path = URI::DEFAULT_PARSER.escape(path)
|
|
743
675
|
return path.start_with?('/') ? "file://" + path : path unless windows?
|
|
744
676
|
return "file:///" + path.tr("\\", "/") if path =~ %r{^[a-zA-Z]:[/\\]}
|
|
745
677
|
return "file:" + path.tr("\\", "/") if path =~ %r{\\\\[^\\]+\\[^\\/]+}
|
|
@@ -774,37 +706,13 @@ module Sass
|
|
|
774
706
|
val || []
|
|
775
707
|
end
|
|
776
708
|
|
|
777
|
-
|
|
709
|
+
CHARSET_REGEXP = /\A@charset "([^"]+)"/
|
|
710
|
+
bom = "\uFEFF"
|
|
711
|
+
UTF_8_BOM = bom.encode("UTF-8").force_encoding('BINARY')
|
|
712
|
+
UTF_16BE_BOM = bom.encode("UTF-16BE").force_encoding('BINARY')
|
|
713
|
+
UTF_16LE_BOM = bom.encode("UTF-16LE").force_encoding('BINARY')
|
|
778
714
|
|
|
779
|
-
|
|
780
|
-
#
|
|
781
|
-
# @return [Boolean]
|
|
782
|
-
def ruby1?
|
|
783
|
-
return @ruby1 if defined?(@ruby1)
|
|
784
|
-
@ruby1 = RUBY_VERSION_COMPONENTS[0] <= 1
|
|
785
|
-
end
|
|
786
|
-
|
|
787
|
-
# Whether or not this is running under Ruby 1.8 or lower.
|
|
788
|
-
#
|
|
789
|
-
# Note that IronRuby counts as Ruby 1.8,
|
|
790
|
-
# because it doesn't support the Ruby 1.9 encoding API.
|
|
791
|
-
#
|
|
792
|
-
# @return [Boolean]
|
|
793
|
-
def ruby1_8?
|
|
794
|
-
# IronRuby says its version is 1.9, but doesn't support any of the encoding APIs.
|
|
795
|
-
# We have to fall back to 1.8 behavior.
|
|
796
|
-
return @ruby1_8 if defined?(@ruby1_8)
|
|
797
|
-
@ruby1_8 = ironruby? ||
|
|
798
|
-
(RUBY_VERSION_COMPONENTS[0] == 1 && RUBY_VERSION_COMPONENTS[1] < 9)
|
|
799
|
-
end
|
|
800
|
-
|
|
801
|
-
# Whether or not this is running under Ruby 1.9.2 exactly.
|
|
802
|
-
#
|
|
803
|
-
# @return [Boolean]
|
|
804
|
-
def ruby1_9_2?
|
|
805
|
-
return @ruby1_9_2 if defined?(@ruby1_9_2)
|
|
806
|
-
@ruby1_9_2 = RUBY_VERSION_COMPONENTS == [1, 9, 2]
|
|
807
|
-
end
|
|
715
|
+
## Cross-Ruby-Version Compatibility
|
|
808
716
|
|
|
809
717
|
# Whether or not this is running under Ruby 2.4 or higher.
|
|
810
718
|
#
|
|
@@ -819,58 +727,6 @@ module Sass
|
|
|
819
727
|
end
|
|
820
728
|
end
|
|
821
729
|
|
|
822
|
-
# Wehter or not this is running under JRuby 1.6 or lower.
|
|
823
|
-
def jruby1_6?
|
|
824
|
-
return @jruby1_6 if defined?(@jruby1_6)
|
|
825
|
-
@jruby1_6 = jruby? && jruby_version[0] == 1 && jruby_version[1] < 7
|
|
826
|
-
end
|
|
827
|
-
|
|
828
|
-
# Whether or not this is running under MacRuby.
|
|
829
|
-
#
|
|
830
|
-
# @return [Boolean]
|
|
831
|
-
def macruby?
|
|
832
|
-
return @macruby if defined?(@macruby)
|
|
833
|
-
@macruby = RUBY_ENGINE == 'macruby'
|
|
834
|
-
end
|
|
835
|
-
|
|
836
|
-
require 'sass/util/ordered_hash' if ruby1_8?
|
|
837
|
-
|
|
838
|
-
# Converts a hash or a list of pairs into an order-preserving hash.
|
|
839
|
-
#
|
|
840
|
-
# On Ruby 1.8.7, this uses the orderedhash gem to simulate an
|
|
841
|
-
# order-preserving hash. On Ruby 1.9 and up, it just uses the native Hash
|
|
842
|
-
# class, since that preserves the order itself.
|
|
843
|
-
#
|
|
844
|
-
# @overload ordered_hash(hash)
|
|
845
|
-
# @param hash [Hash] a normal hash to convert to an ordered hash
|
|
846
|
-
# @return [Hash]
|
|
847
|
-
# @overload ordered_hash(*pairs)
|
|
848
|
-
# @example
|
|
849
|
-
# ordered_hash([:foo, "bar"], [:baz, "bang"])
|
|
850
|
-
# #=> {:foo => "bar", :baz => "bang"}
|
|
851
|
-
# ordered_hash #=> {}
|
|
852
|
-
# @param pairs [Array<(Object, Object)>] the list of key/value pairs for
|
|
853
|
-
# the hash.
|
|
854
|
-
# @return [Hash]
|
|
855
|
-
def ordered_hash(*pairs_or_hash)
|
|
856
|
-
if pairs_or_hash.length == 1 && pairs_or_hash.first.is_a?(Hash)
|
|
857
|
-
hash = pairs_or_hash.first
|
|
858
|
-
return hash unless ruby1_8?
|
|
859
|
-
return OrderedHash.new.merge hash
|
|
860
|
-
end
|
|
861
|
-
|
|
862
|
-
return Hash[pairs_or_hash] unless ruby1_8?
|
|
863
|
-
(pairs_or_hash.is_a?(NormalizedMap) ? NormalizedMap : OrderedHash)[*pairs_or_hash.flatten(1)]
|
|
864
|
-
end
|
|
865
|
-
|
|
866
|
-
unless ruby1_8?
|
|
867
|
-
CHARSET_REGEXP = /\A@charset "([^"]+)"/
|
|
868
|
-
bom = "\uFEFF"
|
|
869
|
-
UTF_8_BOM = bom.encode("UTF-8").force_encoding('BINARY')
|
|
870
|
-
UTF_16BE_BOM = bom.encode("UTF-16BE").force_encoding('BINARY')
|
|
871
|
-
UTF_16LE_BOM = bom.encode("UTF-16LE").force_encoding('BINARY')
|
|
872
|
-
end
|
|
873
|
-
|
|
874
730
|
# Like {\#check\_encoding}, but also checks for a `@charset` declaration
|
|
875
731
|
# at the beginning of the file and uses that encoding if it exists.
|
|
876
732
|
#
|
|
@@ -878,7 +734,7 @@ module Sass
|
|
|
878
734
|
#
|
|
879
735
|
# @param str [String] The string of which to check the encoding
|
|
880
736
|
# @return [(String, Encoding)] The original string encoded as UTF-8,
|
|
881
|
-
# and the source encoding of the string
|
|
737
|
+
# and the source encoding of the string
|
|
882
738
|
# @raise [Encoding::UndefinedConversionError] if the source encoding
|
|
883
739
|
# cannot be converted to UTF-8
|
|
884
740
|
# @raise [ArgumentError] if the document uses an unknown encoding with `@charset`
|
|
@@ -886,15 +742,6 @@ module Sass
|
|
|
886
742
|
# doesn't match its contents, or it doesn't declare an encoding and its
|
|
887
743
|
# contents are invalid in the native encoding.
|
|
888
744
|
def check_sass_encoding(str)
|
|
889
|
-
# On Ruby 1.8 we can't do anything complicated with encodings.
|
|
890
|
-
# Instead, we just strip out a UTF-8 BOM if it exists and
|
|
891
|
-
# sanitize according to Section 3.3 of CSS Syntax Level 3. We
|
|
892
|
-
# don't sanitize null characters since they might be components
|
|
893
|
-
# of other characters.
|
|
894
|
-
if ruby1_8?
|
|
895
|
-
return str.gsub(/\A\xEF\xBB\xBF/, '').gsub(/\r\n?|\f/, "\n"), nil
|
|
896
|
-
end
|
|
897
|
-
|
|
898
745
|
# Determine the fallback encoding following section 3.2 of CSS Syntax Level 3 and Encodings:
|
|
899
746
|
# http://www.w3.org/TR/2013/WD-css-syntax-3-20130919/#determine-the-fallback-encoding
|
|
900
747
|
# http://encoding.spec.whatwg.org/#decode
|
|
@@ -910,14 +757,9 @@ module Sass
|
|
|
910
757
|
str = binary.force_encoding('UTF-16LE')
|
|
911
758
|
elsif binary =~ CHARSET_REGEXP
|
|
912
759
|
charset = $1.force_encoding('US-ASCII')
|
|
913
|
-
|
|
914
|
-
if
|
|
760
|
+
encoding = Encoding.find(charset)
|
|
761
|
+
if encoding.name == 'UTF-16' || encoding.name == 'UTF-16BE'
|
|
915
762
|
encoding = Encoding.find('UTF-8')
|
|
916
|
-
else
|
|
917
|
-
encoding = Encoding.find(charset)
|
|
918
|
-
if encoding.name == 'UTF-16' || encoding.name == 'UTF-16BE'
|
|
919
|
-
encoding = Encoding.find('UTF-8')
|
|
920
|
-
end
|
|
921
763
|
end
|
|
922
764
|
str = binary.force_encoding(encoding)
|
|
923
765
|
elsif str.encoding.name == "ASCII-8BIT"
|
|
@@ -937,50 +779,6 @@ module Sass
|
|
|
937
779
|
end
|
|
938
780
|
end
|
|
939
781
|
|
|
940
|
-
# Checks to see if a class has a given method.
|
|
941
|
-
# For example:
|
|
942
|
-
#
|
|
943
|
-
# Sass::Util.has?(:public_instance_method, String, :gsub) #=> true
|
|
944
|
-
#
|
|
945
|
-
# Method collections like `Class#instance_methods`
|
|
946
|
-
# return strings in Ruby 1.8 and symbols in Ruby 1.9 and on,
|
|
947
|
-
# so this handles checking for them in a compatible way.
|
|
948
|
-
#
|
|
949
|
-
# @param attr [#to_s] The (singular) name of the method-collection method
|
|
950
|
-
# (e.g. `:instance_methods`, `:private_methods`)
|
|
951
|
-
# @param klass [Module] The class to check the methods of which to check
|
|
952
|
-
# @param method [String, Symbol] The name of the method do check for
|
|
953
|
-
# @return [Boolean] Whether or not the given collection has the given method
|
|
954
|
-
def has?(attr, klass, method)
|
|
955
|
-
klass.send("#{attr}s").include?(ruby1_8? ? method.to_s : method.to_sym)
|
|
956
|
-
end
|
|
957
|
-
|
|
958
|
-
# A version of `Enumerable#enum_with_index` that works in Ruby 1.8 and 1.9.
|
|
959
|
-
#
|
|
960
|
-
# @param enum [Enumerable] The enumerable to get the enumerator for
|
|
961
|
-
# @return [Enumerator] The with-index enumerator
|
|
962
|
-
def enum_with_index(enum)
|
|
963
|
-
ruby1_8? ? enum.enum_with_index : enum.each_with_index
|
|
964
|
-
end
|
|
965
|
-
|
|
966
|
-
# A version of `Enumerable#enum_cons` that works in Ruby 1.8 and 1.9.
|
|
967
|
-
#
|
|
968
|
-
# @param enum [Enumerable] The enumerable to get the enumerator for
|
|
969
|
-
# @param n [Integer] The size of each cons
|
|
970
|
-
# @return [Enumerator] The consed enumerator
|
|
971
|
-
def enum_cons(enum, n)
|
|
972
|
-
ruby1_8? ? enum.enum_cons(n) : enum.each_cons(n)
|
|
973
|
-
end
|
|
974
|
-
|
|
975
|
-
# A version of `Enumerable#enum_slice` that works in Ruby 1.8 and 1.9.
|
|
976
|
-
#
|
|
977
|
-
# @param enum [Enumerable] The enumerable to get the enumerator for
|
|
978
|
-
# @param n [Integer] The size of each slice
|
|
979
|
-
# @return [Enumerator] The consed enumerator
|
|
980
|
-
def enum_slice(enum, n)
|
|
981
|
-
ruby1_8? ? enum.enum_slice(n) : enum.each_slice(n)
|
|
982
|
-
end
|
|
983
|
-
|
|
984
782
|
# Destructively removes all elements from an array that match a block, and
|
|
985
783
|
# returns the removed elements.
|
|
986
784
|
#
|
|
@@ -999,14 +797,6 @@ module Sass
|
|
|
999
797
|
out
|
|
1000
798
|
end
|
|
1001
799
|
|
|
1002
|
-
# Returns the ASCII code of the given character.
|
|
1003
|
-
#
|
|
1004
|
-
# @param c [String] All characters but the first are ignored.
|
|
1005
|
-
# @return [Integer] The ASCII code of `c`.
|
|
1006
|
-
def ord(c)
|
|
1007
|
-
ruby1_8? ? c[0] : c.ord
|
|
1008
|
-
end
|
|
1009
|
-
|
|
1010
800
|
# Flattens the first level of nested arrays in `arrs`. Unlike
|
|
1011
801
|
# `Array#flatten`, this orders the result by taking the first
|
|
1012
802
|
# values from each array in order, then the second, and so on.
|
|
@@ -1156,7 +946,7 @@ module Sass
|
|
|
1156
946
|
BASE64_DIGITS = ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a + ['+', '/']
|
|
1157
947
|
BASE64_DIGIT_MAP = begin
|
|
1158
948
|
map = {}
|
|
1159
|
-
|
|
949
|
+
BASE64_DIGITS.each_with_index.map do |digit, i|
|
|
1160
950
|
map[digit] = i
|
|
1161
951
|
end
|
|
1162
952
|
map
|
|
@@ -1185,35 +975,6 @@ module Sass
|
|
|
1185
975
|
result
|
|
1186
976
|
end
|
|
1187
977
|
|
|
1188
|
-
# This is a hack around the fact that you can't instantiate a URI parser on
|
|
1189
|
-
# 1.8, so we have to have this hacky stuff to work around it. When 1.8
|
|
1190
|
-
# support is dropped, we can remove this method.
|
|
1191
|
-
#
|
|
1192
|
-
# @private
|
|
1193
|
-
URI_ESCAPE = URI.const_defined?("DEFAULT_PARSER") ? URI::DEFAULT_PARSER : URI
|
|
1194
|
-
|
|
1195
|
-
# URI-escape `string`.
|
|
1196
|
-
#
|
|
1197
|
-
# @param string [String]
|
|
1198
|
-
# @return [String]
|
|
1199
|
-
def escape_uri(string)
|
|
1200
|
-
URI_ESCAPE.escape string
|
|
1201
|
-
end
|
|
1202
|
-
|
|
1203
|
-
# A cross-platform implementation of `File.absolute_path`.
|
|
1204
|
-
#
|
|
1205
|
-
# @param path [String]
|
|
1206
|
-
# @param dir_string [String] The directory to consider [path] relative to.
|
|
1207
|
-
# @return [String] The absolute version of `path`.
|
|
1208
|
-
def absolute_path(path, dir_string = nil)
|
|
1209
|
-
# Ruby 1.8 doesn't support File.absolute_path.
|
|
1210
|
-
return File.absolute_path(path, dir_string) unless ruby1_8?
|
|
1211
|
-
|
|
1212
|
-
# File.expand_path expands "~", which we don't want.
|
|
1213
|
-
return File.expand_path(path, dir_string) unless path[0] == ?~
|
|
1214
|
-
File.expand_path(File.join(".", path), dir_string)
|
|
1215
|
-
end
|
|
1216
|
-
|
|
1217
978
|
## Static Method Stuff
|
|
1218
979
|
|
|
1219
980
|
# The context in which the ERB for \{#def\_static\_method} will be run.
|
|
@@ -1271,44 +1032,6 @@ module Sass
|
|
|
1271
1032
|
tmpfile.unlink if tmpfile
|
|
1272
1033
|
end
|
|
1273
1034
|
|
|
1274
|
-
def load_listen!
|
|
1275
|
-
if defined?(gem)
|
|
1276
|
-
begin
|
|
1277
|
-
gem 'listen', '>= 1.1.0', '< 3.0.0'
|
|
1278
|
-
require 'listen'
|
|
1279
|
-
rescue Gem::LoadError
|
|
1280
|
-
dir = scope("vendor/listen/lib")
|
|
1281
|
-
$LOAD_PATH.unshift dir
|
|
1282
|
-
begin
|
|
1283
|
-
require 'listen'
|
|
1284
|
-
rescue LoadError => e
|
|
1285
|
-
if version_geq(RUBY_VERSION, "1.9.3")
|
|
1286
|
-
version_constraint = "~> 3.0"
|
|
1287
|
-
else
|
|
1288
|
-
version_constraint = "~> 1.1"
|
|
1289
|
-
end
|
|
1290
|
-
e.message << "\n" <<
|
|
1291
|
-
"Run \"gem install listen --version '#{version_constraint}'\" to get it."
|
|
1292
|
-
raise e
|
|
1293
|
-
end
|
|
1294
|
-
end
|
|
1295
|
-
else
|
|
1296
|
-
begin
|
|
1297
|
-
require 'listen'
|
|
1298
|
-
rescue LoadError => e
|
|
1299
|
-
dir = scope("vendor/listen/lib")
|
|
1300
|
-
if $LOAD_PATH.include?(dir)
|
|
1301
|
-
raise e unless File.exist?(scope(".git"))
|
|
1302
|
-
e.message << "\n" <<
|
|
1303
|
-
'Run "git submodule update --init" to get the bundled version.'
|
|
1304
|
-
else
|
|
1305
|
-
$LOAD_PATH.unshift dir
|
|
1306
|
-
retry
|
|
1307
|
-
end
|
|
1308
|
-
end
|
|
1309
|
-
end
|
|
1310
|
-
end
|
|
1311
|
-
|
|
1312
1035
|
private
|
|
1313
1036
|
|
|
1314
1037
|
def find_encoding_error(str)
|
|
@@ -1372,4 +1095,3 @@ end
|
|
|
1372
1095
|
|
|
1373
1096
|
require 'sass/util/multibyte_string_scanner'
|
|
1374
1097
|
require 'sass/util/normalized_map'
|
|
1375
|
-
require 'sass/util/cross_platform_random'
|
data/lib/sass/version.rb
CHANGED
|
@@ -43,7 +43,6 @@ module Sass
|
|
|
43
43
|
#
|
|
44
44
|
# @return [{Symbol => String/Integer}] The version hash
|
|
45
45
|
# @comment
|
|
46
|
-
# rubocop:disable ClassVars
|
|
47
46
|
def version
|
|
48
47
|
return @@version if defined?(@@version)
|
|
49
48
|
|
|
@@ -80,7 +79,6 @@ module Sass
|
|
|
80
79
|
@@version[:string] << " (#{name})"
|
|
81
80
|
@@version
|
|
82
81
|
end
|
|
83
|
-
# rubocop:enable ClassVars
|
|
84
82
|
|
|
85
83
|
private
|
|
86
84
|
|
data/lib/sass.rb
CHANGED
|
@@ -100,10 +100,3 @@ require 'sass/engine'
|
|
|
100
100
|
require 'sass/plugin' if defined?(Merb::Plugins)
|
|
101
101
|
require 'sass/railtie'
|
|
102
102
|
require 'sass/features'
|
|
103
|
-
|
|
104
|
-
if Sass::Util.ruby1?
|
|
105
|
-
Sass::Util.sass_warn(
|
|
106
|
-
"DEPRECATION WARNING:\n" +
|
|
107
|
-
"Sass 3.5 will no longer support Ruby #{RUBY_VERSION}.\n" +
|
|
108
|
-
"Please upgrade to Ruby 2.0.0 or greater as soon as possible.\n")
|
|
109
|
-
end
|
data/test/sass/cache_test.rb
CHANGED
data/test/sass/callbacks_test.rb
CHANGED
data/test/sass/compiler_test.rb
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
1
|
require 'minitest/autorun'
|
|
3
2
|
require File.dirname(__FILE__) + '/../test_helper'
|
|
4
3
|
require 'sass/plugin'
|
|
@@ -40,12 +39,10 @@ class CompilerTest < MiniTest::Test
|
|
|
40
39
|
@run_during_start = run_during_start
|
|
41
40
|
end
|
|
42
41
|
|
|
43
|
-
# used for Listen < 2.0
|
|
44
42
|
def start!
|
|
45
43
|
@run_during_start.call(self) if @run_during_start
|
|
46
44
|
end
|
|
47
45
|
|
|
48
|
-
# used for Listen >= 2.0
|
|
49
46
|
def start
|
|
50
47
|
parent = Thread.current
|
|
51
48
|
@thread = Thread.new do
|
|
@@ -86,18 +83,10 @@ class CompilerTest < MiniTest::Test
|
|
|
86
83
|
|
|
87
84
|
private
|
|
88
85
|
def create_listener(*args, &on_filesystem_event)
|
|
89
|
-
if
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
@fake_listener.on_start!(&run_during_start)
|
|
94
|
-
@fake_listener
|
|
95
|
-
end
|
|
96
|
-
else
|
|
97
|
-
@fake_listener = FakeListener.new(*args, &on_filesystem_event)
|
|
98
|
-
@fake_listener.on_start!(&run_during_start)
|
|
99
|
-
@fake_listener
|
|
100
|
-
end
|
|
86
|
+
args.pop if args.last.is_a?(Hash)
|
|
87
|
+
@fake_listener = FakeListener.new(*args, &on_filesystem_event)
|
|
88
|
+
@fake_listener.on_start!(&run_during_start)
|
|
89
|
+
@fake_listener
|
|
101
90
|
end
|
|
102
91
|
end
|
|
103
92
|
|