Class: RackPipeline::Base
- Inherits:
-
Object
- Object
- RackPipeline::Base
- Includes:
- Caching, Processing
- Defined in:
- lib/rack-pipeline/base.rb
Constant Summary collapse
- STATIC_TYPES =
{ '.js' => :js, '.css' => :css }.freeze
- CONTENT_TYPES =
{ '.js' => 'application/javascript', '.css' => 'text/css' }.freeze
Instance Attribute Summary collapse
-
#assets ⇒ Object
Returns the value of attribute assets.
-
#settings ⇒ Object
Returns the value of attribute settings.
Instance Method Summary collapse
- #assets_for(pipes, type, opts = {}) ⇒ Object
- #call(env) ⇒ Object
-
#initialize(app, *args) ⇒ Base
constructor
A new instance of Base.
- #inspect ⇒ Object
Methods included from Processing
#combine, #combine?, #compile, #compress
Methods included from Caching
#cache_target, #calculate_hash, #cleanup_cache, #create_temp_directory
Constructor Details
#initialize(app, *args) ⇒ Base
Returns a new instance of Base.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rack-pipeline/base.rb', line 24 def initialize(app, *args) @generations = 0 @assets = {} @settings = { :temp => nil, :compress => false, :combine => false, :css => { :app => 'assets/**/*.css', }, :js => { :app => 'assets/**/*.js', }, } @settings.merge!(args.pop) if args.last.kind_of?(Hash) create_temp_directory populate_pipelines @app = app end |
Instance Attribute Details
#assets ⇒ Object
Returns the value of attribute assets.
13 14 15 |
# File 'lib/rack-pipeline/base.rb', line 13 def assets @assets end |
#settings ⇒ Object
Returns the value of attribute settings.
13 14 15 |
# File 'lib/rack-pipeline/base.rb', line 13 def settings @settings end |
Instance Method Details
#assets_for(pipes, type, opts = {}) ⇒ Object
18 19 20 21 22 |
# File 'lib/rack-pipeline/base.rb', line 18 def assets_for(pipes, type, opts = {}) Array(pipes).inject([]) do |all,pipe| all += Array(combine? ? "#{pipe}.#{type}" : assets[type][pipe].keys) end.compact.uniq end |
#call(env) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rack-pipeline/base.rb', line 48 def call(env) env['rack-pipeline'] = self if file_path = prepare_pipe(env['PATH_INFO']) serve_file(file_path, env['HTTP_IF_MODIFIED_SINCE']) else @app.call(env) end rescue MustRepopulate populate_pipelines retry end |
#inspect ⇒ Object
44 45 46 |
# File 'lib/rack-pipeline/base.rb', line 44 def inspect { :settings => settings, :assets => assets } end |