Sha256: a615221eafb3a9f9295c082408ca4d362fc6bcf98fc69f58375481cf26e8582e

Contents?: true

Size: 658 Bytes

Versions: 2

Compression:

Stored size: 658 Bytes

Contents

# Find files

module FileSmasher
  class << self
    def files_by(directory)
      raise DirNotExistError, "Directory '#{directory}' does not exist" unless Dir.exist?(directory)

      Dir.glob("./#{directory}/**/*.rb")
    end

    def files(directories)
      raise DirNotInformedError if directories.empty?

      files = []
      directories.uniq.each do |directory|
        files.concat(FileSmasher.files_by(directory))
      end

      files
    end

    def file?(element)
      file = File.expand_path("./#{element}")
      return true if File.file?(file)
      return false if element.include?('.')

      File.file?("#{file}.rb")
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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