Class: Sprinkle::Package::PackageRepository

Inherits:
Object
  • Object
show all
Defined in:
lib/sprinkle/package/package_repository.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initializePackageRepository

sets up an empty repository


5
6
7
# File 'lib/sprinkle/package/package_repository.rb', line 5

def initialize
  clear
end

Instance Method Details

#<<(package) ⇒ Object


17
# File 'lib/sprinkle/package/package_repository.rb', line 17

def <<(package); add(package); end

#add(package) ⇒ Object

adds a single package to the repository


14
15
16
# File 'lib/sprinkle/package/package_repository.rb', line 14

def add(package)
  @packages << package
end

#clearObject


9
10
11
# File 'lib/sprinkle/package/package_repository.rb', line 9

def clear
  @packages = []
end

#countObject


32
33
34
# File 'lib/sprinkle/package/package_repository.rb', line 32

def count
  @packages.size
end

#find_all(name, opts = {}) ⇒ Object

returns all packages matching the name and options given (including via provides)


25
26
27
28
29
30
# File 'lib/sprinkle/package/package_repository.rb', line 25

def find_all(name, opts={})
  # opts ||= {}
  all = [@packages.select {|x| x.name.to_s == name.to_s },
  find_all_by_provides(name, opts)].flatten.compact
  filter(all, opts)
end

#first(name, opts = {}) ⇒ Object

returns the first package matching the name and options given


20
21
22
# File 'lib/sprinkle/package/package_repository.rb', line 20

def first(name, opts={})
  find_all(name, opts).try(:first)
end