class Docks::Grouper
Public Class Methods
group(globs)
click to toggle source
# File lib/docks/group.rb, line 17 def self.group(globs) files = file_list_from_globs(globs) groups = {} return groups if files.empty? # Cycle through all files identified by the glob, then assign them to # the group matching their group ID. files.each do |filename| if should_include_file?(filename) identifier = Docks.pattern_id(filename) groups[identifier] ||= [] groups[identifier] << filename end end groups end
source_files_of_type(type)
click to toggle source
# File lib/docks/group.rb, line 35 def self.source_files_of_type(type) return @source_files_by_type[type] unless @source_files_by_type.nil? files = {} files[Docks::Types::Languages::MARKUP] = [] files[Docks::Types::Languages::STYLE] = [] files[Docks::Types::Languages::SCRIPT] = [] files[Docks::Types::Languages::STUB] = [] files[Docks::Types::Languages::DESCRIPTION] = [] file_list_from_globs(Docks.config.sources).each do |filename| files[Docks::Languages.file_type(filename)] << filename end @source_files_by_type = files @source_files_by_type[type] end
Private Class Methods
file_list_from_globs(globs)
click to toggle source
# File lib/docks/group.rb, line 62 def self.file_list_from_globs(globs) Array(globs).map { |glob| Dir.glob(glob) }.flatten end
should_include_file?(filename)
click to toggle source
# File lib/docks/group.rb, line 57 def self.should_include_file?(filename) Docks::Languages.extensions.include?(File.extname(filename)[1..-1]) && !filename.include?('.min.') end