Module | Merb::Slices::ModuleMixin |
In: |
lib/merb-slices/module_mixin.rb
|
Retrieve the absolute path to a app-level directory.
@param type<Symbol> The type of path to retrieve directory for, e.g. :view.
@return <String> The directory for the requested type.
@param type<Symbol> The type of path to retrieve glob for, e.g. :view.
@return <String> The pattern with which to match files within the type directory.
Construct an app-level path.
@param <Symbol> The type of component. @param *segments<Array[to_s]> Path segments to append.
@return <String>
A path within the host application, with added segments.
The app-level load paths to use when loading the slice.
@return <Hash> The load paths which make up the app-level structure.
Clone all files from the slice to their app-level location; this will also copy /lib, causing merb-slices to pick up the slice there.
@return <Array[Array]>
Array of two arrays, one for all copied files, the other for overrides that may have been preserved to resolve collisions.
Retrieve the absolute path to a slice-level directory.
@param type<Symbol> The type of path to retrieve directory for, e.g. :view.
@return <String> The absolute path for the requested type.
@param type<Symbol> The type of path to retrieve glob for, e.g. :view.
@return <String> The pattern with which to match files within the type directory.
Load slice and it‘s classes located in the slice-level load paths.
Assigns collected_slice_paths and collected_app_paths, then loads the collected_slice_paths and triggers the loaded hook method.
Return all slice files mapped from the source to their relative path
@param type<Symbol> Which type to use; defaults to :root (all) @return <Array[Array]> An array of arrays [abs. source, relative dest.]
Copies all files from mirrored_components to their app-level location
This includes application and public components.
@return <Array[Array]>
Array of two arrays, one for all copied files, the other for overrides that may have been preserved to resolve collisions.
Copies all application files from mirrored_components to their app-level location
@return <Array[Array]>
Array of two arrays, one for all copied files, the other for overrides that may have been preserved to resolve collisions.
Copy files from specified component path types to their app-level location
App-level overrides are preserved by creating duplicates before writing gem-level files. Because of their _override postfix they will load after their original implementation. In the case of views, this won‘t work, but the user override is preserved nonetheless.
@return <Array[Array]>
Array of two arrays, one for all copied files, the other for overrides that may have been preserved to resolve collisions.
@note Only explicitly defined component paths will be taken into account to avoid
cluttering the app's Merb.root by mistake - since undefined paths default to that.
Copies all application files from mirrored_components to their app-level location
@return <Array[Array]>
Array of two arrays, one for all copied files, the other for overrides that may have been preserved to resolve collisions.
Copies all files from the (optional) stubs directory to their app-level location
@return <Array[Array]>
Array of two arrays, one for all copied files, the other for overrides that may have been preserved to resolve collisions.
Return all path component types to mirror
If config option :mirror is set return a subset, otherwise return all types.
@return <Array[Symbol]> Component types.
Retrieve the relative path to a public directory.
@param type<Symbol> The type of path to retrieve directory for, e.g. :view.
@return <String> The relative path to the public directory for the requested type.
Construct a path relative to the public directory
@param <Symbol> The type of component. @param *segments<Array[to_s]> Path segments to append.
@return <String>
A path relative to the public directory, with added segments.
This is the core mechanism for setting up your app-level layout.
@param type<Symbol> The type of path being registered (i.e. :view) @param path<String> The full path @param file_glob<String>
A glob that will be used to autoload files under the path. Defaults to "**/*.rb".
@note The :public path is adapted when the slice is run from bin/slice.
This is the core mechanism for setting up your slice-level layout.
@param type<Symbol> The type of path being registered (i.e. :view) @param path<String> The full path @param file_glob<String>
A glob that will be used to autoload files under the path. Defaults to "**/*.rb".
Stub that gets triggered when a slice has been registered.
@note This is rarely needed but still provided for edge cases.
Removes given types of application components from app-level load path this slice uses for autoloading.
@param *args<Array[Symbol]> Components names, for instance, :views, :models
Removes given types of application components from slice-level load path this slice uses for autoloading.
@param *args<Array[Symbol]> Components names, for instance, :views, :models
@param *path<to_s>
The relative path (or list of path components) to a directory under the root of the application.
@return <String> The full path including the root.
This sets up the default slice-level and app-level structure.
You can create your own structure by implementing setup_structure and using the push_path and push_app_paths. By default this setup matches what the merb-gen slice generator creates.
Construct a slice-level path.
@param <Symbol> The type of component. @param *segments<Array[to_s]> Path segments to append.
@return <String>
A path within the slice source (Gem), with added segments.
The slice-level load paths to use when loading the slice.
@return <Hash> The load paths which make up the slice-level structure.
Unpack a subset of files from the slice to their app-level location; this will also copy /lib, causing merb-slices to pick up the slice there.
@return <Array[Array]>
Array of two arrays, one for all copied files, the other for overrides that may have been preserved to resolve collisions.
@note Files for the :stub component type are skipped.
Collect slice-level and app-level load paths to load from.
@param modify_load_path<Boolean>
Whether to add certain paths to $LOAD_PATH; defaults to true.
@param push_merb_path<Boolean>
Whether to add app-level paths using Merb.push_path; defaults to true.
Helper method to copy a source file to destination while resolving any conflicts.
@param source<String> The source path. @param dest<String> The destination path. @param copied<Array> Keep track of all copied files - relative paths. @param duplicated<Array> Keep track of all duplicated files - relative paths. @param postfix<String> The postfix to use for resolving conflicting filenames.
Split a file name so a postfix can be inserted
@return <Array[String]>
The first element will be the name up to the first dot, the second will be the rest.
Predicate method to check if a file should be taken into account when unpacking files
By default any public component paths and stubs are skipped; additionally you can set the :skip_files in the slice‘s config for other relative paths to skip.
@param file<String> The relative path to test. @return <TrueClass,FalseClass> True if the file may be mirrored.