Sha256: a1ea0c95b36604b73694063f958c067f069e927ba5a9ead7e73abf773ec3ff01
Contents?: true
Size: 1.55 KB
Versions: 1
Compression:
Stored size: 1.55 KB
Contents
require "pathname" module Sprockets class Plugin require "sprockets/plugin/version" require "sprockets/plugin/aware" class << self def inherited(plugin) plugins << plugin end # Returns all of the plugins inheriting from # Sprockets::Plugin. def plugins @@plugins ||= [] end # Sets the root path or returns the current one. # A root path is required for appending relative # paths. def root(path = nil) if path @root = Pathname.new(path).expand_path else @root end end # Appends a path to the Plugin. The path will # later be appended to the Sprockets::Environment. def append_paths(*paths) self.paths.push *normalize_paths(paths) end alias_method :append_path, :append_paths # Prepends a path to the Plugin. The path will # later be appended to the Sprockets::Environment. def prepend_paths(*paths) self.paths.unshift *normalize_paths(paths) end alias_method :prepend_path, :prepend_paths # All of the paths registered by the plugin. def paths @paths ||= [] end protected def normalize_paths(paths) paths.inject([]) do |normalized_paths, path| path = Pathname.new(path) path = root.join(path) if root && path.relative? path = path.expand_path normalized_paths.push(path.to_s) if path.exist? end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
sprockets-plugin-0.1.0 | lib/sprockets/plugin.rb |