Class: Debci::Package

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/debci/package.rb

Overview

This class represents a single package.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.prefix(name) ⇒ Object



78
79
80
81
# File 'lib/debci/package.rb', line 78

def self.prefix(name)
  name =~ /^((lib)?.)/
  Regexp.last_match(1)
end

.prefixesObject



73
74
75
76
# File 'lib/debci/package.rb', line 73

def self.prefixes
  # FIXME: optimize(?)
  select(:name).distinct.pluck(:name).map { |n| prefix(n) }.sort.uniq
end

Instance Method Details

#fail_or_neutralObject

Returns an Array of statuses where this package is failing or neutral.



59
60
61
# File 'lib/debci/package.rb', line 59

def fail_or_neutral
  status.flatten.compact.select { |p| (p.status.to_sym == :fail) || (p.status.to_sym == :neutral) }
end

#history(suite, architecture) ⇒ Object

Returns an array of Debci::Job objects that represent the test history for this package



50
51
52
# File 'lib/debci/package.rb', line 50

def history(suite, architecture)
  Debci::Job.history(self, suite, architecture)
end

#last_updated_at(suite = nil) ⇒ Object



95
96
97
98
# File 'lib/debci/package.rb', line 95

def last_updated_at(suite = nil)
  statuses = status.flatten.compact.select { |s| s.suite == suite || !suite }
  statuses.map(&:date).compact.max
end

#newsObject



54
55
56
# File 'lib/debci/package.rb', line 54

def news
  jobs.newsworthy.order('date DESC').first(10)
end

#prefixObject



83
84
85
# File 'lib/debci/package.rb', line 83

def prefix
  self.class.prefix(name)
end

#reject_list_comment(params = {}) ⇒ Object



91
92
93
# File 'lib/debci/package.rb', line 91

def reject_list_comment(params = {})
  Debci.reject_list.comment(name, params)
end

#reject_listed?(params = {}) ⇒ Boolean

Returns:

  • (Boolean)


87
88
89
# File 'lib/debci/package.rb', line 87

def reject_listed?(params = {})
  Debci.reject_list.include?(name, params)
end

#statusObject

Returns a matrix of Debci::Job objects, where rows represent architectures and columns represent suites:

[
  [ amd64_unstable , amd64_testing ],
  [ i386_unstable, i386_testing ],
]

Each cell of the matrix contains a Debci::Job object. Note: Contains statuses which are not rejectlisted



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/debci/package.rb', line 33

def status
  @status ||=
    begin
      map = package_status.includes(:job).each_with_object({}) do |st, memo|
        memo[st.arch] ||= {}
        memo[st.arch][st.suite] = st.job
      end
      Debci.config.arch_list.map do |arch|
        Debci.config.suite_list.map do |suite|
          map[arch] && map[arch][suite]
        end
      end
    end
end

#to_sObject



63
64
65
66
# File 'lib/debci/package.rb', line 63

def to_s
  # :nodoc:
  "<Package #{name}>"
end

#to_strObject



68
69
70
71
# File 'lib/debci/package.rb', line 68

def to_str
  # :nodoc:
  name
end