Class: Docks::Grouper

Inherits:
Object
  • Object
show all
Defined in:
lib/docks/group.rb

Class Method Summary collapse

Class Method Details

.group(globs) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# 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) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# 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