Module: Roger::Helpers::GetFiles

Included in:
Release, Test
Defined in:
lib/roger/helpers/get_files.rb

Overview

Helper to include the get_files method

Instance Method Summary collapse

Instance Method Details

#get_files(globs, excludes = [], path = nil) ⇒ Object

Get files from a path, skipping excludes.

Parameters:

  • globs (Array)

    an array of file path globs that will be globbed against the project path

  • excludes (Array) (defaults to: [])

    an array of regexps that will be excluded from the result.

  • Path (String, Pathname)

    to search files in



12
13
14
15
16
17
# File 'lib/roger/helpers/get_files.rb', line 12

def get_files(globs, excludes = [], path = nil)
  path = Pathname.new(get_files_default_path)
  files = globs.map { |g| Dir.glob(path + g) }.flatten
  files.reject! { |file| excludes.detect { |e| file.match(e) } } if excludes.any?
  files.select { |file| File.file?(file) }
end