Class: Debci::Package
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Debci::Package
- Defined in:
- lib/debci/package.rb
Overview
This class represents a single package.
Class Method Summary collapse
Instance Method Summary collapse
-
#fail_or_neutral ⇒ Object
Returns an Array of statuses where this package is failing or neutral.
-
#history(suite, architecture) ⇒ Object
Returns an array of Debci::Job objects that represent the test history for this package.
- #last_updated_at(suite = nil) ⇒ Object
- #news ⇒ Object
- #prefix ⇒ Object
- #reject_list_comment(params = {}) ⇒ Object
- #reject_listed?(params = {}) ⇒ Boolean
-
#status ⇒ Object
Returns a matrix of Debci::Job objects, where rows represent architectures and columns represent suites:.
- #to_s ⇒ Object
- #to_str ⇒ Object
Class Method Details
.prefix(name) ⇒ Object
80 81 82 83 |
# File 'lib/debci/package.rb', line 80 def self.prefix(name) name =~ /^((lib)?.)/ Regexp.last_match(1) end |
.prefixes ⇒ Object
75 76 77 78 |
# File 'lib/debci/package.rb', line 75 def self.prefixes # FIXME: optimize(?) select(:name).distinct.pluck(:name).map { |n| prefix(n) }.sort.uniq end |
Instance Method Details
#fail_or_neutral ⇒ Object
Returns an Array of statuses where this package is failing or neutral.
61 62 63 |
# File 'lib/debci/package.rb', line 61 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
52 53 54 |
# File 'lib/debci/package.rb', line 52 def history(suite, architecture) Debci::Job.history(self, suite, architecture) end |
#last_updated_at(suite = nil) ⇒ Object
97 98 99 100 |
# File 'lib/debci/package.rb', line 97 def last_updated_at(suite = nil) statuses = status.flatten.compact.select { |s| s.suite == suite || !suite } statuses.map(&:date).compact.max end |
#news ⇒ Object
56 57 58 |
# File 'lib/debci/package.rb', line 56 def news jobs.newsworthy.order('date DESC').first(10) end |
#prefix ⇒ Object
85 86 87 |
# File 'lib/debci/package.rb', line 85 def prefix self.class.prefix(name) end |
#reject_list_comment(params = {}) ⇒ Object
93 94 95 |
# File 'lib/debci/package.rb', line 93 def reject_list_comment(params = {}) Debci.reject_list.comment(name, params) end |
#reject_listed?(params = {}) ⇒ Boolean
89 90 91 |
# File 'lib/debci/package.rb', line 89 def reject_listed?(params = {}) Debci.reject_list.include?(name, params) end |
#status ⇒ Object
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
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/debci/package.rb', line 35 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_s ⇒ Object
65 66 67 68 |
# File 'lib/debci/package.rb', line 65 def to_s # :nodoc: "<Package #{name}>" end |
#to_str ⇒ Object
70 71 72 73 |
# File 'lib/debci/package.rb', line 70 def to_str # :nodoc: name end |