Module: Classifier

Defined in:
lib/require_smasher/classifier.rb

Overview

Classify elements in files or gems

Class Method Summary collapse

Class Method Details

.classify(elements) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/require_smasher/classifier.rb', line 7

def classify(elements)
  elements.uniq!
  files = elements.select { |element| element_type(element) == :file }
  directories = (elements - files).select { |element| element_type(element) == :directory }
  gems = elements - files - directories
  files << directories.map { |directory| FileSmasher.files_by(directory) }
  { files: files.flatten, gems: gems }
end