Class: Appetizer::Rack::Splash
- Inherits:
-
Object
- Object
- Appetizer::Rack::Splash
- Defined in:
- lib/appetizer/rack/splash.rb
Class Method Summary collapse
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(root = "public", glob = "**/*", ¬found) ⇒ Splash
constructor
A new instance of Splash.
Constructor Details
#initialize(root = "public", glob = "**/*", ¬found) ⇒ Splash
Returns a new instance of Splash.
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/appetizer/rack/splash.rb', line 4 def initialize root = "public", glob = "**/*", ¬found notfound ||= lambda { |env| [404, { "Content-Type" => "text/plain" }, []] } urls = Dir[File.join root, glob].sort. select { |f| File.file? f }. map { |f| f[root.length..-1] } @static = ::Rack::Static.new notfound, root: root, urls: urls end |
Class Method Details
.call(env) ⇒ Object
24 25 26 |
# File 'lib/appetizer/rack/splash.rb', line 24 def self.call env new.call env end |
Instance Method Details
#call(env) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/appetizer/rack/splash.rb', line 16 def call env if env["PATH_INFO"] == "/" env["PATH_INFO"] = "/index.html" end @static.call env end |