Sha256: de589ccbc092c6a8acd86648ed39fb79b71d65e3f2a91be25a91dcc0c4bc5496
Contents?: true
Size: 968 Bytes
Versions: 8
Compression:
Stored size: 968 Bytes
Contents
module Praxis class FileGroup attr_reader :groups, :base def initialize(base, &block) if base.nil? raise ArgumentError, "base must not be nil." \ "Are you missing a call Praxis::Application.instance.setup?" end @groups = Hash.new @base = Pathname.new(base) if block_given? self.instance_eval(&block) end end def layout(&block) self.instance_eval(&block) end def map(name, pattern, &block) return unless base.exist? if block_given? @groups[name] = FileGroup.new(base + pattern, &block) else @groups[name] ||= [] files = Pathname.glob(base+pattern).select { |file| file.file? } files.sort_by! { |file| [file.to_s.split('/').size, file.to_s] } files.each { |file| @groups[name] << file } end end def [](*names) names.inject(@groups) { |group, name| group[name] || [] } end end end
Version data entries
8 entries across 8 versions & 1 rubygems