/usr/bin/merb-slice is in merb-slices 1.0.12+dfsg-4fakesync1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | #! /usr/bin/ruby1.8
__DIR__ = Dir.pwd
require 'rubygems'
require 'merb-core'
require 'merb-slices'
slice_name = File.basename(__DIR__)
Merb::Config.use { |c|
c[:framework] = { :public => [Merb.root / "public", nil] }
c[:session_store] = 'none'
c[:exception_details] = true
}
if File.exists?(slice_file = File.join(__DIR__, 'lib', "#{slice_name}.rb"))
Merb::BootLoader.before_app_loads do
$SLICE_MODULE = Merb::Slices.filename2module(slice_file)
require slice_file
end
Merb::BootLoader.after_app_loads do
# See Merb::Slices::ModuleMixin - $SLICE_MODULE is used as a flag
Merb::Router.prepare do
slice($SLICE_MODULE)
slice_id = slice_name.gsub('-', '_').to_sym
slice_routes = Merb::Slices.named_routes[slice_id] || {}
# Setup a / root path matching route - try several defaults
route = slice_routes[:home] || slice_routes[:index]
if route
params = route.params.inject({}) do |hsh,(k,v)|
hsh[k] = v.gsub("\"", '') if k == :controller || k == :action
hsh
end
match('/').to(params)
else
match('/').to(:controller => 'merb_slices', :action => 'index')
end
end
end
else
puts "No slice found (expected: #{slice_name})"
exit
end
class MerbSlices < Merb::Controller
def index
html = "<h1>#{slice.name}</h1><p>#{slice.description}</p>"
html << "<h2>Routes</h2><ul>"
sorted_names = slice.named_routes.keys.map { |k| [k.to_s, k] }.sort_by { |pair| pair.first }
sorted_names.each do |_, name|
if name != :default && (route = slice.named_routes[name])
if name == :index
html << %Q[<li><a href="#{url(route.name)}" title="visit #{name}">#{name}: #{route.inspect}</a></li>]
else
html << %Q[<li>#{name}: #{route.inspect}</li>]
end
end
end
html << "</ul>"
html
end
private
def slice
@slice ||= Merb::Slices.slices.first
end
end
ARGV.push '-H' if ARGV[0] && ARGV[0] =~ /^[^-]/
unless %w[-a --adapter -i --irb-console -r --script-runner].any? { |o| ARGV.index(o) }
ARGV.push *%w[-a mongrel]
end
Merb.start
|