Sha256: 70c3e3304ccd15cfeb36482ba96883366a0748b81f666ecd95849e530e648295

Contents?: true

Size: 864 Bytes

Versions: 3

Compression:

Stored size: 864 Bytes

Contents

require "#{$script_dir}/source-file"

class FileSet
  include Enumerable
  attr_reader :files
  
  def initialize(set)
   @files= []
   case
     when (set.is_a?(String))
       include_file(set)
     when (set.is_a?(Array))
       set.each { |f| include_file(f) }
    end
  end
  
  def include_file(file)
    full_path= File.expand_path(file)

    if File.directory?(full_path)
      Dir.foreach(full_path) { |f|
          next if ('.'==f[/^\./])
          include_file(File.join(full_path, f))
      }
    else
      if (File.exists?(full_path))
        source_file= SourceFile.from_path(full_path)
      else
        source_file= Project.current.find_file(file)
        return if (!source_file)
      end
      
      return if (@files.include?(source_file))
      @files << source_file
    end
  end
  
  def each
    @files.each { |f| yield f }
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
distil-0.8.4 lib/file-set.rb
distil-0.8.2 lib/file-set.rb
distil-0.8.1 lib/file-set.rb