Sha256: f0b194cb263c702512796404f73326c4c11495e4331c43a571d6686558e315b0
Contents?: true
Size: 1.56 KB
Versions: 2
Compression:
Stored size: 1.56 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) self end alias_method :append_path, :append_paths # Append each path in the given directory. def append_paths_in(path) path = normalize_path(path) append_paths(*path.children.select(&:directory?)) if path.directory? self end # All of the paths registered by the plugin. def paths @paths ||= [] end protected def normalize_path(path) Pathname.new(path).expand_path(root) end def normalize_paths(paths) normalized_paths = [] paths.each do |path| path = normalize_path(path) normalized_paths.push(path.to_s) if path.exist? end normalized_paths end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sprockets-plugin-0.3.0 | lib/sprockets/plugin.rb |
sprockets-plugin-0.2.1 | lib/sprockets/plugin.rb |