Class: Gimli::Path

Inherits:
Object
  • Object
show all
Defined in:
lib/gimli/path.rb

Overview

Class used to interact with directory structure

Class Method Summary collapse

Class Method Details

.list_valid(target, recursive = false) ⇒ Array

Return an array of paths to valid markup file matching the passed pattern

Parameters:

  • target (String)
  • recursive (Bool) (defaults to: false)

Returns:

  • (Array)

    an array of valid files



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/gimli/path.rb', line 12

def self.list_valid(target, recursive = false)
  if recursive
    target ||= Dir.pwd
    if File.directory?(target)
      target = File.join(target, '**', '*')
    end
  else
    target ||= Dir.pwd
    if File.directory?(target)
      target = File.join(target, '*')
    end
  end

  # Use select to support ruby 1.8
  Dir.glob(target).sort().select { |file| MarkupFile.new(file).valid? }
end