lib/lotus/config/assets.rb in lotusrb-0.1.0 vs lib/lotus/config/assets.rb in lotusrb-0.2.0
- old
+ new
@@ -2,28 +2,42 @@
module Config
# Assets configuration
#
# @since 0.1.0
# @api private
- class Assets
+ class Assets < Utils::LoadPaths
DEFAULT_DIRECTORY = 'public'.freeze
- def initialize(root, directory)
- @path = root.join(directory || DEFAULT_DIRECTORY)
+ # @since 0.1.0
+ # @api private
+ def initialize(root)
+ @root = root
+ @paths = Array(DEFAULT_DIRECTORY)
end
+ # @since 0.1.0
+ # @api private
def entries
- if @path.exist?
- @path.children.map {|child| "/#{ child.basename }" }
- else
- []
+ hash = Hash.new { |k, v| k[v] = [] }
+ each do |path|
+ if path.exist?
+ hash[path.to_s] = path.children.map { |child| "/#{ child.basename }" }
+ end
end
+ hash
end
- def to_s
- @path.to_s
+ # @since 0.2.0
+ # @api private
+ def any?
+ @paths.any?
end
- alias_method :to_str, :to_s
+ protected
+ # @since 0.1.0
+ # @api private
+ def realpath(path)
+ @root.join(path).realpath
+ end
end
end
end