compass-svg-polyfill 1.0.6 → 1.0.7
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
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: fc2ba58d9987f92353653ad9ded9d156d942a48b
         | 
| 4 | 
            +
              data.tar.gz: ff2d2f173900f5dff4f146387297cb447b815d9f
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: f440fa50551bd792a30ff27fa4ac5d6ade880a6b315c5e331b89aaef51f394aa0265ee9249c79c421bead1a4d89897b07d3f1f5d8a1fdd8542ff2d76449fcda9
         | 
| 7 | 
            +
              data.tar.gz: 3f1d41f801cfe19de9a61169966b84080a0de3baf0a5708551a6ac2e852d167c81ca3a601179107a70d7b1db1c5969093ca40777391e8e9a68949c03bb67ec26
         | 
    
        data/README.md
    CHANGED
    
    
    
        data/lib/compass-svg-polyfill.rb
    CHANGED
    
    
| @@ -1,3 +1,6 @@ | |
| 1 | 
            +
            require 'tempfile'
         | 
| 2 | 
            +
            require 'fileutils'
         | 
| 3 | 
            +
            require 'digest'
         | 
| 1 4 | 
             
            require 'RMagick' unless Object.const_defined?("Magick")
         | 
| 2 5 |  | 
| 3 6 | 
             
            module Sass::Script::Functions
         | 
| @@ -8,43 +11,74 @@ module Sass::Script::Functions | |
| 8 11 | 
             
                assert_type pngName, :String
         | 
| 9 12 | 
             
                assert_type imageConverter, :String
         | 
| 10 13 |  | 
| 14 | 
            +
                # Normalise values
         | 
| 15 | 
            +
                svgFilepath = File.join Compass.configuration.images_path, svgName.value.to_s
         | 
| 16 | 
            +
                pngFilepath = File.join Compass.configuration.images_path, pngName.value.to_s
         | 
| 11 17 | 
             
                imageConverter = imageConverter.value.to_sym
         | 
| 12 18 |  | 
| 19 | 
            +
                # Helper objects
         | 
| 13 20 | 
             
                logger = Compass::Logger.new
         | 
| 21 | 
            +
                cache_store = environment.options[:cache_store]
         | 
| 14 22 |  | 
| 15 | 
            -
                 | 
| 16 | 
            -
                 | 
| 17 | 
            -
             | 
| 18 | 
            -
                pngName = pngName.value.to_s
         | 
| 19 | 
            -
                pngPath = File.join Compass.configuration.images_path, pngName
         | 
| 20 | 
            -
             | 
| 21 | 
            -
                if !File.exists? svgPath
         | 
| 22 | 
            -
                  raise Sass::SyntaxError, "svg does not exist #{svgName}"
         | 
| 23 | 
            +
                # Check if file exists
         | 
| 24 | 
            +
                if !File.exists? svgFilepath
         | 
| 25 | 
            +
                  raise Sass::SyntaxError, "SVG file does not exist #{svgName.value.to_s}"
         | 
| 23 26 | 
             
                end
         | 
| 24 27 |  | 
| 25 | 
            -
                 | 
| 26 | 
            -
             | 
| 27 | 
            -
                 | 
| 28 | 
            -
                  logger.record :create, pngName
         | 
| 29 | 
            -
                end
         | 
| 28 | 
            +
                # Create a temporary output file
         | 
| 29 | 
            +
                tmpFile = Tempfile.new(['compass-svg-polyfill', '.png'])
         | 
| 30 | 
            +
                tmpFile.close false
         | 
| 30 31 |  | 
| 31 32 | 
             
                case imageConverter
         | 
| 32 33 | 
             
                when :imagemagick
         | 
| 33 | 
            -
                  img = Magick::Image.read( | 
| 34 | 
            +
                  img = Magick::Image.read(svgFilepath).first
         | 
| 34 35 | 
             
                  img.resize!(width.value.to_i, height.value.to_i)
         | 
| 35 | 
            -
                  img.write  | 
| 36 | 
            +
                  img.write tmpFile.path
         | 
| 36 37 | 
             
                when :librsvg
         | 
| 37 38 | 
             
                  system(
         | 
| 38 | 
            -
                    "rsvg-convert", | 
| 39 | 
            -
                    "-w",  | 
| 40 | 
            -
                    "-h",  | 
| 41 | 
            -
                     | 
| 42 | 
            -
                    "-o",  | 
| 39 | 
            +
                    "rsvg-convert",      # Process
         | 
| 40 | 
            +
                    "-w", width.value,   # Width
         | 
| 41 | 
            +
                    "-h", height.value,  # Height
         | 
| 42 | 
            +
                    svgFilepath,         # Input
         | 
| 43 | 
            +
                    "-o", tmpFile.path   # Output
         | 
| 43 44 | 
             
                  )
         | 
| 44 45 | 
             
                else
         | 
| 45 46 | 
             
                  raise Sass::SyntaxError, "Unknown image converter #{imageConverter}"
         | 
| 46 47 | 
             
                end
         | 
| 47 48 |  | 
| 49 | 
            +
                # Setup cache values
         | 
| 50 | 
            +
                cacheKey = cache_store.key(File.dirname(pngFilepath), File.basename(pngFilepath))
         | 
| 51 | 
            +
                cacheSHA = Digest::SHA1.hexdigest(pngFilepath)
         | 
| 52 | 
            +
                cacheVal = "#{width} #{height} #{Digest::SHA1.file(svgFilepath).hexdigest}"
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                action = nil
         | 
| 55 | 
            +
             | 
| 56 | 
            +
                if File.exists? pngFilepath
         | 
| 57 | 
            +
                  action = :overwrite
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                  if (cachedSHA = cache_store.retrieve(cacheKey, cacheSHA)) then
         | 
| 60 | 
            +
                    if cachedSHA.eql? cacheVal then
         | 
| 61 | 
            +
                      action = :unchanged
         | 
| 62 | 
            +
                    end
         | 
| 63 | 
            +
                  end
         | 
| 64 | 
            +
                else
         | 
| 65 | 
            +
                  action = :create
         | 
| 66 | 
            +
                end
         | 
| 67 | 
            +
             | 
| 68 | 
            +
                logger.record action, pngName.value
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                case action
         | 
| 71 | 
            +
                when :overwrite, :create
         | 
| 72 | 
            +
                  # Save the file
         | 
| 73 | 
            +
                  FileUtils.mv(tmpFile.path, pngFilepath)
         | 
| 74 | 
            +
                end
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                # Save the cache key
         | 
| 77 | 
            +
                cache_store.store(cacheKey, cacheSHA, cacheVal)
         | 
| 78 | 
            +
             | 
| 79 | 
            +
                # Remove temp file
         | 
| 80 | 
            +
                tmpFile.unlink
         | 
| 81 | 
            +
             | 
| 48 82 | 
             
                Sass::Script::Bool.new true
         | 
| 49 83 | 
             
              end
         | 
| 50 84 |  | 
| 
            File without changes
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: compass-svg-polyfill
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.0. | 
| 4 | 
            +
              version: 1.0.7
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Bashkim Isai
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2015-02-11 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rmagick
         | 
| @@ -60,11 +60,11 @@ executables: [] | |
| 60 60 | 
             
            extensions: []
         | 
| 61 61 | 
             
            extra_rdoc_files: []
         | 
| 62 62 | 
             
            files:
         | 
| 63 | 
            +
            - README.md
         | 
| 64 | 
            +
            - lib/compass-svg-polyfill.rb
         | 
| 63 65 | 
             
            - lib/compass-svg-polyfill/sass_functions.rb
         | 
| 64 | 
            -
            - lib/compass-svg-polyfill/stylesheets/compass-svg-polyfill/ | 
| 66 | 
            +
            - lib/compass-svg-polyfill/stylesheets/compass-svg-polyfill/_svg.scss
         | 
| 65 67 | 
             
            - lib/compass-svg-polyfill/version.rb
         | 
| 66 | 
            -
            - lib/compass-svg-polyfill.rb
         | 
| 67 | 
            -
            - README.md
         | 
| 68 68 | 
             
            homepage: http://github.com/bashaus/compass-svg-polyfill
         | 
| 69 69 | 
             
            licenses:
         | 
| 70 70 | 
             
            - MIT
         | 
| @@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 85 85 | 
             
                  version: '0'
         | 
| 86 86 | 
             
            requirements: []
         | 
| 87 87 | 
             
            rubyforge_project: 
         | 
| 88 | 
            -
            rubygems_version: 2. | 
| 88 | 
            +
            rubygems_version: 2.4.4
         | 
| 89 89 | 
             
            signing_key: 
         | 
| 90 90 | 
             
            specification_version: 4
         | 
| 91 91 | 
             
            summary: Converts SVG images to PNG for use in older browsers
         |