Sha256: c5f0303cacb4acac891238bfee2ad4b00687ac184b8b07a2b843ea2179a756bb

Contents?: true

Size: 584 Bytes

Versions: 2

Compression:

Stored size: 584 Bytes

Contents

# Classify elements in files or gems

module Classifier
  class << self
    def classify(elements)
      files = []
      gems = []

      elements.uniq.each do |element|
        case element_type(element)
        when :file then files << element
        when :directory then files.concat(FileSmasher.files_by(element))
        else gems << element
        end
      end
      { files: files, gems: gems }
    end

    private

    def element_type(element)
      return :directory if Dir.exist?(element)
      return :file if FileSmasher.file?(element)

      :gem
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
require_smasher-0.4.1 lib/require_smasher/classifier.rb
require_smasher-0.4.0 lib/require_smasher/classifier.rb