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
- #blacklist_comment(params = {}) ⇒ Object
- #blacklisted?(params = {}) ⇒ Boolean
-
#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
-
#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
77 78 79 80 |
# File 'lib/debci/package.rb', line 77 def self.prefix(name) name =~ /^((lib)?.)/ Regexp.last_match(1) end |
.prefixes ⇒ Object
72 73 74 75 |
# File 'lib/debci/package.rb', line 72 def self.prefixes # FIXME: optimize(?) select(:name).distinct.pluck(:name).map { |n| prefix(n) }.sort.uniq end |
Instance Method Details
#blacklist_comment(params = {}) ⇒ Object
90 91 92 |
# File 'lib/debci/package.rb', line 90 def blacklist_comment(params = {}) Debci.blacklist.comment(name, params) end |
#blacklisted?(params = {}) ⇒ Boolean
86 87 88 |
# File 'lib/debci/package.rb', line 86 def blacklisted?(params = {}) Debci.blacklist.include?(name, params) end |
#fail_or_neutral ⇒ Object
Returns an Array of statuses where this package is failing or neutral.
58 59 60 |
# File 'lib/debci/package.rb', line 58 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
49 50 51 |
# File 'lib/debci/package.rb', line 49 def history(suite, architecture) Debci::Job.history(self, suite, architecture) end |
#last_updated_at(suite = nil) ⇒ Object
94 95 96 97 |
# File 'lib/debci/package.rb', line 94 def last_updated_at(suite = nil) statuses = status.flatten.compact.select { |s| s.suite == suite || !suite } statuses.map(&:date).compact.max end |
#news ⇒ Object
53 54 55 |
# File 'lib/debci/package.rb', line 53 def news jobs.newsworthy.order('date DESC').first(10) end |
#prefix ⇒ Object
82 83 84 |
# File 'lib/debci/package.rb', line 82 def prefix self.class.prefix(name) 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 blacklisted
32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/debci/package.rb', line 32 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
62 63 64 65 |
# File 'lib/debci/package.rb', line 62 def to_s # :nodoc: "<Package #{name}>" end |
#to_str ⇒ Object
67 68 69 70 |
# File 'lib/debci/package.rb', line 67 def to_str # :nodoc: name end |