lib/roda/plugins/public.rb in roda-2.29.0 vs lib/roda/plugins/public.rb in roda-3.0.0
- old
+ new
@@ -8,27 +8,24 @@
# The public plugin adds a +r.public+ routing method to serve static files
# from a directory.
#
# The public plugin recognizes the application's :root option, and defaults to
# using the +public+ subfolder of the application's +:root+ option. If the application's
- # :root option is not set, it defaults to the the +public+ folder in the working
+ # :root option is not set, it defaults to the +public+ folder in the working
# directory. Additionally, if a relative path is provided as the :root
# option to the plugin, it will be considered relative to the application's
# +:root+ option.
#
# Examples:
#
# opts[:root] = '/path/to/app'
# plugin :public
- # plugin :public, :root=>'static'
+ # plugin :public, root: 'static'
module Public
SPLIT = Regexp.union(*[File::SEPARATOR, File::ALT_SEPARATOR].compact)
- PARSER = RUBY_VERSION >= '1.9' ? URI::DEFAULT_PARSER : URI
+ PARSER = URI::DEFAULT_PARSER
- NULL_BYTE = "\0".freeze
- RodaPlugins.deprecate_constant(self, :NULL_BYTE)
-
# Use options given to setup a Rack::File instance for serving files. Options:
# :default_mime :: The default mime type to use if the mime type is not recognized.
# :gzip :: Whether to serve already gzipped files with a .gz extension for clients
# supporting gzipped transfer encoding.
# :headers :: A hash of headers to use for statically served files
@@ -95,21 +92,21 @@
false
# :nocov:
end
if ::Rack.release > '2'
- # :nocov:
+ # Serve the given path using the given Rack::File server.
def public_serve(server, path)
server.serving(self, path)
end
- # :nocov:
else
- # Serve the given path using the given Rack::File server.
+ # :nocov:
def public_serve(server, path)
server = server.dup
server.path = path
server.serving(env)
end
+ # :nocov:
end
end
end
register_plugin(:public, Public)