padrino-pipeline 0.2.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 +7 -0
- data/.gitignore +2 -0
- data/.travis.yml +14 -0
- data/Gemfile +10 -0
- data/LICENSE.txt +20 -0
- data/README.md +60 -0
- data/Rakefile +14 -0
- data/lib/padrino-pipeline.rb +18 -0
- data/lib/padrino-pipeline/ext/padrino-helpers/asset_tag_helper.rb +12 -0
- data/lib/padrino-pipeline/pipelines/asset_pack.rb +56 -0
- data/lib/padrino-pipeline/pipelines/sprockets.rb +61 -0
- data/lib/padrino-pipeline/version.rb +5 -0
- data/padrino-pipeline.gemspec +34 -0
- data/test/asset_pack/test_css.rb +33 -0
- data/test/asset_pack/test_js.rb +33 -0
- data/test/asset_pack/test_packages.rb +61 -0
- data/test/extra/helper.rb +39 -0
- data/test/extra/mini_shoulda.rb +44 -0
- data/test/fixtures/asset_pack_app/asset_pack_app.rb +32 -0
- data/test/fixtures/asset_pack_app/assets/css/meow.css +3 -0
- data/test/fixtures/asset_pack_app/assets/javascripts/app.js +1 -0
- data/test/fixtures/asset_pack_app/assets/javascripts/coffee.coffee +1 -0
- data/test/fixtures/asset_pack_app/assets/javascripts/other.js +1 -0
- data/test/fixtures/asset_pack_app/assets/js/myapp.js +0 -0
- data/test/fixtures/asset_pack_app/assets/stylesheets/app.css +3 -0
- data/test/fixtures/asset_pack_app/assets/stylesheets/default.scss +3 -0
- data/test/fixtures/sprockets_app/assets/images/glass.png +0 -0
- data/test/fixtures/sprockets_app/assets/javascripts/app.js +2 -0
- data/test/fixtures/sprockets_app/assets/javascripts/coffee.js.coffee +1 -0
- data/test/fixtures/sprockets_app/assets/javascripts/second_js_file.js +1 -0
- data/test/fixtures/sprockets_app/assets/javascripts/unrequired.js +1 -0
- data/test/fixtures/sprockets_app/assets/other/other.css +0 -0
- data/test/fixtures/sprockets_app/assets/stylesheets/application.css +1 -0
- data/test/fixtures/sprockets_app/assets/stylesheets/sass.scss +5 -0
- data/test/fixtures/sprockets_app/assets/stylesheets/second_file.css +3 -0
- data/test/fixtures/sprockets_app/sprockets_app.rb +19 -0
- data/test/sprockets/test_asset_tag.rb +27 -0
- data/test/sprockets/test_assets.rb +40 -0
- data/test/sprockets/test_css.rb +68 -0
- data/test/sprockets/test_js.rb +79 -0
- metadata +223 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: c9eb1b49916318fbeb59d6b2f7b44382eaaa7a10
         | 
| 4 | 
            +
              data.tar.gz: da6aa8f8a18ef8c9df137f719d2110d769016b03
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: f4325db977da9487c2e10572e7516a7cfc748e9bc0a47200ce7e84ef1805b0dadec2c1c10468e9bd43206634f02a0f25d2b9219dc0c59757c48d5d6317bfba00
         | 
| 7 | 
            +
              data.tar.gz: beee248b82501aac96ea301bc223492c799e93e62dde8a50853f61da5a960f659b1374693f2ba529e5a2d390792728476f5103d3ddcdde65750e8107318b1ab7
         | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.travis.yml
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE.txt
    ADDED
    
    | @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            Copyright (c) 2011 Padrino
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining
         | 
| 4 | 
            +
            a copy of this software and associated documentation files (the
         | 
| 5 | 
            +
            "Software"), to deal in the Software without restriction, including
         | 
| 6 | 
            +
            without limitation the rights to use, copy, modify, merge, publish,
         | 
| 7 | 
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 8 | 
            +
            permit persons to whom the Software is furnished to do so, subject to
         | 
| 9 | 
            +
            the following conditions:
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            The above copyright notice and this permission notice shall be
         | 
| 12 | 
            +
            included in all copies or substantial portions of the Software.
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 15 | 
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 16 | 
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 17 | 
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 18 | 
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 19 | 
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 20 | 
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,60 @@ | |
| 1 | 
            +
            [](https://travis-ci.org/Ortuna/padrino-assets)
         | 
| 2 | 
            +
            [](https://codeclimate.com/github/Ortuna/padrino-assets)
         | 
| 3 | 
            +
             
         | 
| 4 | 
            +
            #padrino-assets
         | 
| 5 | 
            +
            This is an early version and work in progress for padrino pipeline
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            #Usage
         | 
| 8 | 
            +
            include in your padrino project
         | 
| 9 | 
            +
            ```ruby
         | 
| 10 | 
            +
            gem 'padrino-assets', :github => 'Ortuna/padrino-assets'
         | 
| 11 | 
            +
            ```
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            ##Basic usage
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            ```ruby
         | 
| 16 | 
            +
            module Ortuna
         | 
| 17 | 
            +
              class App < Padrino::Application
         | 
| 18 | 
            +
                register Padrino::Assets
         | 
| 19 | 
            +
                configure_assets do |assets|
         | 
| 20 | 
            +
                  assets.pipeline = Padrino::Assets::Sprockets
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
            end
         | 
| 24 | 
            +
            ```
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            This should default app/assets/javascripts and app/assets/stylesheets to be served
         | 
| 27 | 
            +
            from http://localhost:3000/assets/javascripts and http://localhost:3000/assets/styleseets
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            ##Usage with options
         | 
| 30 | 
            +
            ```ruby
         | 
| 31 | 
            +
            module Ortuna
         | 
| 32 | 
            +
              class App < Padrino::Application
         | 
| 33 | 
            +
                register Padrino::Assets
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                configure_assets do |assets|
         | 
| 36 | 
            +
                  assets.pipeline = Padrino::Assets::Sprockets
         | 
| 37 | 
            +
                  assets.paths = ['assets/javascripts', 'assets/stylesheets'] # defaults to assets/stylesheets
         | 
| 38 | 
            +
                  assets.js_prefix = '/custom/location'   # defaults to /assets/javascripts
         | 
| 39 | 
            +
                  assets.css_prefix = '/custom/stylesheets'   # defaults to /assets/stylesheets
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                  assets.prefix = '/trunk' #general prefix, /trunk/assets/javascripts/xyz.js
         | 
| 42 | 
            +
                end
         | 
| 43 | 
            +
              end
         | 
| 44 | 
            +
            end
         | 
| 45 | 
            +
            ```
         | 
| 46 | 
            +
             | 
| 47 | 
            +
            visit `http://localhost:3000/custom/location/app.js` will map to the file
         | 
| 48 | 
            +
            app/assets/javascripts/app.js
         | 
| 49 | 
            +
             | 
| 50 | 
            +
            visit `http://localhost:3000/custom/stylesheets/main.css` will map to the file
         | 
| 51 | 
            +
            app/assets/stylesheets/main.css
         | 
| 52 | 
            +
             | 
| 53 | 
            +
            use sprockets helpers like you would:
         | 
| 54 | 
            +
            ```javascript
         | 
| 55 | 
            +
            //= require stuff
         | 
| 56 | 
            +
            function stuff() {
         | 
| 57 | 
            +
             | 
| 58 | 
            +
            }
         | 
| 59 | 
            +
            ```
         | 
| 60 | 
            +
             | 
    
        data/Rakefile
    ADDED
    
    | @@ -0,0 +1,14 @@ | |
| 1 | 
            +
            # coding:utf-8
         | 
| 2 | 
            +
            RAKE_ROOT = __FILE__
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            require 'rubygems' unless defined?(Gem)
         | 
| 5 | 
            +
            require 'rake'
         | 
| 6 | 
            +
            require 'rake/testtask'
         | 
| 7 | 
            +
            require 'bundler/gem_tasks'
         | 
| 8 | 
            +
            Rake::TestTask.new(:test) do |test|
         | 
| 9 | 
            +
              test.libs << 'test'
         | 
| 10 | 
            +
              test.test_files = Dir['test/**/test_*.rb']
         | 
| 11 | 
            +
              test.verbose = true
         | 
| 12 | 
            +
            end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
            task :default => :test
         | 
| @@ -0,0 +1,18 @@ | |
| 1 | 
            +
            require 'padrino-pipeline/pipelines/sprockets'
         | 
| 2 | 
            +
            require 'padrino-pipeline/pipelines/asset_pack'
         | 
| 3 | 
            +
            require 'ostruct'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            module Padrino
         | 
| 6 | 
            +
              ##
         | 
| 7 | 
            +
              # Add public api docs here
         | 
| 8 | 
            +
              module Pipeline
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                def configure_assets(&block)
         | 
| 11 | 
            +
                  assets = OpenStruct.new
         | 
| 12 | 
            +
                  assets.packages = []
         | 
| 13 | 
            +
                  yield assets if block_given?
         | 
| 14 | 
            +
                  assets.pipeline.new(self, assets)
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
            end
         | 
| @@ -0,0 +1,56 @@ | |
| 1 | 
            +
            require 'sinatra/assetpack' unless defined? Sinatra::AssetPack
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Padrino
         | 
| 4 | 
            +
              module Pipeline
         | 
| 5 | 
            +
                class AssetPack
         | 
| 6 | 
            +
                  def initialize(app, config)
         | 
| 7 | 
            +
                    @app    = app
         | 
| 8 | 
            +
                    @config = config
         | 
| 9 | 
            +
                    setup_enviroment
         | 
| 10 | 
            +
                    setup_pipeline
         | 
| 11 | 
            +
                  end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                  def js_prefix
         | 
| 14 | 
            +
                    (@config.prefix || '') + (@config.js_prefix  || '/assets/javascripts')
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                  def css_prefix
         | 
| 18 | 
            +
                    (@config.prefix || '') + (@config.css_prefix || '/assets/stylesheets')
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                  def js_assets
         | 
| 22 | 
            +
                    @config.js_assets || 'assets/javascripts'
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                  def css_assets
         | 
| 26 | 
            +
                    @config.css_assets || 'assets/stylesheets'
         | 
| 27 | 
            +
                  end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                  def packages
         | 
| 30 | 
            +
                    @config.packages  || []
         | 
| 31 | 
            +
                  end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                  private
         | 
| 34 | 
            +
                  def setup_enviroment
         | 
| 35 | 
            +
                    @app.set :serve_assets, true
         | 
| 36 | 
            +
                    @app.register Sinatra::AssetPack
         | 
| 37 | 
            +
                  end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                  def setup_pipeline
         | 
| 40 | 
            +
                    js_prefix, css_prefix   = self.js_prefix, self.css_prefix
         | 
| 41 | 
            +
                    js_assets, css_assets   = self.js_assets, self.css_assets
         | 
| 42 | 
            +
                    packages                = self.packages
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                    @app.assets {
         | 
| 45 | 
            +
                      serve js_prefix, :from => js_assets
         | 
| 46 | 
            +
                      serve css_prefix,:from => css_assets
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                      packages.each { |package| send(package.shift, *package) } 
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                      js_compression  :uglify
         | 
| 51 | 
            +
                      css_compression :simple
         | 
| 52 | 
            +
                    }
         | 
| 53 | 
            +
                  end
         | 
| 54 | 
            +
                end
         | 
| 55 | 
            +
              end
         | 
| 56 | 
            +
            end
         | 
| @@ -0,0 +1,61 @@ | |
| 1 | 
            +
            require 'sprockets'
         | 
| 2 | 
            +
            require 'uglifier'
         | 
| 3 | 
            +
            require 'padrino-pipeline/ext/padrino-helpers/asset_tag_helper'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            module Padrino
         | 
| 6 | 
            +
              module Pipeline 
         | 
| 7 | 
            +
                class Sprockets
         | 
| 8 | 
            +
                  def initialize(app, config)
         | 
| 9 | 
            +
                    @app    = app
         | 
| 10 | 
            +
                    @config = config
         | 
| 11 | 
            +
                    setup_enviroment
         | 
| 12 | 
            +
                    setup_sprockets
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  private
         | 
| 16 | 
            +
                  def app_root
         | 
| 17 | 
            +
                    @app.settings.root
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  def default_paths
         | 
| 21 | 
            +
                    ["#{app_root}/assets/javascripts", "#{app_root}/assets/stylesheets"]
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                  def setup_sprockets
         | 
| 25 | 
            +
                    @config.paths ||= default_paths
         | 
| 26 | 
            +
                    @config.paths.each { |path| @app.settings.assets.append_path path }
         | 
| 27 | 
            +
                    mount_js_assets  (@config.prefix || '') + (@config.js_prefix  || '/assets/javascripts')
         | 
| 28 | 
            +
                    mount_css_assets (@config.prefix || '') + (@config.css_prefix || '/assets/stylesheets')
         | 
| 29 | 
            +
                  end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                  def setup_enviroment
         | 
| 32 | 
            +
                    @app.set :serve_assets, true
         | 
| 33 | 
            +
                    @app.set :assets, ::Sprockets::Environment.new
         | 
| 34 | 
            +
                    @app.settings.assets.js_compressor  = Uglifier.new(:mangle => true)
         | 
| 35 | 
            +
                  end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                  def mount_js_assets(prefix)
         | 
| 38 | 
            +
                    mount_assets(:prefix => prefix, 
         | 
| 39 | 
            +
                                 :extension => "js",
         | 
| 40 | 
            +
                                 :content_type => "application/javascript")
         | 
| 41 | 
            +
                  end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
                  def mount_css_assets(prefix)
         | 
| 44 | 
            +
                    mount_assets(:prefix => prefix, 
         | 
| 45 | 
            +
                                 :extension => "css",
         | 
| 46 | 
            +
                                 :content_type => "text/css")
         | 
| 47 | 
            +
                  end
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                  def mount_assets(options = {})
         | 
| 50 | 
            +
                    prefix       = options[:prefix]
         | 
| 51 | 
            +
                    extension    = options[:extension]
         | 
| 52 | 
            +
                    content_type = options[:content_type]
         | 
| 53 | 
            +
                    @app.get "#{prefix}/:file.#{extension}" do
         | 
| 54 | 
            +
                      content_type(content_type)
         | 
| 55 | 
            +
                      settings.assets["#{params[:file]}.#{extension}"] || not_found
         | 
| 56 | 
            +
                    end
         | 
| 57 | 
            +
                  end
         | 
| 58 | 
            +
             | 
| 59 | 
            +
                end
         | 
| 60 | 
            +
              end
         | 
| 61 | 
            +
            end
         | 
| @@ -0,0 +1,34 @@ | |
| 1 | 
            +
            #!/usr/bin/env gem build
         | 
| 2 | 
            +
            # encoding: utf-8
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            require File.expand_path("../lib/padrino-pipeline/version.rb", __FILE__)
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Gem::Specification.new do |s|
         | 
| 7 | 
            +
              s.name = "padrino-pipeline"
         | 
| 8 | 
            +
              s.rubyforge_project = "padrino-pipeline"
         | 
| 9 | 
            +
              s.authors = ["Sumeet Singh"]
         | 
| 10 | 
            +
              s.email = "ortuna@gmail.com"
         | 
| 11 | 
            +
              s.summary = "The Padrino asset management system"
         | 
| 12 | 
            +
              s.homepage = "http://www.padrinorb.com"
         | 
| 13 | 
            +
              s.description = "The Padrino asset management system allowing frictionless serving of assets"
         | 
| 14 | 
            +
              s.required_rubygems_version = ">= 1.3.6"
         | 
| 15 | 
            +
              s.version = Padrino::Pipeline::VERSION
         | 
| 16 | 
            +
              s.date = Time.now.strftime("%Y-%m-%d")
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              s.extra_rdoc_files = Dir["*.rdoc"]
         | 
| 19 | 
            +
              s.files         = `git ls-files`.split("\n")
         | 
| 20 | 
            +
              s.test_files    = `git ls-files -- {test,spec,features}/*`.split("\n")
         | 
| 21 | 
            +
              s.executables   = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
         | 
| 22 | 
            +
              s.require_paths = ["lib"]
         | 
| 23 | 
            +
              s.rdoc_options  = ["--charset=UTF-8"]
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              s.add_dependency("padrino-core", "~> 0.11.0")
         | 
| 26 | 
            +
              s.add_dependency("padrino-helpers", "~> 0.11.0")
         | 
| 27 | 
            +
              s.add_dependency("coffee-script", "~> 2.2.0")
         | 
| 28 | 
            +
              s.add_dependency("sass", "~> 3.2.0")
         | 
| 29 | 
            +
              s.add_dependency("sprockets", "~> 2.10.0")
         | 
| 30 | 
            +
              s.add_dependency("uglifier", "~> 2.1.0")
         | 
| 31 | 
            +
             | 
| 32 | 
            +
              s.add_dependency("sinatra-assetpack", "~> 0.2.0")
         | 
| 33 | 
            +
              s.add_dependency("padrino-core", "~> 0.11.0")
         | 
| 34 | 
            +
            end
         | 
| @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            require File.expand_path(File.dirname(__FILE__) + '/../extra/helper')
         | 
| 2 | 
            +
            require File.expand_path(File.dirname(__FILE__) + '/../fixtures/asset_pack_app/asset_pack_app')
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            describe 'AssetPack Stylesheets' do
         | 
| 5 | 
            +
              let(:app) { AssetsAppAssetPack }
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              it 'can get a stylesheet file' do
         | 
| 8 | 
            +
                get '/assets/stylesheets/app.css'
         | 
| 9 | 
            +
                assert_equal 200, last_response.status
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              it 'makes sure that sass is compiled' do
         | 
| 13 | 
            +
                get '/assets/stylesheets/default.css'
         | 
| 14 | 
            +
                assert_equal 200, last_response.status
         | 
| 15 | 
            +
                assert_match ".content {\n  display: none; }\n", last_response.body
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              it 'gives 404 for unknown files' do
         | 
| 19 | 
            +
                get '/assets/stylesheets/omg.css'
         | 
| 20 | 
            +
                assert_equal 404, last_response.status
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
              context 'for non-defualt options' do
         | 
| 24 | 
            +
                let(:app) { AssetsAppAssetPackCustom }
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                it 'can serve from another stylesheets path' do
         | 
| 27 | 
            +
                  get '/meow/stylesheets/meow.css'
         | 
| 28 | 
            +
                  assert_equal 200, last_response.status
         | 
| 29 | 
            +
                  assert_match '.meow', last_response.body 
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
            end
         | 
| @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            require File.expand_path(File.dirname(__FILE__) + '/../extra/helper')
         | 
| 2 | 
            +
            require File.expand_path(File.dirname(__FILE__) + '/../fixtures/asset_pack_app/asset_pack_app')
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            describe 'AssetPack Javascripts' do
         | 
| 5 | 
            +
              let(:app) { AssetsAppAssetPack }
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              it 'can get a javascript file' do
         | 
| 8 | 
            +
                get '/assets/javascripts/app.js'
         | 
| 9 | 
            +
                assert_equal 200, last_response.status
         | 
| 10 | 
            +
                assert_match 'var mainApp = true;', last_response.body
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              it 'makes sure that coffeescript is compiled' do
         | 
| 14 | 
            +
                get '/assets/javascripts/coffee.js'
         | 
| 15 | 
            +
                assert_equal 200, last_response.status
         | 
| 16 | 
            +
                assert_match 'coffee = true', last_response.body
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              it 'gives 404 for unknown files' do
         | 
| 20 | 
            +
                get '/assets/javascripts/omg.js'
         | 
| 21 | 
            +
                assert_equal 404, last_response.status
         | 
| 22 | 
            +
              end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
              context 'for non-defualt options' do
         | 
| 25 | 
            +
                let(:app) { AssetsAppAssetPackCustom }
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                it 'can serve from another javascript path' do
         | 
| 28 | 
            +
                  get '/meow/javascripts/myapp.js'
         | 
| 29 | 
            +
                  assert_equal 200, last_response.status
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
            end
         | 
| @@ -0,0 +1,61 @@ | |
| 1 | 
            +
            require File.expand_path(File.dirname(__FILE__) + '/../extra/helper')
         | 
| 2 | 
            +
            require File.expand_path(File.dirname(__FILE__) + '/../fixtures/asset_pack_app/asset_pack_app')
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            describe 'AssetPack Packages' do
         | 
| 5 | 
            +
              let(:app) { rack_app }
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              context 'for javascripts' do
         | 
| 8 | 
            +
                it 'can serve an asset pack' do
         | 
| 9 | 
            +
                  mock_app do
         | 
| 10 | 
            +
                    register Padrino::Pipeline
         | 
| 11 | 
            +
                    configure_assets do |config|
         | 
| 12 | 
            +
                      config.pipeline   = Padrino::Pipeline::AssetPack
         | 
| 13 | 
            +
                      config.packages << [:js, :application, '/assets/javascripts/application.js', ['/assets/javascripts/*.js']]
         | 
| 14 | 
            +
                    end
         | 
| 15 | 
            +
                  end
         | 
| 16 | 
            +
                  get '/assets/javascripts/application.js' 
         | 
| 17 | 
            +
                  assert_equal 200, last_response.status
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                it 'can serve an asset pack from a non-standard location' do
         | 
| 21 | 
            +
                  mock_app do
         | 
| 22 | 
            +
                    register Padrino::Pipeline
         | 
| 23 | 
            +
                    configure_assets do |config|
         | 
| 24 | 
            +
                      config.pipeline   = Padrino::Pipeline::AssetPack
         | 
| 25 | 
            +
                      config.js_prefix  = '/meow/javascripts'
         | 
| 26 | 
            +
                      config.packages << [:js, :application, '/meow/javascripts/application.js', ['/assets/javascripts/*.js']]
         | 
| 27 | 
            +
                    end
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
                  get '/meow/javascripts/application.js' 
         | 
| 30 | 
            +
                  assert_equal 200, last_response.status
         | 
| 31 | 
            +
                end
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
              context 'for stylesheets' do
         | 
| 35 | 
            +
                it 'can serve an asset pack' do
         | 
| 36 | 
            +
                  mock_app do
         | 
| 37 | 
            +
                    register Padrino::Pipeline
         | 
| 38 | 
            +
                    configure_assets do |config|
         | 
| 39 | 
            +
                      config.pipeline   = Padrino::Pipeline::AssetPack
         | 
| 40 | 
            +
                      config.packages << [:css, :application, '/assets/stylesheets/application.css', ['/assets/stylesheets/*.css']]
         | 
| 41 | 
            +
                    end
         | 
| 42 | 
            +
                  end
         | 
| 43 | 
            +
                  get '/assets/stylesheets/application.css' 
         | 
| 44 | 
            +
                  assert_equal 200, last_response.status
         | 
| 45 | 
            +
                end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                it 'can serve an asset pack from a non-standard location' do
         | 
| 48 | 
            +
                  mock_app do
         | 
| 49 | 
            +
                    register Padrino::Pipeline
         | 
| 50 | 
            +
                    configure_assets do |config|
         | 
| 51 | 
            +
                      config.pipeline   = Padrino::Pipeline::AssetPack
         | 
| 52 | 
            +
                      config.js_prefix  = '/meow/stylesheets'
         | 
| 53 | 
            +
                      config.packages << [:css, :application, '/meow/stylesheets/application.css', ['/assets/stylesheets/*.css']]
         | 
| 54 | 
            +
                    end
         | 
| 55 | 
            +
                  end
         | 
| 56 | 
            +
                  get '/meow/stylesheets/application.css' 
         | 
| 57 | 
            +
                  assert_equal 200, last_response.status
         | 
| 58 | 
            +
                end
         | 
| 59 | 
            +
              end
         | 
| 60 | 
            +
             | 
| 61 | 
            +
            end
         | 
| @@ -0,0 +1,39 @@ | |
| 1 | 
            +
            require File.join(File.dirname(__FILE__), 'mini_shoulda')
         | 
| 2 | 
            +
            require File.join(File.dirname(__FILE__), '..' , 'fixtures', 'sprockets_app', 'sprockets_app')
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            require 'rack/test'
         | 
| 5 | 
            +
            require 'webrat'
         | 
| 6 | 
            +
            require 'padrino-helpers'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            class MiniTest::Spec
         | 
| 9 | 
            +
              include Rack::Test::Methods
         | 
| 10 | 
            +
              include Webrat::Methods
         | 
| 11 | 
            +
              include Webrat::Matchers
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              Webrat.configure { |config| config.mode = :rack }
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              def mock_app(base=Padrino::Application, &block)
         | 
| 16 | 
            +
                @app = Sinatra.new(base, &block)
         | 
| 17 | 
            +
                @app.set :logging, false
         | 
| 18 | 
            +
                @app.set :padrino_logging, false
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              def rack_app
         | 
| 22 | 
            +
                Rack::Lint.new(@app)
         | 
| 23 | 
            +
              end  
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              def fixture_path(fixture)
         | 
| 26 | 
            +
                test_path = File.expand_path(File.dirname(__FILE__) + '/..')
         | 
| 27 | 
            +
                "#{test_path}/fixtures/#{fixture}" 
         | 
| 28 | 
            +
              end
         | 
| 29 | 
            +
            end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            module Webrat
         | 
| 32 | 
            +
              module Logging
         | 
| 33 | 
            +
                def logger # @private
         | 
| 34 | 
            +
                  @logger = nil
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
            end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
             | 
| @@ -0,0 +1,44 @@ | |
| 1 | 
            +
            gem 'minitest'
         | 
| 2 | 
            +
            require 'minitest/autorun'
         | 
| 3 | 
            +
            require 'minitest/spec'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            begin
         | 
| 6 | 
            +
              require 'ruby-debug'
         | 
| 7 | 
            +
            rescue LoadError; end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            class MiniTest::Spec
         | 
| 10 | 
            +
              class << self
         | 
| 11 | 
            +
                alias :setup :before unless defined?(Rails)
         | 
| 12 | 
            +
                alias :teardown :after unless defined?(Rails)
         | 
| 13 | 
            +
                alias :should :it
         | 
| 14 | 
            +
                alias :context :describe
         | 
| 15 | 
            +
                def should_eventually(desc)
         | 
| 16 | 
            +
                  it("should eventually #{desc}") { skip("Should eventually #{desc}") }
         | 
| 17 | 
            +
                end
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
              alias :assert_no_match  :refute_match
         | 
| 20 | 
            +
              alias :assert_not_nil   :refute_nil
         | 
| 21 | 
            +
              alias :assert_not_equal :refute_equal
         | 
| 22 | 
            +
            end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            class ColoredIO
         | 
| 25 | 
            +
              def initialize(io)
         | 
| 26 | 
            +
                @io = io
         | 
| 27 | 
            +
              end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
              def print(o)
         | 
| 30 | 
            +
                case o
         | 
| 31 | 
            +
                when "." then @io.send(:print, o.green)
         | 
| 32 | 
            +
                when "E" then @io.send(:print, o.red)
         | 
| 33 | 
            +
                when "F" then @io.send(:print, o.yellow)
         | 
| 34 | 
            +
                when "S" then @io.send(:print, o.magenta)
         | 
| 35 | 
            +
                else @io.send(:print, o)
         | 
| 36 | 
            +
                end
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              def puts(*o)
         | 
| 40 | 
            +
                super
         | 
| 41 | 
            +
              end
         | 
| 42 | 
            +
            end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
            MiniTest::Unit.output = ColoredIO.new(MiniTest::Unit.output)
         | 
| @@ -0,0 +1,32 @@ | |
| 1 | 
            +
            require 'padrino-core'
         | 
| 2 | 
            +
            require 'padrino-pipeline'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            class BaseApp < Sinatra::Base
         | 
| 5 | 
            +
              register Padrino::Pipeline
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              configure do
         | 
| 8 | 
            +
                set :logging, false
         | 
| 9 | 
            +
                set :padrino_logging, false
         | 
| 10 | 
            +
                set :root, File.dirname(__FILE__)
         | 
| 11 | 
            +
              end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            class AssetsAppAssetPack < BaseApp
         | 
| 16 | 
            +
              configure_assets do |config|
         | 
| 17 | 
            +
                config.pipeline   = Padrino::Pipeline::AssetPack
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
            end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            class AssetsAppAssetPackCustom < BaseApp
         | 
| 22 | 
            +
              configure_assets do |config|
         | 
| 23 | 
            +
                config.pipeline   = Padrino::Pipeline::AssetPack
         | 
| 24 | 
            +
                config.js_prefix  = '/meow/javascripts'
         | 
| 25 | 
            +
                config.js_assets  = '/assets/js' 
         | 
| 26 | 
            +
                
         | 
| 27 | 
            +
                config.css_prefix  = '/meow/stylesheets'
         | 
| 28 | 
            +
                config.css_assets  = '/assets/css' 
         | 
| 29 | 
            +
              end
         | 
| 30 | 
            +
            end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
            Padrino.load!
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            var mainApp = true;
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            @coffee = true
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            var otherFileVar = true;
         | 
| 
            File without changes
         | 
| Binary file | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            cf = 'yes'
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            var in_second_file;
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            var unrequired;
         | 
| 
            File without changes
         | 
| @@ -0,0 +1 @@ | |
| 1 | 
            +
            //= require second_file
         | 
| @@ -0,0 +1,19 @@ | |
| 1 | 
            +
            require 'padrino-core'
         | 
| 2 | 
            +
            require 'padrino-pipeline'
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            class AssetsAppSprockets < Padrino::Application
         | 
| 5 | 
            +
              register Padrino::Pipeline
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              configure do
         | 
| 8 | 
            +
                set :logging, false
         | 
| 9 | 
            +
                set :padrino_logging, false
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              configure_assets do |assets|
         | 
| 13 | 
            +
                assets.pipeline   = Padrino::Pipeline::Sprockets
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
             | 
| 17 | 
            +
            end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            Padrino.load!
         | 
| @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            require File.expand_path(File.dirname(__FILE__) + '/../extra/helper')
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe 'Asset tags' do
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              context 'javascript_include_tag' do
         | 
| 6 | 
            +
                let(:app) { rack_app }
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                it 'can use the default javascript_include_tag to resolve JS asset' do
         | 
| 9 | 
            +
                  skip
         | 
| 10 | 
            +
                  assets_location = "#{fixture_path('sprockets_app')}/assets/javascripts"
         | 
| 11 | 
            +
                  mock_app do
         | 
| 12 | 
            +
                    register Padrino::Pipeline
         | 
| 13 | 
            +
                    register Padrino::Helpers
         | 
| 14 | 
            +
                    configure_assets do |assets| 
         | 
| 15 | 
            +
                      assets.pipeline = Padrino::Pipeline::Sprockets
         | 
| 16 | 
            +
                      assets.paths    = [assets_location]
         | 
| 17 | 
            +
                    end
         | 
| 18 | 
            +
                    get('/') { render :erb, "<%= javascript_include_tag 'app.js' %>" }
         | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                  get '/'
         | 
| 22 | 
            +
                  assert_equal '/assets/javascripts/app.js', last_response.body
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              end
         | 
| 26 | 
            +
            end
         | 
| 27 | 
            +
             | 
| @@ -0,0 +1,40 @@ | |
| 1 | 
            +
            require File.expand_path(File.dirname(__FILE__) + '/../extra/helper')
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Padrino::Pipeline do
         | 
| 4 | 
            +
              let(:app) { AssetsAppSprockets }
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              context 'for application behavior' do
         | 
| 7 | 
            +
                it 'knows that assets should be served' do
         | 
| 8 | 
            +
                  assert_equal app.serve_assets?, true
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                it 'detects the root location of the running app' do
         | 
| 12 | 
            +
                  app_path = fixture_path('sprockets_app')
         | 
| 13 | 
            +
                  assert_equal app_path, app.root
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              context 'general options' do
         | 
| 18 | 
            +
                let(:app) { rack_app }
         | 
| 19 | 
            +
                
         | 
| 20 | 
            +
                before do
         | 
| 21 | 
            +
                 @assets_location = "#{fixture_path('sprockets_app')}/assets/javascripts"
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                it 'can set a general prefix for all asset types' do
         | 
| 25 | 
            +
                  assets_location = @assets_location
         | 
| 26 | 
            +
                  mock_app do
         | 
| 27 | 
            +
                    register Padrino::Pipeline
         | 
| 28 | 
            +
                    configure_assets do |assets|
         | 
| 29 | 
            +
                      assets.pipeline = Padrino::Pipeline::Sprockets
         | 
| 30 | 
            +
                      assets.paths    = [assets_location]
         | 
| 31 | 
            +
                      assets.prefix   = '/trunk'
         | 
| 32 | 
            +
                    end
         | 
| 33 | 
            +
                  end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                  get '/trunk/assets/javascripts/app.js'
         | 
| 36 | 
            +
                  assert_equal 200, last_response.status
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
              end
         | 
| 39 | 
            +
             | 
| 40 | 
            +
            end#describe
         | 
| @@ -0,0 +1,68 @@ | |
| 1 | 
            +
            require File.expand_path(File.dirname(__FILE__) + '/../extra/helper')
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe 'Stylesheets' do
         | 
| 4 | 
            +
              let(:app) { AssetsAppSprockets }
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              context 'for css assets' do
         | 
| 7 | 
            +
                it 'can retrieve an css asset by file name' do
         | 
| 8 | 
            +
                  get '/assets/stylesheets/application.css'
         | 
| 9 | 
            +
                  assert_equal 200, last_response.status
         | 
| 10 | 
            +
                end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                it 'is the right content type' do
         | 
| 13 | 
            +
                  get '/assets/stylesheets/application.css'
         | 
| 14 | 
            +
                  assert_match 'text/css', last_response.content_type
         | 
| 15 | 
            +
                end    
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                it 'works with directives' do
         | 
| 18 | 
            +
                  get '/assets/stylesheets/application.css'
         | 
| 19 | 
            +
                  assert_match '.home {', last_response.body
         | 
| 20 | 
            +
                end
         | 
| 21 | 
            +
             
         | 
| 22 | 
            +
                context 'for SASS assets' do
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                  it 'can retrieve a .scss asset by file name' do
         | 
| 25 | 
            +
                    get '/assets/stylesheets/sass.css'
         | 
| 26 | 
            +
                    assert_match 'body .div', last_response.body
         | 
| 27 | 
            +
                  end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                context 'for custom options' do
         | 
| 32 | 
            +
                  let(:app) { rack_app }
         | 
| 33 | 
            +
                  before do
         | 
| 34 | 
            +
                    @assets_location = "#{fixture_path('sprockets_app')}/assets/stylesheets"
         | 
| 35 | 
            +
                  end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                  it 'can modify the default asset path by configuration' do
         | 
| 38 | 
            +
                    assets_location = "#{fixture_path('sprockets_app')}/assets/other"
         | 
| 39 | 
            +
                    mock_app do
         | 
| 40 | 
            +
                      register Padrino::Pipeline
         | 
| 41 | 
            +
                      configure_assets do |assets|
         | 
| 42 | 
            +
                        assets.pipeline = Padrino::Pipeline::Sprockets
         | 
| 43 | 
            +
                        assets.paths    = [assets_location]
         | 
| 44 | 
            +
                      end
         | 
| 45 | 
            +
                    end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                    get '/assets/stylesheets/other.css'
         | 
| 48 | 
            +
                    assert_equal 200, last_response.status
         | 
| 49 | 
            +
                  end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
                  it 'can modify the default css prefix by configuration' do
         | 
| 52 | 
            +
                    assets_location = @assets_location
         | 
| 53 | 
            +
                    mock_app do
         | 
| 54 | 
            +
                      register Padrino::Pipeline
         | 
| 55 | 
            +
                      configure_assets do |assets|
         | 
| 56 | 
            +
                        assets.pipeline = Padrino::Pipeline::Sprockets
         | 
| 57 | 
            +
                        assets.paths      = [assets_location]
         | 
| 58 | 
            +
                        assets.css_prefix = '/myassets/items'
         | 
| 59 | 
            +
                      end
         | 
| 60 | 
            +
                    end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                    get '/myassets/items/application.css'
         | 
| 63 | 
            +
                    assert_equal 200, last_response.status
         | 
| 64 | 
            +
                  end
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                end #context
         | 
| 67 | 
            +
              end #context
         | 
| 68 | 
            +
            end #describe
         | 
| @@ -0,0 +1,79 @@ | |
| 1 | 
            +
            require File.expand_path(File.dirname(__FILE__) + '/../extra/helper')
         | 
| 2 | 
            +
            require File.expand_path(File.dirname(__FILE__) + '/../fixtures/sprockets_app/sprockets_app')
         | 
| 3 | 
            +
             | 
| 4 | 
            +
             | 
| 5 | 
            +
            describe 'Javascripts' do
         | 
| 6 | 
            +
              let(:app) { AssetsAppSprockets }
         | 
| 7 | 
            +
              context 'for coffeescript assets' do
         | 
| 8 | 
            +
                it 'can get a coffeescript' do
         | 
| 9 | 
            +
                  get '/assets/javascripts/coffee.js'
         | 
| 10 | 
            +
                  assert_equal 200, last_response.status
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                it 'is compiled' do 
         | 
| 14 | 
            +
                  get '/assets/javascripts/coffee.js'
         | 
| 15 | 
            +
                  assert_match 'a="yes"', last_response.body
         | 
| 16 | 
            +
                end
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              context 'for javascript assets' do
         | 
| 20 | 
            +
                it 'can retrieve a js asset by file name' do
         | 
| 21 | 
            +
                  get '/assets/javascripts/unrequired.js'
         | 
| 22 | 
            +
                  assert_match 'var unrequired;', last_response.body
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                it 'is the right content type' do
         | 
| 26 | 
            +
                  get '/assets/javascripts/unrequired.js'
         | 
| 27 | 
            +
                  assert_match 'application/javascript', last_response.content_type
         | 
| 28 | 
            +
                end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                it 'shows a 404 for unkown assets' do
         | 
| 31 | 
            +
                  get '/assets/javascripts/xyz.js'
         | 
| 32 | 
            +
                  assert_not_equal 200, last_response.status
         | 
| 33 | 
            +
                end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                context 'for //= require' do
         | 
| 36 | 
            +
                  it 'picks up require statements' do
         | 
| 37 | 
            +
                    get '/assets/javascripts/app.js'
         | 
| 38 | 
            +
                    assert_match 'var in_second_file;', last_response.body
         | 
| 39 | 
            +
                  end
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
             | 
| 42 | 
            +
                context 'for custom options' do
         | 
| 43 | 
            +
                  let(:app) { rack_app }
         | 
| 44 | 
            +
                  before do
         | 
| 45 | 
            +
                  @assets_location =  "#{fixture_path('sprockets_app')}/assets/javascripts"
         | 
| 46 | 
            +
                  end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
                  it '#append_asset_path' do
         | 
| 49 | 
            +
                    assets_location = @assets_location
         | 
| 50 | 
            +
                    mock_app do
         | 
| 51 | 
            +
                      register Padrino::Pipeline
         | 
| 52 | 
            +
                      configure_assets do |assets| 
         | 
| 53 | 
            +
                        assets.pipeline = Padrino::Pipeline::Sprockets
         | 
| 54 | 
            +
                        assets.paths    = [assets_location]
         | 
| 55 | 
            +
                      end
         | 
| 56 | 
            +
                    end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                    get '/assets/javascripts/app.js'
         | 
| 59 | 
            +
                    assert_match 'var in_second_file', last_response.body
         | 
| 60 | 
            +
                  end
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                  it '#js_prefix mounts assets to the correct spot' do
         | 
| 63 | 
            +
                    assets_location = @assets_location
         | 
| 64 | 
            +
                    mock_app do
         | 
| 65 | 
            +
                      register Padrino::Pipeline
         | 
| 66 | 
            +
                      configure_assets do |assets|
         | 
| 67 | 
            +
                        assets.pipeline  = Padrino::Pipeline::Sprockets
         | 
| 68 | 
            +
                        assets.paths     = [assets_location]
         | 
| 69 | 
            +
                        assets.js_prefix = '/custom/location'
         | 
| 70 | 
            +
                      end
         | 
| 71 | 
            +
                    end#mock-app
         | 
| 72 | 
            +
                    get '/custom/location/app.js'
         | 
| 73 | 
            +
                    assert_match 'var in_second_file', last_response.body
         | 
| 74 | 
            +
                    assert_equal 200, last_response.status
         | 
| 75 | 
            +
                  end
         | 
| 76 | 
            +
             | 
| 77 | 
            +
                end#context
         | 
| 78 | 
            +
              end#context
         | 
| 79 | 
            +
            end#describe
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,223 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: padrino-pipeline
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.2.0
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Sumeet Singh
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2013-06-08 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: padrino-core
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - ~>
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: 0.11.0
         | 
| 20 | 
            +
              type: :runtime
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - ~>
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: 0.11.0
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: padrino-helpers
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - ~>
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: 0.11.0
         | 
| 34 | 
            +
              type: :runtime
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - ~>
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: 0.11.0
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: coffee-script
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - ~>
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: 2.2.0
         | 
| 48 | 
            +
              type: :runtime
         | 
| 49 | 
            +
              prerelease: false
         | 
| 50 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - ~>
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: 2.2.0
         | 
| 55 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            +
              name: sass
         | 
| 57 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - ~>
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: 3.2.0
         | 
| 62 | 
            +
              type: :runtime
         | 
| 63 | 
            +
              prerelease: false
         | 
| 64 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                requirements:
         | 
| 66 | 
            +
                - - ~>
         | 
| 67 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            +
                    version: 3.2.0
         | 
| 69 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 70 | 
            +
              name: sprockets
         | 
| 71 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 | 
            +
                requirements:
         | 
| 73 | 
            +
                - - ~>
         | 
| 74 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 75 | 
            +
                    version: 2.10.0
         | 
| 76 | 
            +
              type: :runtime
         | 
| 77 | 
            +
              prerelease: false
         | 
| 78 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 | 
            +
                requirements:
         | 
| 80 | 
            +
                - - ~>
         | 
| 81 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 82 | 
            +
                    version: 2.10.0
         | 
| 83 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 84 | 
            +
              name: uglifier
         | 
| 85 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 86 | 
            +
                requirements:
         | 
| 87 | 
            +
                - - ~>
         | 
| 88 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 89 | 
            +
                    version: 2.1.0
         | 
| 90 | 
            +
              type: :runtime
         | 
| 91 | 
            +
              prerelease: false
         | 
| 92 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 93 | 
            +
                requirements:
         | 
| 94 | 
            +
                - - ~>
         | 
| 95 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 96 | 
            +
                    version: 2.1.0
         | 
| 97 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 98 | 
            +
              name: sinatra-assetpack
         | 
| 99 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 100 | 
            +
                requirements:
         | 
| 101 | 
            +
                - - ~>
         | 
| 102 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 103 | 
            +
                    version: 0.2.0
         | 
| 104 | 
            +
              type: :runtime
         | 
| 105 | 
            +
              prerelease: false
         | 
| 106 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 107 | 
            +
                requirements:
         | 
| 108 | 
            +
                - - ~>
         | 
| 109 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 110 | 
            +
                    version: 0.2.0
         | 
| 111 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 112 | 
            +
              name: padrino-core
         | 
| 113 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 114 | 
            +
                requirements:
         | 
| 115 | 
            +
                - - ~>
         | 
| 116 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 117 | 
            +
                    version: 0.11.0
         | 
| 118 | 
            +
              type: :runtime
         | 
| 119 | 
            +
              prerelease: false
         | 
| 120 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 121 | 
            +
                requirements:
         | 
| 122 | 
            +
                - - ~>
         | 
| 123 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 124 | 
            +
                    version: 0.11.0
         | 
| 125 | 
            +
            description: The Padrino asset management system allowing frictionless serving of
         | 
| 126 | 
            +
              assets
         | 
| 127 | 
            +
            email: ortuna@gmail.com
         | 
| 128 | 
            +
            executables: []
         | 
| 129 | 
            +
            extensions: []
         | 
| 130 | 
            +
            extra_rdoc_files: []
         | 
| 131 | 
            +
            files:
         | 
| 132 | 
            +
            - .gitignore
         | 
| 133 | 
            +
            - .travis.yml
         | 
| 134 | 
            +
            - Gemfile
         | 
| 135 | 
            +
            - LICENSE.txt
         | 
| 136 | 
            +
            - README.md
         | 
| 137 | 
            +
            - Rakefile
         | 
| 138 | 
            +
            - lib/padrino-pipeline.rb
         | 
| 139 | 
            +
            - lib/padrino-pipeline/ext/padrino-helpers/asset_tag_helper.rb
         | 
| 140 | 
            +
            - lib/padrino-pipeline/pipelines/asset_pack.rb
         | 
| 141 | 
            +
            - lib/padrino-pipeline/pipelines/sprockets.rb
         | 
| 142 | 
            +
            - lib/padrino-pipeline/version.rb
         | 
| 143 | 
            +
            - padrino-pipeline.gemspec
         | 
| 144 | 
            +
            - test/asset_pack/test_css.rb
         | 
| 145 | 
            +
            - test/asset_pack/test_js.rb
         | 
| 146 | 
            +
            - test/asset_pack/test_packages.rb
         | 
| 147 | 
            +
            - test/extra/helper.rb
         | 
| 148 | 
            +
            - test/extra/mini_shoulda.rb
         | 
| 149 | 
            +
            - test/fixtures/asset_pack_app/asset_pack_app.rb
         | 
| 150 | 
            +
            - test/fixtures/asset_pack_app/assets/css/meow.css
         | 
| 151 | 
            +
            - test/fixtures/asset_pack_app/assets/javascripts/app.js
         | 
| 152 | 
            +
            - test/fixtures/asset_pack_app/assets/javascripts/coffee.coffee
         | 
| 153 | 
            +
            - test/fixtures/asset_pack_app/assets/javascripts/other.js
         | 
| 154 | 
            +
            - test/fixtures/asset_pack_app/assets/js/myapp.js
         | 
| 155 | 
            +
            - test/fixtures/asset_pack_app/assets/stylesheets/app.css
         | 
| 156 | 
            +
            - test/fixtures/asset_pack_app/assets/stylesheets/default.scss
         | 
| 157 | 
            +
            - test/fixtures/sprockets_app/assets/images/glass.png
         | 
| 158 | 
            +
            - test/fixtures/sprockets_app/assets/javascripts/app.js
         | 
| 159 | 
            +
            - test/fixtures/sprockets_app/assets/javascripts/coffee.js.coffee
         | 
| 160 | 
            +
            - test/fixtures/sprockets_app/assets/javascripts/second_js_file.js
         | 
| 161 | 
            +
            - test/fixtures/sprockets_app/assets/javascripts/unrequired.js
         | 
| 162 | 
            +
            - test/fixtures/sprockets_app/assets/other/other.css
         | 
| 163 | 
            +
            - test/fixtures/sprockets_app/assets/stylesheets/application.css
         | 
| 164 | 
            +
            - test/fixtures/sprockets_app/assets/stylesheets/sass.scss
         | 
| 165 | 
            +
            - test/fixtures/sprockets_app/assets/stylesheets/second_file.css
         | 
| 166 | 
            +
            - test/fixtures/sprockets_app/sprockets_app.rb
         | 
| 167 | 
            +
            - test/sprockets/test_asset_tag.rb
         | 
| 168 | 
            +
            - test/sprockets/test_assets.rb
         | 
| 169 | 
            +
            - test/sprockets/test_css.rb
         | 
| 170 | 
            +
            - test/sprockets/test_js.rb
         | 
| 171 | 
            +
            homepage: http://www.padrinorb.com
         | 
| 172 | 
            +
            licenses: []
         | 
| 173 | 
            +
            metadata: {}
         | 
| 174 | 
            +
            post_install_message: 
         | 
| 175 | 
            +
            rdoc_options:
         | 
| 176 | 
            +
            - --charset=UTF-8
         | 
| 177 | 
            +
            require_paths:
         | 
| 178 | 
            +
            - lib
         | 
| 179 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 180 | 
            +
              requirements:
         | 
| 181 | 
            +
              - - '>='
         | 
| 182 | 
            +
                - !ruby/object:Gem::Version
         | 
| 183 | 
            +
                  version: '0'
         | 
| 184 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 185 | 
            +
              requirements:
         | 
| 186 | 
            +
              - - '>='
         | 
| 187 | 
            +
                - !ruby/object:Gem::Version
         | 
| 188 | 
            +
                  version: 1.3.6
         | 
| 189 | 
            +
            requirements: []
         | 
| 190 | 
            +
            rubyforge_project: padrino-pipeline
         | 
| 191 | 
            +
            rubygems_version: 2.0.2
         | 
| 192 | 
            +
            signing_key: 
         | 
| 193 | 
            +
            specification_version: 4
         | 
| 194 | 
            +
            summary: The Padrino asset management system
         | 
| 195 | 
            +
            test_files:
         | 
| 196 | 
            +
            - test/asset_pack/test_css.rb
         | 
| 197 | 
            +
            - test/asset_pack/test_js.rb
         | 
| 198 | 
            +
            - test/asset_pack/test_packages.rb
         | 
| 199 | 
            +
            - test/extra/helper.rb
         | 
| 200 | 
            +
            - test/extra/mini_shoulda.rb
         | 
| 201 | 
            +
            - test/fixtures/asset_pack_app/asset_pack_app.rb
         | 
| 202 | 
            +
            - test/fixtures/asset_pack_app/assets/css/meow.css
         | 
| 203 | 
            +
            - test/fixtures/asset_pack_app/assets/javascripts/app.js
         | 
| 204 | 
            +
            - test/fixtures/asset_pack_app/assets/javascripts/coffee.coffee
         | 
| 205 | 
            +
            - test/fixtures/asset_pack_app/assets/javascripts/other.js
         | 
| 206 | 
            +
            - test/fixtures/asset_pack_app/assets/js/myapp.js
         | 
| 207 | 
            +
            - test/fixtures/asset_pack_app/assets/stylesheets/app.css
         | 
| 208 | 
            +
            - test/fixtures/asset_pack_app/assets/stylesheets/default.scss
         | 
| 209 | 
            +
            - test/fixtures/sprockets_app/assets/images/glass.png
         | 
| 210 | 
            +
            - test/fixtures/sprockets_app/assets/javascripts/app.js
         | 
| 211 | 
            +
            - test/fixtures/sprockets_app/assets/javascripts/coffee.js.coffee
         | 
| 212 | 
            +
            - test/fixtures/sprockets_app/assets/javascripts/second_js_file.js
         | 
| 213 | 
            +
            - test/fixtures/sprockets_app/assets/javascripts/unrequired.js
         | 
| 214 | 
            +
            - test/fixtures/sprockets_app/assets/other/other.css
         | 
| 215 | 
            +
            - test/fixtures/sprockets_app/assets/stylesheets/application.css
         | 
| 216 | 
            +
            - test/fixtures/sprockets_app/assets/stylesheets/sass.scss
         | 
| 217 | 
            +
            - test/fixtures/sprockets_app/assets/stylesheets/second_file.css
         | 
| 218 | 
            +
            - test/fixtures/sprockets_app/sprockets_app.rb
         | 
| 219 | 
            +
            - test/sprockets/test_asset_tag.rb
         | 
| 220 | 
            +
            - test/sprockets/test_assets.rb
         | 
| 221 | 
            +
            - test/sprockets/test_css.rb
         | 
| 222 | 
            +
            - test/sprockets/test_js.rb
         | 
| 223 | 
            +
            has_rdoc: 
         |