Mailinglist Archive: yast-devel (163 mails)

< Previous Next >
[yast-devel] Re: [yast-commit] <rest-service> master : patches module: fixed vendor package list. #TODO: read real yml file, add tests
  • From: Josef Reidinger <jreidinger@xxxxxxx>
  • Date: Tue, 01 Sep 2009 08:28:29 +0200
  • Message-id: <4A9CBF0D.8010405@xxxxxxx>
On 08/31/2009 05:42 PM, Bjoern Geuken wrote:
ref: refs/heads/master
commit 576fcd2127a2d10f936f61800da6d37749fe4186
Author: Bjoern Geuken <bgeuken@xxxxxxx>
Date: Mon Aug 31 17:42:44 2009 +0200

patches module: fixed vendor package list. #TODO: read real yml file, add
tests
---
.../patches/app/controllers/packages_controller.rb | 30 ++++++++++---------
plugins/patches/app/models/package.rb | 7 ----
2 files changed, 16 insertions(+), 21 deletions(-)

diff --git a/plugins/patches/app/controllers/packages_controller.rb
b/plugins/patches/app/controllers/packages_controller.rb
index e2b46ca..38d8bfd 100644
--- a/plugins/patches/app/controllers/packages_controller.rb
+++ b/plugins/patches/app/controllers/packages_controller.rb
@@ -38,30 +38,32 @@ class PackagesController < ApplicationController
end
end

- public
-
def compare_lists(packages)
- vendor_packages = Hash.new
- # yml datei auslesen: ["packages"] => ["yast-core", "ruby-dbus", ...]
- package_list = Array.new
- package_list << ["yast2-users", "3ddiag", "foo"]
+ vendor_packages = Array.new
+ #TODO: replace by real yml file
+ package_list = ["3ddiag", "foo", "yast2-users", "yast2-network"]

package_list.each {|pk_name|
- packages.each {|p|
+ p = nil
+ for i in 0..packages.size-1
# package installed?
- if p.name == pk_name
- # store version and name
- vendor_packages["package"] = {:name => "#{p.name}", :version =>
"#{p.version}"}
+ if pk_name == packages[i].name
+ # store package
+ p = packages[i]
+ break
Hi,
As I say before this is unnecessary big code instead
p = nil
for i in 0..packages.size-1
if pk_name == packages[i].name
# store package
p = packages[i]
break
end
end

use this with same result
p = packages.find { |pkg| pk_name == pkg.name }

if you have question about code just ask ;)

--
Josef Reidinger
YaST team
maintainer of perl-Bootloader, YaST2-Repair, webyast modules language
and time
--
To unsubscribe, e-mail: yast-devel+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-devel+help@xxxxxxxxxxxx

< Previous Next >
List Navigation
This Thread
  • No further messages