Class: Debci::RejectList

Inherits:
Object
  • Object
show all
Defined in:
lib/debci/reject_list.rb

Instance Method Summary collapse

Constructor Details

#initializeRejectList

Returns a new instance of RejectList.



3
4
5
6
7
# File 'lib/debci/reject_list.rb', line 3

def initialize
  @config_dir = Debci.config.config_dir
  @suite_list = Debci.config.suite_list
  @arch_list = Debci.config.arch_list
end

Instance Method Details

#comment(name, params = {}) ⇒ Object



55
56
57
58
# File 'lib/debci/reject_list.rb', line 55

def comment(name, params = {})
  suite, arch, version = unpack_params(params)
  data.dig(name, suite, arch, version)
end

#dataObject



66
67
68
# File 'lib/debci/reject_list.rb', line 66

def data
  @data ||= read_data
end

#find_expanding_package_name(name, params) ⇒ Object



29
30
31
32
33
34
35
36
37
# File 'lib/debci/reject_list.rb', line 29

def find_expanding_package_name(name, params)
  suite, arch, version = unpack_params(params)
  # Expand package name
  data.keys.select { |k| File.fnmatch(k, name) }.each do |wildcard|
    return true if include?(wildcard, suite: suite, arch: arch, version: version)
  end
  # None of the package name wildcards match
  false
end

#find_expanding_wildcards(name, params) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/debci/reject_list.rb', line 39

def find_expanding_wildcards(name, params)
  suite, arch, version = unpack_params(params)

  if suite == '*'
    return @suite_list.all? do |s|
      include?(name, suite: s, arch: arch, version: version)
    end
  end

  return unless arch == '*'

  @arch_list.all? do |a|
    include?(name, suite: suite, arch: a, version: version)
  end
end

#include?(name, params = {}) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/debci/reject_list.rb', line 16

def include?(name, params = {})
  name = String(name)
  suite, arch, version = unpack_params(params)

  return find_expanding_package_name(name, params) unless data.key?(name)
  return find_expanding_wildcards(name, params) unless data[name].key?(suite)
  return find_expanding_wildcards(name, params) unless data[name][suite].key?(arch)

  return true if [version, '*'].include?(data[name][suite][arch].keys.first)

  find_expanding_wildcards(name, params)
end

#packagesObject



60
61
62
63
64
# File 'lib/debci/reject_list.rb', line 60

def packages
  # A package is rejectlisted only if it is rejectlisted for all suites,
  # architectures and versions.
  @packages ||= data.keys.select { |key| !key.include?("*") && include?(key) }
end

#unpack_params(params) ⇒ Object



9
10
11
12
13
14
# File 'lib/debci/reject_list.rb', line 9

def unpack_params(params)
  suite = params[:suite] || '*'
  arch = params[:arch] || '*'
  version = params[:version] || '*'
  [suite, arch, version]
end