Class: Debci::RejectList
- Inherits:
-
Object
- Object
- Debci::RejectList
- Defined in:
- lib/debci/reject_list.rb
Instance Method Summary collapse
- #comment(name, params = {}) ⇒ Object
- #data ⇒ Object
- #find_expanding_package_name(name, params) ⇒ Object
- #find_expanding_wildcards(name, params) ⇒ Object
- #include?(name, params = {}) ⇒ Boolean
-
#initialize ⇒ RejectList
constructor
A new instance of RejectList.
- #packages ⇒ Object
- #unpack_params(params) ⇒ Object
Constructor Details
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 |
#data ⇒ Object
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 (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 (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
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 (name, params) unless data.key?(name) return (name, params) unless data[name].key?(suite) return (name, params) unless data[name][suite].key?(arch) return true if [version, '*'].include?(data[name][suite][arch].keys.first) (name, params) end |
#packages ⇒ Object
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 |