-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
/.yardoc | ||
/coverage | ||
*.bz2 | ||
/nbproject/private/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
|
||
module Migration | ||
|
||
class ProductChecker | ||
|
||
def initialize(products) | ||
@products = products | ||
end | ||
|
||
def obsoleted_product_repos | ||
|
||
end | ||
|
||
private | ||
|
||
attr_accessor :products | ||
|
||
def available_obsolete_products | ||
obsolete = [] | ||
|
||
new_products = select_products(:installed) | ||
available_products = select_products(:available) | ||
|
||
new_products.each do |new_product| | ||
upgraded_products = available_products.select do |available_product| | ||
available_product["name"] == new_product["name"] && | ||
product_version(available_product) < product_version(new_product) | ||
end | ||
|
||
obsolete.concat(upgraded_products) | ||
end | ||
|
||
obsolete | ||
end | ||
|
||
def select_products(status) | ||
products.select { |product| product["status"] == status } | ||
end | ||
|
||
# returns product version (uses Gem::Version which properly parses the | ||
# version string) | ||
# @return [Gem::Version] product version | ||
def product_version(product) | ||
Gem::Version.new(product["version_version"]) | ||
end | ||
|
||
|
||
# does one product upgrad another? | ||
# @param [Hash] new_product new product | ||
# @param [Hash] old_product new product | ||
# @return [Boolean] true if the new product upgrades the old product | ||
def product_upgrades?(new_product, old_product) | ||
old_product["name"] == new_product["name"] && | ||
product_version(old_product) < product_version(new_product) | ||
end | ||
|
||
end | ||
|
||
end |