Class: Rack::ScriptStackerUtils::Runner
- Inherits:
-
Object
- Object
- Rack::ScriptStackerUtils::Runner
- Defined in:
- lib/rack/scriptstacker.rb
Instance Method Summary collapse
-
#initialize(stacker_configs, inject_mode) ⇒ Runner
constructor
A new instance of Runner.
- #replace_in_body(body, path_specs) ⇒ Object
Constructor Details
#initialize(stacker_configs, inject_mode) ⇒ Runner
158 159 160 161 |
# File 'lib/rack/scriptstacker.rb', line 158 def initialize stacker_configs, inject_mode @stacker_configs = stacker_configs @inject_mode = inject_mode end |
Instance Method Details
#replace_in_body(body, path_specs) ⇒ Object
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/rack/scriptstacker.rb', line 163 def replace_in_body body, path_specs stackers = @stacker_configs.select do |name, config| !config[:skip_stack] end.map do |name, config| [name, Stacker.new(config)] end.to_h path_specs.select do |name, specs| stackers.has_key? name end.each do |name, specs| specs.each do |spec| stackers[name].find_files spec.source_path, spec.serve_path end end body.map do |chunk| stackers.values.reduce chunk do |memo, stacker| inject_into memo, stacker end end end |