sprockets 2.2.3 → 2.3.3
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.
Potentially problematic release.
This version of sprockets might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +22 -1
- data/lib/sprockets.rb +6 -2
- data/lib/sprockets/asset.rb +1 -0
- data/lib/sprockets/caching.rb +39 -39
- data/lib/sprockets/context.rb +2 -2
- data/lib/sprockets/manifest.rb +1 -0
- data/lib/sprockets/sass_cache_store.rb +25 -0
- data/lib/sprockets/sass_importer.rb +29 -0
- data/lib/sprockets/sass_template.rb +47 -0
- data/lib/sprockets/scss_template.rb +13 -0
- data/lib/sprockets/version.rb +1 -1
- metadata +19 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 7d49453908a650a88e75856c3002fc529139583d
         | 
| 4 | 
            +
              data.tar.gz: c4032fb6c3197b5872097d55365b1e3c8547369d
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: eeaf6c406818a6736564bad41f732b7f45c18504625caa8e4a71cb0466e6238656ade799b1f4c4c1a5e37c4142f8180e0136cfa6489a88a93e59e70cbf9a5346
         | 
| 7 | 
            +
              data.tar.gz: 1d3f359e15024afc8828d45f868b73a8685d21d69a9e93e4dfd57afb7a4043f5e06f84f49d714ebb879e0855ae6c866a83b042770756bf03dbf64fe2288fcfe5
         | 
    
        data/README.md
    CHANGED
    
    | @@ -336,6 +336,13 @@ source file before any subsequent `require` or `include` directives. | |
| 336 336 | 
             
            including it in the bundle. This is useful when you need to expire an
         | 
| 337 337 | 
             
            asset's cache in response to a change in another file.
         | 
| 338 338 |  | 
| 339 | 
            +
            ### The `stub` Directive ###
         | 
| 340 | 
            +
             | 
| 341 | 
            +
            `stub` *path* allows dependency to be excluded from the asset bundle.
         | 
| 342 | 
            +
            The *path* must be a valid asset and may or may not already be part
         | 
| 343 | 
            +
            of the bundle. Once stubbed, it is blacklisted and can't be brought
         | 
| 344 | 
            +
            back by any other `require`.
         | 
| 345 | 
            +
             | 
| 339 346 | 
             
            # Development #
         | 
| 340 347 |  | 
| 341 348 | 
             
            ## Contributing ##
         | 
| @@ -354,7 +361,21 @@ submit a pull request. | |
| 354 361 |  | 
| 355 362 | 
             
            ## Version History ##
         | 
| 356 363 |  | 
| 357 | 
            -
            **2.2 | 
| 364 | 
            +
            **2.3.2** (March 26, 2012)
         | 
| 365 | 
            +
             | 
| 366 | 
            +
            * Fix Context#logical_path with dots
         | 
| 367 | 
            +
             | 
| 368 | 
            +
            **2.3.1** (February 11, 2012)
         | 
| 369 | 
            +
             | 
| 370 | 
            +
            * Added bytesize to manifest
         | 
| 371 | 
            +
            * Added Asset#bytesize alias
         | 
| 372 | 
            +
            * Security: Check path for forbidden access after unescaping
         | 
| 373 | 
            +
             | 
| 374 | 
            +
            **2.3.0** (January 16, 2012)
         | 
| 375 | 
            +
             | 
| 376 | 
            +
            * Added special Sass importer that automatically tracks any `@import`ed files.
         | 
| 377 | 
            +
             | 
| 378 | 
            +
            **2.2.0** (January 10, 2012)
         | 
| 358 379 |  | 
| 359 380 | 
             
            * Added `sprockets` command line utility.
         | 
| 360 381 | 
             
            * Added rake/sprocketstask.
         | 
    
        data/lib/sprockets.rb
    CHANGED
    
    | @@ -23,6 +23,10 @@ module Sprockets | |
| 23 23 | 
             
              autoload :JstProcessor,            "sprockets/jst_processor"
         | 
| 24 24 | 
             
              autoload :Processor,               "sprockets/processor"
         | 
| 25 25 | 
             
              autoload :SafetyColons,            "sprockets/safety_colons"
         | 
| 26 | 
            +
              autoload :SassCacheStore,          "sprockets/sass_cache_store"
         | 
| 27 | 
            +
              autoload :SassImporter,            "sprockets/sass_importer"
         | 
| 28 | 
            +
              autoload :SassTemplate,            "sprockets/sass_template"
         | 
| 29 | 
            +
              autoload :ScssTemplate,            "sprockets/scss_template"
         | 
| 26 30 |  | 
| 27 31 | 
             
              # Internal utilities
         | 
| 28 32 | 
             
              autoload :ArgumentError,           "sprockets/errors"
         | 
| @@ -55,8 +59,8 @@ module Sprockets | |
| 55 59 |  | 
| 56 60 | 
             
              # CSS engines
         | 
| 57 61 | 
             
              register_engine '.less',   Tilt::LessTemplate
         | 
| 58 | 
            -
              register_engine '.sass',    | 
| 59 | 
            -
              register_engine '.scss',    | 
| 62 | 
            +
              register_engine '.sass',   SassTemplate
         | 
| 63 | 
            +
              register_engine '.scss',   ScssTemplate
         | 
| 60 64 |  | 
| 61 65 | 
             
              # Other
         | 
| 62 66 | 
             
              register_engine '.erb',    Tilt::ERBTemplate
         | 
    
        data/lib/sprockets/asset.rb
    CHANGED
    
    
    
        data/lib/sprockets/caching.rb
    CHANGED
    
    | @@ -2,6 +2,45 @@ module Sprockets | |
| 2 2 | 
             
              # `Caching` is an internal mixin whose public methods are exposed on
         | 
| 3 3 | 
             
              # the `Environment` and `Index` classes.
         | 
| 4 4 | 
             
              module Caching
         | 
| 5 | 
            +
                # Low level cache getter for `key`. Checks a number of supported
         | 
| 6 | 
            +
                # cache interfaces.
         | 
| 7 | 
            +
                def cache_get(key)
         | 
| 8 | 
            +
                  # `Cache#get(key)` for Memcache
         | 
| 9 | 
            +
                  if cache.respond_to?(:get)
         | 
| 10 | 
            +
                    cache.get(key)
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                  # `Cache#[key]` so `Hash` can be used
         | 
| 13 | 
            +
                  elsif cache.respond_to?(:[])
         | 
| 14 | 
            +
                    cache[key]
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  # `Cache#read(key)` for `ActiveSupport::Cache` support
         | 
| 17 | 
            +
                  elsif cache.respond_to?(:read)
         | 
| 18 | 
            +
                    cache.read(key)
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  else
         | 
| 21 | 
            +
                    nil
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                # Low level cache setter for `key`. Checks a number of supported
         | 
| 26 | 
            +
                # cache interfaces.
         | 
| 27 | 
            +
                def cache_set(key, value)
         | 
| 28 | 
            +
                  # `Cache#set(key, value)` for Memcache
         | 
| 29 | 
            +
                  if cache.respond_to?(:set)
         | 
| 30 | 
            +
                    cache.set(key, value)
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                  # `Cache#[key]=value` so `Hash` can be used
         | 
| 33 | 
            +
                  elsif cache.respond_to?(:[]=)
         | 
| 34 | 
            +
                    cache[key] = value
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                  # `Cache#write(key, value)` for `ActiveSupport::Cache` support
         | 
| 37 | 
            +
                  elsif cache.respond_to?(:write)
         | 
| 38 | 
            +
                    cache.write(key, value)
         | 
| 39 | 
            +
                  end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                  value
         | 
| 42 | 
            +
                end
         | 
| 43 | 
            +
             | 
| 5 44 | 
             
                protected
         | 
| 6 45 | 
             
                  # Cache helper method. Takes a `path` argument which maybe a
         | 
| 7 46 | 
             
                  # logical path or fully expanded path. The `&block` is passed
         | 
| @@ -53,44 +92,5 @@ module Sprockets | |
| 53 92 | 
             
                    cache_set(expand_cache_key(key), hash)
         | 
| 54 93 | 
             
                    hash
         | 
| 55 94 | 
             
                  end
         | 
| 56 | 
            -
             | 
| 57 | 
            -
                  # Low level cache getter for `key`. Checks a number of supported
         | 
| 58 | 
            -
                  # cache interfaces.
         | 
| 59 | 
            -
                  def cache_get(key)
         | 
| 60 | 
            -
                    # `Cache#get(key)` for Memcache
         | 
| 61 | 
            -
                    if cache.respond_to?(:get)
         | 
| 62 | 
            -
                      cache.get(key)
         | 
| 63 | 
            -
             | 
| 64 | 
            -
                    # `Cache#[key]` so `Hash` can be used
         | 
| 65 | 
            -
                    elsif cache.respond_to?(:[])
         | 
| 66 | 
            -
                      cache[key]
         | 
| 67 | 
            -
             | 
| 68 | 
            -
                    # `Cache#read(key)` for `ActiveSupport::Cache` support
         | 
| 69 | 
            -
                    elsif cache.respond_to?(:read)
         | 
| 70 | 
            -
                      cache.read(key)
         | 
| 71 | 
            -
             | 
| 72 | 
            -
                    else
         | 
| 73 | 
            -
                      nil
         | 
| 74 | 
            -
                    end
         | 
| 75 | 
            -
                  end
         | 
| 76 | 
            -
             | 
| 77 | 
            -
                  # Low level cache setter for `key`. Checks a number of supported
         | 
| 78 | 
            -
                  # cache interfaces.
         | 
| 79 | 
            -
                  def cache_set(key, value)
         | 
| 80 | 
            -
                    # `Cache#set(key, value)` for Memcache
         | 
| 81 | 
            -
                    if cache.respond_to?(:set)
         | 
| 82 | 
            -
                      cache.set(key, value)
         | 
| 83 | 
            -
             | 
| 84 | 
            -
                    # `Cache#[key]=value` so `Hash` can be used
         | 
| 85 | 
            -
                    elsif cache.respond_to?(:[]=)
         | 
| 86 | 
            -
                      cache[key] = value
         | 
| 87 | 
            -
             | 
| 88 | 
            -
                    # `Cache#write(key, value)` for `ActiveSupport::Cache` support
         | 
| 89 | 
            -
                    elsif cache.respond_to?(:write)
         | 
| 90 | 
            -
                      cache.write(key, value)
         | 
| 91 | 
            -
                    end
         | 
| 92 | 
            -
             | 
| 93 | 
            -
                    value
         | 
| 94 | 
            -
                  end
         | 
| 95 95 | 
             
              end
         | 
| 96 96 | 
             
            end
         | 
    
        data/lib/sprockets/context.rb
    CHANGED
    
    | @@ -53,7 +53,7 @@ module Sprockets | |
| 53 53 | 
             
                #     # => 'application'
         | 
| 54 54 | 
             
                #
         | 
| 55 55 | 
             
                def logical_path
         | 
| 56 | 
            -
                  @logical_path | 
| 56 | 
            +
                  @logical_path.chomp(File.extname(@logical_path))
         | 
| 57 57 | 
             
                end
         | 
| 58 58 |  | 
| 59 59 | 
             
                # Returns content type of file
         | 
| @@ -101,7 +101,7 @@ module Sprockets | |
| 101 101 |  | 
| 102 102 | 
             
                    raise FileNotFound, "couldn't find file '#{path}'"
         | 
| 103 103 | 
             
                  else
         | 
| 104 | 
            -
                    environment.resolve(path, :base_path => self.pathname.dirname, &block)
         | 
| 104 | 
            +
                    environment.resolve(path, {:base_path => self.pathname.dirname}.merge(options), &block)
         | 
| 105 105 | 
             
                  end
         | 
| 106 106 | 
             
                end
         | 
| 107 107 |  | 
    
        data/lib/sprockets/manifest.rb
    CHANGED
    
    
| @@ -0,0 +1,25 @@ | |
| 1 | 
            +
            require 'sass'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Sprockets
         | 
| 4 | 
            +
              class SassCacheStore < ::Sass::CacheStores::Base
         | 
| 5 | 
            +
                attr_reader :environment
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                def initialize(environment)
         | 
| 8 | 
            +
                  @environment = environment
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                def _store(key, version, sha, contents)
         | 
| 12 | 
            +
                  environment.cache_set("sass/#{key}", {:version => version, :sha => sha, :contents => contents})
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                def _retrieve(key, version, sha)
         | 
| 16 | 
            +
                  if obj = environment.cache_get("sass/#{key}")
         | 
| 17 | 
            +
                    return unless obj[:version] == version
         | 
| 18 | 
            +
                    return unless obj[:sha] == sha
         | 
| 19 | 
            +
                    obj[:obj]
         | 
| 20 | 
            +
                  else
         | 
| 21 | 
            +
                    nil
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
            end
         | 
| @@ -0,0 +1,29 @@ | |
| 1 | 
            +
            require 'sass'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Sprockets
         | 
| 4 | 
            +
              # This custom importer adds sprockets dependency tracking on to Sass
         | 
| 5 | 
            +
              # `@import` statements. This makes the Sprockets and Sass caching
         | 
| 6 | 
            +
              # systems work together.
         | 
| 7 | 
            +
              class SassImporter < Sass::Importers::Filesystem
         | 
| 8 | 
            +
                def initialize(context, root)
         | 
| 9 | 
            +
                  @context = context
         | 
| 10 | 
            +
                  super root.to_s
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                def find_relative(*args)
         | 
| 14 | 
            +
                  engine = super
         | 
| 15 | 
            +
                  if engine && (filename = engine.options[:filename])
         | 
| 16 | 
            +
                    @context.depend_on_asset(filename)
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
                  engine
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                def find(*args)
         | 
| 22 | 
            +
                  engine = super
         | 
| 23 | 
            +
                  if engine && (filename = engine.options[:filename])
         | 
| 24 | 
            +
                    @context.depend_on_asset(filename)
         | 
| 25 | 
            +
                  end
         | 
| 26 | 
            +
                  engine
         | 
| 27 | 
            +
                end
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
            end
         | 
| @@ -0,0 +1,47 @@ | |
| 1 | 
            +
            require 'tilt'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Sprockets
         | 
| 4 | 
            +
              # This custom Tilt handler replaces the one built into Tilt. The
         | 
| 5 | 
            +
              # main difference is that it uses a custom importer that plays nice
         | 
| 6 | 
            +
              # with sprocket's caching system.
         | 
| 7 | 
            +
              #
         | 
| 8 | 
            +
              # See `SassImporter` for more infomation.
         | 
| 9 | 
            +
              class SassTemplate < Tilt::Template
         | 
| 10 | 
            +
                self.default_mime_type = 'text/css'
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                def self.engine_initialized?
         | 
| 13 | 
            +
                  defined? ::Sass::Engine
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                def initialize_engine
         | 
| 17 | 
            +
                  require_template_library 'sass'
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                def prepare
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                def syntax
         | 
| 24 | 
            +
                  :sass
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                def evaluate(context, locals, &block)
         | 
| 28 | 
            +
                  # Use custom importer that knows about Sprockets Caching
         | 
| 29 | 
            +
                  cache_store = SassCacheStore.new(context.environment)
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                  options = {
         | 
| 32 | 
            +
                    :filename => eval_file,
         | 
| 33 | 
            +
                    :line => line,
         | 
| 34 | 
            +
                    :syntax => syntax,
         | 
| 35 | 
            +
                    :cache_store => cache_store,
         | 
| 36 | 
            +
                    :importer => SassImporter.new(context, context.pathname),
         | 
| 37 | 
            +
                    :load_paths => context.environment.paths.map { |path| SassImporter.new(context, path) }
         | 
| 38 | 
            +
                  }
         | 
| 39 | 
            +
             | 
| 40 | 
            +
                  ::Sass::Engine.new(data, options).render
         | 
| 41 | 
            +
                rescue ::Sass::SyntaxError => e
         | 
| 42 | 
            +
                  # Annotates exception message with parse line number
         | 
| 43 | 
            +
                  context.__LINE__ = e.sass_backtrace.first[:line]
         | 
| 44 | 
            +
                  raise e
         | 
| 45 | 
            +
                end
         | 
| 46 | 
            +
              end
         | 
| 47 | 
            +
            end
         | 
| @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            require 'sprockets/sass_template'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Sprockets
         | 
| 4 | 
            +
              # Scss handler to replace Tilt's builtin one. See `SassTemplate` and
         | 
| 5 | 
            +
              # `SassImporter` for more infomation.
         | 
| 6 | 
            +
              class ScssTemplate < SassTemplate
         | 
| 7 | 
            +
                self.default_mime_type = 'text/css'
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                def syntax
         | 
| 10 | 
            +
                  :scss
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
            end
         | 
    
        data/lib/sprockets/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: sprockets
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2. | 
| 4 | 
            +
              version: 2.3.3
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Sam Stephenson
         | 
| @@ -185,6 +185,20 @@ dependencies: | |
| 185 185 | 
             
                - - ">="
         | 
| 186 186 | 
             
                  - !ruby/object:Gem::Version
         | 
| 187 187 | 
             
                    version: '0'
         | 
| 188 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 189 | 
            +
              name: sass
         | 
| 190 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 191 | 
            +
                requirements:
         | 
| 192 | 
            +
                - - "~>"
         | 
| 193 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 194 | 
            +
                    version: '3.1'
         | 
| 195 | 
            +
              type: :development
         | 
| 196 | 
            +
              prerelease: false
         | 
| 197 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 198 | 
            +
                requirements:
         | 
| 199 | 
            +
                - - "~>"
         | 
| 200 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 201 | 
            +
                    version: '3.1'
         | 
| 188 202 | 
             
            description: Sprockets is a Rack-based asset packaging system that concatenates and
         | 
| 189 203 | 
             
              serves JavaScript, CoffeeScript, CSS, LESS, Sass, and SCSS.
         | 
| 190 204 | 
             
            email:
         | 
| @@ -222,6 +236,10 @@ files: | |
| 222 236 | 
             
            - lib/sprockets/processing.rb
         | 
| 223 237 | 
             
            - lib/sprockets/processor.rb
         | 
| 224 238 | 
             
            - lib/sprockets/safety_colons.rb
         | 
| 239 | 
            +
            - lib/sprockets/sass_cache_store.rb
         | 
| 240 | 
            +
            - lib/sprockets/sass_importer.rb
         | 
| 241 | 
            +
            - lib/sprockets/sass_template.rb
         | 
| 242 | 
            +
            - lib/sprockets/scss_template.rb
         | 
| 225 243 | 
             
            - lib/sprockets/server.rb
         | 
| 226 244 | 
             
            - lib/sprockets/static_asset.rb
         | 
| 227 245 | 
             
            - lib/sprockets/trail.rb
         |