sass 3.1.19 → 3.1.20
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/VERSION +1 -1
- data/lib/sass/script/functions.rb +34 -28
- data/lib/sass/scss/parser.rb +1 -1
- data/lib/sass/scss/rx.rb +2 -0
- data/lib/sass/util.rb +10 -3
- data/test/sass/functions_test.rb +14 -0
- data/test/sass/scss/css_test.rb +4 -0
- metadata +4 -4
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            3.1. | 
| 1 | 
            +
            3.1.20
         | 
| @@ -135,6 +135,9 @@ module Sass::Script | |
| 135 135 | 
             
              # \{#join join($list1, $list2, \[$separator\])}
         | 
| 136 136 | 
             
              # : Joins together two lists into one.
         | 
| 137 137 | 
             
              #
         | 
| 138 | 
            +
              # \{#append append($list1, $val, \[$separator\])}
         | 
| 139 | 
            +
              # : Appends a single value onto the end of a list.
         | 
| 140 | 
            +
              #
         | 
| 138 141 | 
             
              # ## Introspection Functions
         | 
| 139 142 | 
             
              #
         | 
| 140 143 | 
             
              # \{#type_of type-of($value)}
         | 
| @@ -573,7 +576,10 @@ module Sass::Script | |
| 573 576 | 
             
                    return Sass::Script::String.new("alpha(#{args.map {|a| a.to_s}.join(", ")})")
         | 
| 574 577 | 
             
                  end
         | 
| 575 578 |  | 
| 576 | 
            -
                   | 
| 579 | 
            +
                  raise ArgumentError.new("wrong number of arguments (#{args.size} for 1)") if args.size != 1
         | 
| 580 | 
            +
             | 
| 581 | 
            +
                  assert_type args.first, :Color
         | 
| 582 | 
            +
                  Sass::Script::Number.new(args.first.alpha)
         | 
| 577 583 | 
             
                end
         | 
| 578 584 | 
             
                declare :alpha, [:color]
         | 
| 579 585 |  | 
| @@ -586,6 +592,7 @@ module Sass::Script | |
| 586 592 | 
             
                # @see #transparentize
         | 
| 587 593 | 
             
                # @raise [ArgumentError] If `color` isn't a color
         | 
| 588 594 | 
             
                def opacity(color)
         | 
| 595 | 
            +
                  return Sass::Script::String.new("opacity(#{color})") if color.is_a?(Sass::Script::Number)
         | 
| 589 596 | 
             
                  assert_type color, :Color
         | 
| 590 597 | 
             
                  Sass::Script::Number.new(color.alpha)
         | 
| 591 598 | 
             
                end
         | 
| @@ -676,16 +683,21 @@ module Sass::Script | |
| 676 683 | 
             
                # @example
         | 
| 677 684 | 
             
                #   saturate(hsl(120, 30%, 90%), 20%) => hsl(120, 50%, 90%)
         | 
| 678 685 | 
             
                #   saturate(#855, 20%) => #9e3f3f
         | 
| 679 | 
            -
                # @ | 
| 680 | 
            -
                # | 
| 681 | 
            -
                # | 
| 682 | 
            -
                # | 
| 683 | 
            -
                # | 
| 684 | 
            -
                #    | 
| 685 | 
            -
                 | 
| 686 | 
            +
                # @overload saturate(color, amount)
         | 
| 687 | 
            +
                #   @param color [Color]
         | 
| 688 | 
            +
                #   @param amount [Number]
         | 
| 689 | 
            +
                #   @return [Color]
         | 
| 690 | 
            +
                #   @see #desaturate
         | 
| 691 | 
            +
                #   @raise [ArgumentError] If `color` isn't a color,
         | 
| 692 | 
            +
                #     or `number` isn't a number between 0% and 100%
         | 
| 693 | 
            +
                def saturate(color, amount = nil)
         | 
| 694 | 
            +
                  # Support the filter effects definition of saturate.
         | 
| 695 | 
            +
                  # https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html
         | 
| 696 | 
            +
                  return Sass::Script::String.new("saturate(#{color})") if amount.nil?
         | 
| 686 697 | 
             
                  _adjust(color, amount, :saturation, 0..100, :+, "%")
         | 
| 687 698 | 
             
                end
         | 
| 688 699 | 
             
                declare :saturate, [:color, :amount]
         | 
| 700 | 
            +
                declare :saturate, [:amount]
         | 
| 689 701 |  | 
| 690 702 | 
             
                # Makes a color less saturated.
         | 
| 691 703 | 
             
                # Takes a color and an amount between 0% and 100%,
         | 
| @@ -969,21 +981,13 @@ module Sass::Script | |
| 969 981 | 
             
                declare :mix, [:color_1, :color_2]
         | 
| 970 982 | 
             
                declare :mix, [:color_1, :color_2, :weight]
         | 
| 971 983 |  | 
| 972 | 
            -
                #  | 
| 973 | 
            -
                # | 
| 974 | 
            -
                #   This is identical to `desaturate(color, 100%)`.
         | 
| 975 | 
            -
                #
         | 
| 976 | 
            -
                #   @param color [Color]
         | 
| 977 | 
            -
                #   @return [Color]
         | 
| 978 | 
            -
                #   @raise [ArgumentError] if `color` isn't a color
         | 
| 979 | 
            -
                #   @see #desaturate
         | 
| 980 | 
            -
                # @overload grayscale(number)
         | 
| 981 | 
            -
                #   Returns an unquoted string `grayscale(number)`, as though the function
         | 
| 982 | 
            -
                #   were not defined. This is for the `grayscale` function used in
         | 
| 983 | 
            -
                #   `-webkit-filter`.
         | 
| 984 | 
            +
                # Converts a color to grayscale.
         | 
| 985 | 
            +
                # This is identical to `desaturate(color, 100%)`.
         | 
| 984 986 | 
             
                #
         | 
| 985 | 
            -
                # | 
| 986 | 
            -
                # | 
| 987 | 
            +
                # @param color [Color]
         | 
| 988 | 
            +
                # @return [Color]
         | 
| 989 | 
            +
                # @raise [ArgumentError] if `color` isn't a color
         | 
| 990 | 
            +
                # @see #desaturate
         | 
| 987 991 | 
             
                def grayscale(color)
         | 
| 988 992 | 
             
                  return Sass::Script::String.new("grayscale(#{color})") if color.is_a?(Sass::Script::Number)
         | 
| 989 993 | 
             
                  desaturate color, Number.new(100)
         | 
| @@ -1009,6 +1013,8 @@ module Sass::Script | |
| 1009 1013 | 
             
                # @return [Color]
         | 
| 1010 1014 | 
             
                # @raise [ArgumentError] if `color` isn't a color
         | 
| 1011 1015 | 
             
                def invert(color)
         | 
| 1016 | 
            +
                  return Sass::Script::String.new("invert(#{color})") if color.is_a?(Sass::Script::Number)
         | 
| 1017 | 
            +
             | 
| 1012 1018 | 
             
                  assert_type color, :Color
         | 
| 1013 1019 | 
             
                  color.with(
         | 
| 1014 1020 | 
             
                    :red => (255 - color.red),
         | 
| @@ -1271,14 +1277,14 @@ module Sass::Script | |
| 1271 1277 | 
             
                #   append(10px 20px, 30px) => 10px 20px 30px
         | 
| 1272 1278 | 
             
                #   append((blue, red), green) => blue, red, green
         | 
| 1273 1279 | 
             
                #   append(10px 20px, 30px 40px) => 10px 20px (30px 40px)
         | 
| 1274 | 
            -
                #    | 
| 1275 | 
            -
                #    | 
| 1276 | 
            -
                # @overload  | 
| 1277 | 
            -
                #   @param  | 
| 1278 | 
            -
                #   @param  | 
| 1280 | 
            +
                #   append(10px, 20px, comma) => 10px, 20px
         | 
| 1281 | 
            +
                #   append((blue, red), green, space) => blue red green
         | 
| 1282 | 
            +
                # @overload append(list, val, separator: auto)
         | 
| 1283 | 
            +
                #   @param list [Literal] The list to add the value to
         | 
| 1284 | 
            +
                #   @param val [Literal] The value to add to the end of the list
         | 
| 1279 1285 | 
             
                #   @param separator [String] How the list separator (comma or space) should be determined.
         | 
| 1280 1286 | 
             
                #     If this is `comma` or `space`, that is always the separator;
         | 
| 1281 | 
            -
                #     if this is `auto` (the default), the separator is  | 
| 1287 | 
            +
                #     if this is `auto` (the default), the separator is the same as that used by the list.
         | 
| 1282 1288 | 
             
                def append(list, val, separator = Sass::Script::String.new("auto"))
         | 
| 1283 1289 | 
             
                  assert_type separator, :String
         | 
| 1284 1290 | 
             
                  unless %w[auto space comma].include?(separator.value)
         | 
    
        data/lib/sass/scss/parser.rb
    CHANGED
    
    
    
        data/lib/sass/scss/rx.rb
    CHANGED
    
    
    
        data/lib/sass/util.rb
    CHANGED
    
    | @@ -439,9 +439,9 @@ module Sass | |
| 439 439 | 
             
                # Like `Dir.glob`, but works with backslash-separated paths on Windows.
         | 
| 440 440 | 
             
                #
         | 
| 441 441 | 
             
                # @param path [String]
         | 
| 442 | 
            -
                def glob(path)
         | 
| 442 | 
            +
                def glob(path, &block)
         | 
| 443 443 | 
             
                  path = path.gsub('\\', '/') if windows?
         | 
| 444 | 
            -
                  Dir.glob(path)
         | 
| 444 | 
            +
                  Dir.glob(path, &block)
         | 
| 445 445 | 
             
                end
         | 
| 446 446 |  | 
| 447 447 | 
             
                ## Cross-Ruby-Version Compatibility
         | 
| @@ -466,6 +466,13 @@ module Sass | |
| 466 466 | 
             
                  ruby1_8? && Sass::Util::RUBY_VERSION[2] < 7
         | 
| 467 467 | 
             
                end
         | 
| 468 468 |  | 
| 469 | 
            +
                # Whether or not this is running under MacRuby.
         | 
| 470 | 
            +
                #
         | 
| 471 | 
            +
                # @return [Boolean]
         | 
| 472 | 
            +
                def macruby?
         | 
| 473 | 
            +
                  RUBY_ENGINE == 'macruby'
         | 
| 474 | 
            +
                end
         | 
| 475 | 
            +
             | 
| 469 476 | 
             
                # Checks that the encoding of a string is valid in Ruby 1.9
         | 
| 470 477 | 
             
                # and cleans up potential encoding gotchas like the UTF-8 BOM.
         | 
| 471 478 | 
             
                # If it's not, yields an error string describing the invalid character
         | 
| @@ -568,7 +575,7 @@ MSG | |
| 568 575 | 
             
                        Regexp.new(/\A(?:#{_enc("\uFEFF", e)})?#{
         | 
| 569 576 | 
             
                          _enc('@charset "', e)}(.*?)#{_enc('"', e)}|\A(#{
         | 
| 570 577 | 
             
                          _enc("\uFEFF", e)})/)
         | 
| 571 | 
            -
                      rescue Encoding:: | 
| 578 | 
            +
                      rescue Encoding::ConverterNotFoundError => _
         | 
| 572 579 | 
             
                        nil # JRuby on Java 5 doesn't support UTF-32
         | 
| 573 580 | 
             
                      rescue
         | 
| 574 581 | 
             
                        # /\A@charset "(.*?)"/
         | 
    
        data/test/sass/functions_test.rb
    CHANGED
    
    | @@ -312,6 +312,18 @@ class SassFunctionTest < Test::Unit::TestCase | |
| 312 312 | 
             
                assert_error_message("12 is not a color for `alpha'", "alpha(12)")
         | 
| 313 313 | 
             
              end
         | 
| 314 314 |  | 
| 315 | 
            +
              def test_opacity
         | 
| 316 | 
            +
                assert_equal("1", evaluate("opacity(#123456)"))
         | 
| 317 | 
            +
                assert_equal("0.34", evaluate("opacity(rgba(0, 1, 2, 0.34))"))
         | 
| 318 | 
            +
                assert_equal("0", evaluate("opacity(hsla(0, 1, 2, 0))"))
         | 
| 319 | 
            +
                assert_equal("0", evaluate("opacity($color: hsla(0, 1, 2, 0))"))
         | 
| 320 | 
            +
                assert_equal("opacity(20%)", evaluate("opacity(20%)"))
         | 
| 321 | 
            +
              end
         | 
| 322 | 
            +
             | 
| 323 | 
            +
              def test_opacity_exception
         | 
| 324 | 
            +
                assert_error_message("\"foo\" is not a color for `opacity'", "opacity(foo)")
         | 
| 325 | 
            +
              end
         | 
| 326 | 
            +
             | 
| 315 327 | 
             
              def test_opacify
         | 
| 316 328 | 
             
                assert_equal("rgba(0, 0, 0, 0.75)", evaluate("opacify(rgba(0, 0, 0, 0.5), 0.25)"))
         | 
| 317 329 | 
             
                assert_equal("rgba(0, 0, 0, 0.3)", evaluate("opacify(rgba(0, 0, 0, 0.2), 0.1)"))
         | 
| @@ -411,6 +423,7 @@ class SassFunctionTest < Test::Unit::TestCase | |
| 411 423 | 
             
                assert_equal("#88aa88", evaluate("saturate(#8a8, 0%)"))
         | 
| 412 424 | 
             
                assert_equal("rgba(158, 63, 63, 0.5)", evaluate("saturate(rgba(136, 85, 85, 0.5), 20%)"))
         | 
| 413 425 | 
             
                assert_equal("rgba(158, 63, 63, 0.5)", evaluate("saturate($color: rgba(136, 85, 85, 0.5), $amount: 20%)"))
         | 
| 426 | 
            +
                assert_equal("saturate(50%)", evaluate("saturate(50%)"))
         | 
| 414 427 | 
             
              end
         | 
| 415 428 |  | 
| 416 429 | 
             
              def test_saturate_tests_bounds
         | 
| @@ -797,6 +810,7 @@ class SassFunctionTest < Test::Unit::TestCase | |
| 797 810 | 
             
              def test_invert
         | 
| 798 811 | 
             
                assert_equal("#112233", evaluate("invert(#edc)"))
         | 
| 799 812 | 
             
                assert_equal("rgba(245, 235, 225, 0.5)", evaluate("invert(rgba(10, 20, 30, 0.5))"))
         | 
| 813 | 
            +
                assert_equal("invert(20%)", evaluate("invert(20%)"))
         | 
| 800 814 | 
             
              end
         | 
| 801 815 |  | 
| 802 816 | 
             
              def test_invert_tests_types
         | 
    
        data/test/sass/scss/css_test.rb
    CHANGED
    
    | @@ -946,6 +946,10 @@ SCSS | |
| 946 946 |  | 
| 947 947 | 
             
              ## Regressions
         | 
| 948 948 |  | 
| 949 | 
            +
              def test_selector_without_closing_bracket
         | 
| 950 | 
            +
                assert_not_parses('"]"', "foo[bar <err>{a: b}")
         | 
| 951 | 
            +
              end
         | 
| 952 | 
            +
             | 
| 949 953 | 
             
              def test_closing_line_comment_end_with_compact_output
         | 
| 950 954 | 
             
                assert_equal(<<CSS, render(<<SCSS, :style => :compact))
         | 
| 951 955 | 
             
            /* foo */
         | 
    
        metadata
    CHANGED
    
    | @@ -1,13 +1,13 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: sass
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              hash:  | 
| 4 | 
            +
              hash: 43
         | 
| 5 5 | 
             
              prerelease: false
         | 
| 6 6 | 
             
              segments: 
         | 
| 7 7 | 
             
              - 3
         | 
| 8 8 | 
             
              - 1
         | 
| 9 | 
            -
              -  | 
| 10 | 
            -
              version: 3.1. | 
| 9 | 
            +
              - 20
         | 
| 10 | 
            +
              version: 3.1.20
         | 
| 11 11 | 
             
            platform: ruby
         | 
| 12 12 | 
             
            authors: 
         | 
| 13 13 | 
             
            - Nathan Weizenbaum
         | 
| @@ -17,7 +17,7 @@ autorequire: | |
| 17 17 | 
             
            bindir: bin
         | 
| 18 18 | 
             
            cert_chain: []
         | 
| 19 19 |  | 
| 20 | 
            -
            date: 2012- | 
| 20 | 
            +
            date: 2012-06-29 00:00:00 -07:00
         | 
| 21 21 | 
             
            default_executable: 
         | 
| 22 22 | 
             
            dependencies: 
         | 
| 23 23 | 
             
            - !ruby/object:Gem::Dependency 
         |