Class: Qwandry::LibraryRepository
- Inherits:
-
Repository
- Object
- Repository
- Qwandry::LibraryRepository
- Defined in:
- lib/qwandry/library_repository.rb
Overview
The LibraryRepository assumes that the search path contains files in the root mixed with directories of the same name which should be opened together. Ruby’s date library is a good example of this:
date.rb
date/
Instance Attribute Summary
Attributes inherited from Repository
Instance Method Summary collapse
-
#scan(pattern) ⇒ Object
Returns Packages that may contain one or more paths if there are similar root level files that should be bundled together.
Methods inherited from Repository
Constructor Details
This class inherits a constructor from Qwandry::Repository
Instance Method Details
#scan(pattern) ⇒ Object
Returns Packages that may contain one or more paths if there are similar root level files that should be bundled together.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/qwandry/library_repository.rb', line 13 def scan(pattern) results = Hash.new{|h,k| h[k] = package(k)} all_paths.select do |path| basename = File.basename(path) if File.fnmatch?(pattern, basename, File::FNM_CASEFOLD) # strip any file extension basename.sub! /\.\w+$/,'' unless File.directory?(path) results[basename].paths << path end end results.values.sort_by{|package| package.name} end |