/usr/lib/ruby/1.8/merb-slices.rb is in libmerb-slices-ruby1.8 1.0.12+dfsg-4fakesync1.
This file is owned by root:root, with mode 0o644.
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 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | require 'merb-slices/module'
if defined?(Merb::Plugins)
Merb::Plugins.add_rakefiles "merb-slices/merbtasks"
Merb::Plugins.config[:merb_slices] ||= {}
require "merb-slices/module_mixin"
require "merb-slices/controller_mixin"
require "merb-slices/router_ext"
# Enable slice behaviour for any class inheriting from AbstractController.
# To use this call controller_for_slice in your controller class.
Merb::AbstractController.send(:include, Merb::Slices::ControllerMixin)
# Load Slice classes before the app's classes are loaded.
#
# This allows the application to override/merge any slice-level classes.
class Merb::Slices::Loader < Merb::BootLoader
before LoadClasses
class << self
# Gather all slices from search path and gems and load their classes.
def run
Merb::Slices.register_slices_from_search_path! if auto_register?
Merb::Slices.each_slice { |slice| slice.load_slice }
end
# Load a single file and its requirements.
#
# @param file<String> The file to load.
def load_file(file)
Merb::BootLoader::LoadClasses.load_file file
end
# Remove a single file and the classes loaded by it from ObjectSpace.
#
# @param file<String> The file to load.
def remove_classes_in_file(file)
Merb::BootLoader::LoadClasses.remove_classes_in_file file
end
# Load classes from given paths - using path/glob pattern.
#
# @param *paths <Array> Array of paths to load classes from - may contain glob pattern
def load_classes(*paths)
Merb::BootLoader::LoadClasses.load_classes paths
end
# Reload the router - takes all_slices into account to load slices at runtime.
def reload_router!
Merb::BootLoader::Router.reload!
end
# Slice-level paths for all loaded slices.
#
# @return <Array[String]> Any slice-level paths that have been loaded.
def slice_paths
paths = []
Merb::Slices.each_slice { |slice| paths += slice.collected_slice_paths }
paths
end
# App-level paths for all loaded slices.
#
# @return <Array[String]> Any app-level paths that have been loaded.
def app_paths
paths = []
Merb::Slices.each_slice { |slice| paths += slice.collected_app_paths }
paths
end
private
# Whether slices from search paths should be registered automatically.
# Defaults to true if not explicitly set.
def auto_register?
Merb::Plugins.config[:merb_slices][:auto_register] || !Merb::Plugins.config[:merb_slices].key?(:auto_register)
end
end
end
# Call initialization method for each registered Slice.
#
# This is done just before the app's after_load_callbacks are run.
# The application has been practically loaded completely, letting
# the callbacks work with what has been loaded.
class Merb::Slices::Initialize < Merb::BootLoader
before AfterAppLoads
def self.run
Merb::Slices.each_slice do |slice|
Merb.logger.verbose!("Initializing slice '#{slice}' ...")
slice.init if slice.respond_to?(:init)
end
end
end
# Call activation method for each registered Slice.
#
# This is done right after the app's after_load_callbacks are run.
# Any settings can be taken into account in the activation step.
#
# @note Activation will only take place if the slice has been routed;
# this means you need have at least one slice route setup.
class Merb::Slices::Activate < Merb::BootLoader
after AfterAppLoads
def self.run
Merb::Slices.each_slice do |slice|
Merb.logger.info!("Activating slice '#{slice}' ...")
slice.activate if slice.respond_to?(:activate) && slice.routed?
end
end
end
end
|