Sha256: 4e96baad0608a38d9709188c75cdd7bfe4a2a2bf65dbec7aea4c1946c9131ba9
Contents?: true
Size: 1.59 KB
Versions: 1
Compression:
Stored size: 1.59 KB
Contents
module Lotus module Config # Assets configuration # # @since 0.1.0 # @api private class Assets < Utils::LoadPaths DEFAULT_DIRECTORY = 'public'.freeze # Assets source (directory) # # @since 0.5.0 # @api private class Source # @since 0.5.0 # @api private BLANK = ''.freeze # @since 0.5.0 # @api private URL_SEPARATOR = '/'.freeze # @since 0.5.0 # @api private attr_reader :urls # @since 0.5.0 # @api private attr_reader :root # @since 0.5.0 # @api private def initialize(path) @path = path.to_s @root = @path.sub("#{ Lotus.root }/", BLANK) @urls = {} Dir.glob("#{ path }/**/*").each do |file| next if ::File.directory?(file) @urls.store( file.sub(@path, BLANK).sub(::File::SEPARATOR, URL_SEPARATOR), file.sub("#{ @path }/", BLANK) ) end @urls.freeze end end # @since 0.1.0 # @api private def initialize(root) @root = root @paths = Array(DEFAULT_DIRECTORY) end # @since 0.5.0 # @api private def for_each_source each do |path| yield Source.new(path) if path.exist? end end # @since 0.2.0 # @api private def any? @paths.any? end protected # @since 0.1.0 # @api private def realpath(path) @root.join(path).realpath end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lotusrb-0.5.0 | lib/lotus/config/assets.rb |