lib/arborist/dependency.rb in arborist-0.2.0.pre20170519125456 vs lib/arborist/dependency.rb in arborist-0.2.0

- old
+ new

@@ -219,15 +219,27 @@ ### Return an English description of why this dependency is not met. If it is ### met, returns +nil+. def down_reason - ids = self.down_identifiers - subdeps = self.down_subdeps + parts = [ + self.down_primary_reasons, + self.down_secondary_reasons + ].compact - return nil if ids.empty? && subdeps.empty? + return nil if parts.empty? + return parts.join( '; ' ) + end + + + ### Return an English description of why any first tier dependencies are not met, + ### or +nil+ if there are none. + def down_primary_reasons + ids = self.down_identifiers + return nil if ids.empty? + msg = nil case self.behavior when :all msg = ids.first.dup if ids.size == 1 @@ -243,11 +255,19 @@ msg << " as of %s" % [ self.latest_down_time ] else raise "Don't know how to build a description of down behavior for %p" % [ self.behavior ] end + end - return msg + + ### Return an English description of why any subdependencies are not met, + ### or +nil+ if there are none. + def down_secondary_reasons + subdeps = self.down_subdeps + return nil if subdeps.empty? + + return subdeps.map( &:down_reason ).join( ' and ' ) end ### Return the entire dependency tree as a nested Hash. def to_h