class Pannier::App
Attributes
behaviors[R]
env[R]
input_path[R]
logger[R]
mount_path[R]
output_path[R]
packages[R]
Public Class Methods
new(env_name = 'development')
click to toggle source
# File lib/pannier/app.rb, line 16 def initialize(env_name = 'development') @env = Environment.new(env_name) @behaviors, @packages, @root = {}, [], '/' end
Public Instance Methods
[](package_name)
click to toggle source
# File lib/pannier/app.rb, line 37 def [](package_name) @packages.find { |pkg| pkg.name == package_name } end
add_behavior(name, &block)
click to toggle source
# File lib/pannier/app.rb, line 92 def add_behavior(name, &block) self.behaviors[name] = block end
add_package(package)
click to toggle source
# File lib/pannier/app.rb, line 33 def add_package(package) @packages << package end
behavior(name, &block)
click to toggle source
# File lib/pannier/app.rb, line 78 def behavior(name, &block) add_behavior(name, &block) end
call(env)
click to toggle source
# File lib/pannier/mounted/app.rb, line 33 def call(env) handler.call(env) end
clobber!()
click to toggle source
# File lib/pannier/app.rb, line 45 def clobber! manifest_writer.clobber!(@input_path) @packages.each(&:clobber!) end
handler()
click to toggle source
# File lib/pannier/mounted/app.rb, line 29 def handler Rack::URLMap.new(handler_map) end
handler_map()
click to toggle source
# File lib/pannier/mounted/app.rb, line 21 def handler_map @packages.reduce({}) do |hash, pkg| hash[pkg.handler_path] ||= Rack::Cascade.new([]) hash[pkg.handler_path].add(pkg.handler) hash end end
input(path)
click to toggle source
# File lib/pannier/app.rb, line 66 def input(path) set_input(path) end
manifest_writer()
click to toggle source
# File lib/pannier/app.rb, line 41 def manifest_writer @manifest_writer ||= ManifestWriter.new(self, @env) end
mount(*)
click to toggle source
# File lib/pannier/app.rb, line 86 def mount(*) # see pannier/mounted/app end
output(path)
click to toggle source
# File lib/pannier/app.rb, line 70 def output(path) set_output(path) end
package(name, &block)
click to toggle source
# File lib/pannier/app.rb, line 82 def package(name, &block) add_package(Package.build(name, __getobj__, &block)) end
prime!(manifest)
click to toggle source
# File lib/pannier/mounted/app.rb, line 12 def prime!(manifest) manifest.each do |name, paths| if (pkg = self[name]) assets = pkg.build_assets_from_paths(paths) pkg.add_output_assets(assets) end end end
process!()
click to toggle source
# File lib/pannier/app.rb, line 50 def process! @packages.each(&:process!) manifest_writer.write!(@input_path) end
process_owners!(*paths)
click to toggle source
# File lib/pannier/app.rb, line 55 def process_owners!(*paths) pkgs = @packages.select { |pkg| pkg.owns_any?(*paths) } pkgs.each(&:process!) end
set_input(path)
click to toggle source
# File lib/pannier/app.rb, line 21 def set_input(path) @input_path = File.expand_path(path) end
set_logger(logger)
click to toggle source
# File lib/pannier/app.rb, line 29 def set_logger(logger) @logger = logger end
set_mount_path(path)
click to toggle source
# File lib/pannier/mounted/app.rb, line 8 def set_mount_path(path) @mount_path = path end
set_output(path)
click to toggle source
# File lib/pannier/app.rb, line 25 def set_output(path) @output_path = File.expand_path(path) end