Class: Qwandry::FlatRepository

Inherits:
Repository show all
Defined in:
lib/qwandry/flat_repository.rb

Overview

The FlatRepository assumes that each file or directory in the search path is a stand alone Package. For instance:

rails-2.3.2
rails-3.0.1
thin

Instance Attribute Summary

Attributes inherited from Repository

#name, #options, #path

Instance Method Summary collapse

Methods inherited from Repository

#all_paths, #initialize

Constructor Details

This class inherits a constructor from Qwandry::Repository

Instance Method Details

#scan(pattern) ⇒ Object

Returns a Package for each matching file or directory.



11
12
13
14
15
16
17
18
19
20
# File 'lib/qwandry/flat_repository.rb', line 11

def scan(pattern)
  results = []
  all_paths.select do |path|
    if File.fnmatch?(pattern, File.basename(path), File::FNM_CASEFOLD)
      results << package(File.basename(path), [path])
    end
  end
  
  results
end