class JsDuck::Options::InputFiles

Finalizes the list of input files.

Public Class Methods

new(opts) click to toggle source
# File lib/jsduck/options/input_files.rb, line 9
def initialize(opts)
  @opts = opts
end

Public Instance Methods

expand!() click to toggle source

Expands opts.input_files (modifying its contents):

  • When file is a directory, scans all JS, SCSS files in there.

  • When file is a .jsb3 file, extracts list of files from it.

  • Otherwise returns array with this same input filename.

Then excludes the files and dirs listed in opts.exclude.

# File lib/jsduck/options/input_files.rb, line 20
def expand!
  @opts.input_files = expand_files(@opts.input_files)
  exclude_files!(@opts.input_files, @opts.exclude)
end

Private Instance Methods

exclude_files!(files, exclude_paths) click to toggle source

Removes the files matching exclude_paths from list of files

# File lib/jsduck/options/input_files.rb, line 50
def exclude_files!(files, exclude_paths)
  exclude_paths.each do |exclude_path|
    exclude_re = Regexp.new('\A' + Regexp.escape(exclude_path))
    files.reject! {|f| f =~ exclude_re }
  end
end
expand_filename(fname) click to toggle source
# File lib/jsduck/options/input_files.rb, line 31
def expand_filename(fname)
  files = []

  if File.exists?(fname)
    if File.directory?(fname)
      Dir[fname+"/**/*.{js,scss}"].each {|f| files << f }
    elsif fname =~ /\.jsb3$/
      Options::Jsb.read(fname).each {|fn| read_filenames(fn) }
    else
      files << fname
    end
  else
    Logger.warn(nil, "File not found", {:filename => fname})
  end

  files
end
expand_files(unexpanded_files) click to toggle source
# File lib/jsduck/options/input_files.rb, line 27
def expand_files(unexpanded_files)
  unexpanded_files.map {|fname| expand_filename(fname) }.flatten
end