sassc-inline-svg 0.0.1
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 +7 -0
 - data/Gemfile +5 -0
 - data/README.md +12 -0
 - data/lib/sassc-inline-svg.rb +37 -0
 - data/lib/sassc-inline-svg/version.rb +8 -0
 - data/sassc-inline-svg.gemspec +21 -0
 - metadata +61 -0
 
    
        checksums.yaml
    ADDED
    
    | 
         @@ -0,0 +1,7 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ---
         
     | 
| 
      
 2 
     | 
    
         
            +
            SHA256:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: bfe1125b1aeeb7871aac174f657357fcc5f7e446156d03cb9449f59bd8961dea
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: a000f33cd15b2c92ccde94018233ec2e3c108939b6adb9f26d79f83e12edf336
         
     | 
| 
      
 5 
     | 
    
         
            +
            SHA512:
         
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 8acff27ee03b575862006c77173f50f8348121e419da224855e747828c54c91ace3df19ee4d1891c747b18ce3da0898d5ace0b580424b599a2ec336378702a2b
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 3fd6893203dfec9ce69066f312c2ff8d6501634601e57b7bbc524f8923a70954206ae6debed1202d1780842d14a45a0795a303b3aaca6301131bd8b9f2fa96b9
         
     | 
    
        data/Gemfile
    ADDED
    
    
    
        data/README.md
    ADDED
    
    
| 
         @@ -0,0 +1,37 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # encoding: UTF-8
         
     | 
| 
      
 2 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            require 'sassc-rails'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'cgi'
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            module SassC::InlineSVG
         
     | 
| 
      
 8 
     | 
    
         
            +
              module Functions
         
     | 
| 
      
 9 
     | 
    
         
            +
                def inline_svg(path, options = nil)
         
     | 
| 
      
 10 
     | 
    
         
            +
                  sprockets_context.depend_on_asset(path.value)
         
     | 
| 
      
 11 
     | 
    
         
            +
                  svg = read_file(path.value.strip)
         
     | 
| 
      
 12 
     | 
    
         
            +
                  options.value.each_pair { |k, v| svg.gsub!(k.value, v.value) if svg.include?(k.value) } unless options.nil?
         
     | 
| 
      
 13 
     | 
    
         
            +
                  SassC::Script::Value::String.new(encoded_url(svg))
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                private
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                def encoded_url(svg)
         
     | 
| 
      
 19 
     | 
    
         
            +
                  encoded = CGI::escape(svg).gsub("+", "%20")
         
     | 
| 
      
 20 
     | 
    
         
            +
                  "url('data:image/svg+xml;charset=utf-8," + encoded + "')"
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
                def read_file(path)
         
     | 
| 
      
 24 
     | 
    
         
            +
                  if defined?(Rails)
         
     | 
| 
      
 25 
     | 
    
         
            +
                    asset = (Rails.application.assets || ::Sprockets::Railtie.build_environment(Rails.application)).find_asset(path).to_s
         
     | 
| 
      
 26 
     | 
    
         
            +
                    raise "File not found or cannot be read (Sprockets): #{path}" if asset.nil?
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                    return asset.to_s
         
     | 
| 
      
 29 
     | 
    
         
            +
                  end
         
     | 
| 
      
 30 
     | 
    
         
            +
                  raise SassC::SyntaxError, "File not found or cannot be read (native): #{path}" unless File.readable?(path)
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                  File.open(path, 'rb') { |f| f.read }.strip
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
            end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            SassC::Script::Functions.include SassC::InlineSVG::Functions
         
     | 
| 
         @@ -0,0 +1,21 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # encoding: UTF-8
         
     | 
| 
      
 2 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            require File.expand_path('../lib/sassc-inline-svg/version', __FILE__)
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            Gem::Specification.new do |s|
         
     | 
| 
      
 7 
     | 
    
         
            +
              s.name            = 'sassc-inline-svg'
         
     | 
| 
      
 8 
     | 
    
         
            +
              s.version         = SassC::InlineSVG::VERSION
         
     | 
| 
      
 9 
     | 
    
         
            +
              s.author          = 'Dmitry Leonov'
         
     | 
| 
      
 10 
     | 
    
         
            +
              s.email           = 'ordm67@gmail.com'
         
     | 
| 
      
 11 
     | 
    
         
            +
              s.summary         = 'Adds inline_svg as a Sass function.'
         
     | 
| 
      
 12 
     | 
    
         
            +
              s.description     = 'Adds inline_svg as a Sass function.'
         
     | 
| 
      
 13 
     | 
    
         
            +
              s.homepage        = 'https://github.com/OrdinaryMagic/sassc-inline-svg'
         
     | 
| 
      
 14 
     | 
    
         
            +
              s.license         = 'MIT'
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              s.files           = `git ls-files -z`.split("\x0")
         
     | 
| 
      
 17 
     | 
    
         
            +
              s.test_files      = `git ls-files -z -- {test,spec,features}/*`.split("\x0")
         
     | 
| 
      
 18 
     | 
    
         
            +
              s.require_paths   = ['lib']
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              s.add_dependency 'sassc-rails', '~> 2.0'
         
     | 
| 
      
 21 
     | 
    
         
            +
            end
         
     | 
    
        metadata
    ADDED
    
    | 
         @@ -0,0 +1,61 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            --- !ruby/object:Gem::Specification
         
     | 
| 
      
 2 
     | 
    
         
            +
            name: sassc-inline-svg
         
     | 
| 
      
 3 
     | 
    
         
            +
            version: !ruby/object:Gem::Version
         
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.1
         
     | 
| 
      
 5 
     | 
    
         
            +
            platform: ruby
         
     | 
| 
      
 6 
     | 
    
         
            +
            authors:
         
     | 
| 
      
 7 
     | 
    
         
            +
            - Dmitry Leonov
         
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire: 
         
     | 
| 
      
 9 
     | 
    
         
            +
            bindir: bin
         
     | 
| 
      
 10 
     | 
    
         
            +
            cert_chain: []
         
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2020-10-23 00:00:00.000000000 Z
         
     | 
| 
      
 12 
     | 
    
         
            +
            dependencies:
         
     | 
| 
      
 13 
     | 
    
         
            +
            - !ruby/object:Gem::Dependency
         
     | 
| 
      
 14 
     | 
    
         
            +
              name: sassc-rails
         
     | 
| 
      
 15 
     | 
    
         
            +
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
      
 16 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 17 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 19 
     | 
    
         
            +
                    version: '2.0'
         
     | 
| 
      
 20 
     | 
    
         
            +
              type: :runtime
         
     | 
| 
      
 21 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
      
 22 
     | 
    
         
            +
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
      
 23 
     | 
    
         
            +
                requirements:
         
     | 
| 
      
 24 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 25 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 26 
     | 
    
         
            +
                    version: '2.0'
         
     | 
| 
      
 27 
     | 
    
         
            +
            description: Adds inline_svg as a Sass function.
         
     | 
| 
      
 28 
     | 
    
         
            +
            email: ordm67@gmail.com
         
     | 
| 
      
 29 
     | 
    
         
            +
            executables: []
         
     | 
| 
      
 30 
     | 
    
         
            +
            extensions: []
         
     | 
| 
      
 31 
     | 
    
         
            +
            extra_rdoc_files: []
         
     | 
| 
      
 32 
     | 
    
         
            +
            files:
         
     | 
| 
      
 33 
     | 
    
         
            +
            - Gemfile
         
     | 
| 
      
 34 
     | 
    
         
            +
            - README.md
         
     | 
| 
      
 35 
     | 
    
         
            +
            - lib/sassc-inline-svg.rb
         
     | 
| 
      
 36 
     | 
    
         
            +
            - lib/sassc-inline-svg/version.rb
         
     | 
| 
      
 37 
     | 
    
         
            +
            - sassc-inline-svg.gemspec
         
     | 
| 
      
 38 
     | 
    
         
            +
            homepage: https://github.com/OrdinaryMagic/sassc-inline-svg
         
     | 
| 
      
 39 
     | 
    
         
            +
            licenses:
         
     | 
| 
      
 40 
     | 
    
         
            +
            - MIT
         
     | 
| 
      
 41 
     | 
    
         
            +
            metadata: {}
         
     | 
| 
      
 42 
     | 
    
         
            +
            post_install_message: 
         
     | 
| 
      
 43 
     | 
    
         
            +
            rdoc_options: []
         
     | 
| 
      
 44 
     | 
    
         
            +
            require_paths:
         
     | 
| 
      
 45 
     | 
    
         
            +
            - lib
         
     | 
| 
      
 46 
     | 
    
         
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 47 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 48 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 49 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 50 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 51 
     | 
    
         
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         
     | 
| 
      
 52 
     | 
    
         
            +
              requirements:
         
     | 
| 
      
 53 
     | 
    
         
            +
              - - ">="
         
     | 
| 
      
 54 
     | 
    
         
            +
                - !ruby/object:Gem::Version
         
     | 
| 
      
 55 
     | 
    
         
            +
                  version: '0'
         
     | 
| 
      
 56 
     | 
    
         
            +
            requirements: []
         
     | 
| 
      
 57 
     | 
    
         
            +
            rubygems_version: 3.1.4
         
     | 
| 
      
 58 
     | 
    
         
            +
            signing_key: 
         
     | 
| 
      
 59 
     | 
    
         
            +
            specification_version: 4
         
     | 
| 
      
 60 
     | 
    
         
            +
            summary: Adds inline_svg as a Sass function.
         
     | 
| 
      
 61 
     | 
    
         
            +
            test_files: []
         
     |