From: Klaus Kaempf Date: Wed, 9 Jan 2008 13:53:13 +0000 (+0000) Subject: Problem.to_s and Decision.to_s X-Git-Tag: BASE-SuSE-Code-12_1-Branch~1020 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fd7320fb333a0d821cc46596a239c3a161ff6e11;p=platform%2Fupstream%2Flibsolv.git Problem.to_s and Decision.to_s --- diff --git a/examples/ruby/decision.rb b/examples/ruby/decision.rb new file mode 100644 index 0000000..872849e --- /dev/null +++ b/examples/ruby/decision.rb @@ -0,0 +1,21 @@ +# +# Extend SatSolver::Decision with to_s +# + +class Satsolverx::Decision + def to_s + case self.op + when SatSolver::DEC_INSTALL + return "Install #{self.solvable} #{self.reason}" + when SatSolver::DEC_REMOVE + return "Remove #{self.solvable} #{self.reason}" + when SatSolver::DEC_OBSOLETE + return "Obsolete #{self.solvable} #{self.reason}" + when SatSolver::DEC_UPDATE + return "Update #{self.solvable} #{self.reason}" + else + return "Decision op #{self.op}" + end + "**Decision**" + end +end diff --git a/examples/ruby/problem.rb b/examples/ruby/problem.rb new file mode 100644 index 0000000..3ffef60 --- /dev/null +++ b/examples/ruby/problem.rb @@ -0,0 +1,31 @@ +# +# Extend SatSolver::Problem with to_s +# + +class Satsolverx::Problem + def to_s + case self.reason + when SatSolver::SOLVER_PROBLEM_UPDATE_RULE #1 + reason = "problem with installed" + when SatSolver::SOLVER_PROBLEM_JOB_RULE #2 + reason = "conflicting requests" + when SatSolver::SOLVER_PROBLEM_JOB_NOTHING_PROVIDES_DEP #3 + reason = "nothing provides requested" + when SatSolver::SOLVER_PROBLEM_NOT_INSTALLABLE #4 + reason = "not installable" + when SatSolver::SOLVER_PROBLEM_NOTHING_PROVIDES_DEP #5 + reason = "nothing provides rel required by source" + when SatSolver::SOLVER_PROBLEM_SAME_NAME #6 + reason = "cannot install both" + when SatSolver::SOLVER_PROBLEM_PACKAGE_CONFLICT #7 + reason = "source conflicts with rel provided by target" + when SatSolver::SOLVER_PROBLEM_PACKAGE_OBSOLETES #8 + reason = "source obsoletes rel provided by target" + when SatSolver::SOLVER_PROBLEM_DEP_PROVIDERS_NOT_INSTALLABLE #9 + reason = "source requires rel but no providers are installable" + else + reason = "**unknown**" + end + "[#{self.reason}]: #{reason}] Source #{self.source}, Rel #{self.relation}, Target #{self.target}" + end +end