Class: Mago::Cli::FileFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/mago/cli/file_finder.rb

Overview

Finds ruby files in local file system.

Instance Method Summary collapse

Constructor Details

#initialize(paths) ⇒ FileFinder

Returns a new instance of FileFinder.

Parameters:

  • paths (Array<String>)

    files and directories



6
7
8
# File 'lib/mago/cli/file_finder.rb', line 6

def initialize(paths)
  @paths = paths
end

Instance Method Details

#findArray<String>

Find ruby files.

Returns:

  • (Array<String>)

    ruby files



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/mago/cli/file_finder.rb', line 13

def find
  ruby_files = []

  @paths.each do |path|
    if File.directory?(path)
      pattern = File.join(path, '/**/*.rb')
      ruby_files.concat(Dir[pattern])
    else
      ruby_files << path
    end
  end

  ruby_files
end