Module: Roda::RodaPlugins::SprocketAssets::RequestMethods

Defined in:
lib/roda/plugins/sprocket_assets.rb

Instance Method Summary collapse

Instance Method Details

#sprocket_assetsObject



97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/roda/plugins/sprocket_assets.rb', line 97

def sprocket_assets
  scope.class.configure :test, :development do
    get self.class.sprocket_assets_regexp do |path|
      opts                       = scope.sprocket_assets_opts
      env_sprockets              = scope.request.env.dup
      env_sprockets['PATH_INFO'] = path

      status, headers, response = opts[:sprockets].call env_sprockets

      scope.response.status = status
      scope.response.headers.merge! headers
      response.is_a?(Array) ? response.join('\n') : response.to_s
    end
  end
end