Class: AptControl::PackageStates

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/apt_control/package_states.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ PackageStates

Returns a new instance of PackageStates.



5
6
7
8
9
# File 'lib/apt_control/package_states.rb', line 5

def initialize(options)
  @apt_site      = options.fetch(:apt_site)
  @build_archive = options.fetch(:build_archive)
  @control_file  = options.fetch(:control_file)
end

Instance Method Details

#each(&block) ⇒ Object

yield a package state for each entry in the control file



12
13
14
15
16
17
18
19
# File 'lib/apt_control/package_states.rb', line 12

def each(&block)
  @control_file.distributions.each do |dist|
    dist.package_rules.each do |rule|
      yield PackageState.new(dist: dist, rule: rule, apt_site: @apt_site,
        build_archive: @build_archive)
    end
  end
end

#find_state(dist_name, package_name) ⇒ Object



21
22
23
24
25
# File 'lib/apt_control/package_states.rb', line 21

def find_state(dist_name, package_name)
  find do |state|
    state.dist.name == dist_name && state.package_name == package_name
  end
end