Class: Qwandry::Repository
- Inherits:
-
Object
- Object
- Qwandry::Repository
- Defined in:
- lib/qwandry/repository.rb
Overview
A Repository’s primary responsibility is to return a set of Packages that match the search criteria used in Repository#scan.
Subclasses are expected
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#all_paths ⇒ Object
Returns all paths that should be tested by Qwandry#scan.
-
#initialize(name, path, options = {}) ⇒ Repository
constructor
Creates a Repository with a give name, search path, and options.
-
#scan(name) ⇒ Object
Given a name, scan should an array with 0 or more Packages matching the name.
Constructor Details
#initialize(name, path, options = {}) ⇒ Repository
Creates a Repository with a give name, search path, and options.
12 13 14 15 16 |
# File 'lib/qwandry/repository.rb', line 12 def initialize(name, path, ={}) @name = name @path = path.chomp('/') @options = end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
7 8 9 |
# File 'lib/qwandry/repository.rb', line 7 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/qwandry/repository.rb', line 9 def @options end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/qwandry/repository.rb', line 8 def path @path end |
Instance Method Details
#all_paths ⇒ Object
Returns all paths that should be tested by Qwandry#scan.
25 26 27 28 29 30 |
# File 'lib/qwandry/repository.rb', line 25 def all_paths paths = Dir["#{@path}/*"] paths = paths.select(&matcher([:accept])) if [:accept] paths = paths.reject(&matcher([:reject])) if [:reject] paths end |
#scan(name) ⇒ Object
Given a name, scan should an array with 0 or more Packages matching the name.
20 21 22 |
# File 'lib/qwandry/repository.rb', line 20 def scan(name) raise NotImplementedError, "Repositories must return an Array of matching packages." end |