Class: Ella::Pipeline
- Inherits:
-
Object
- Object
- Ella::Pipeline
- Defined in:
- lib/ella/pipeline.rb
Overview
Custom made super-simple assets pipeline. This KISS philosophy of this pipeline is:
"data from files" --> "user defined filter in Ruby" --> "output file"
Of course, Ella is modular, so the user should be able to disable it and set up their own assets pipeline of choice.
Instance Method Summary collapse
-
#initialize(pipeline_type) ⇒ Pipeline
constructor
A new instance of Pipeline.
-
#listen ⇒ Object
Because this is user-defined code, any exception is possible.
- #run ⇒ Object
Constructor Details
#initialize(pipeline_type) ⇒ Pipeline
Returns a new instance of Pipeline.
27 28 29 30 31 32 33 34 |
# File 'lib/ella/pipeline.rb', line 27 def initialize(pipeline_type) @type = pipeline_type Log.info("Initializing #{@type.upcase} pipeline...") set_io_directories initialize_tempfile load File.join(Dir.pwd, "configs/#{@type}.rb") end |
Instance Method Details
#listen ⇒ Object
Because this is user-defined code, any exception is possible. Having to restart the development server every time there is some error in the filter is NOT DESIRABLE.
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ella/pipeline.rb', line 39 def listen run # Public files are not persistent, so this must be run on startup. @listener = Listen.to(@input_dir) do |modified, added, removed| report_listen_results(modified, added, removed) run rescue => e report_listen_error(e) end @listener.start end |
#run ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/ella/pipeline.rb', line 50 def run @tempfile.close @tempfile.unlink @tempfile = Tempfile.new(['', ".#{@type}"], @output_dir) @tempfile.write(filter) @tempfile.rewind end |