Skip to content

Commit

Permalink
Rename licenses handlers/fetchers from :rpm to :libzypp
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs committed Apr 5, 2018
1 parent ca36cfb commit 67ea5dd
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 35 deletions.
4 changes: 2 additions & 2 deletions library/packages/src/Makefile.am
Expand Up @@ -54,12 +54,12 @@ y2rns_fetchers_DATA = \
y2licenses_fetchersdir = "${yast2dir}/lib/y2packager/licenses_fetchers" y2licenses_fetchersdir = "${yast2dir}/lib/y2packager/licenses_fetchers"
y2licenses_fetchers_DATA = \ y2licenses_fetchers_DATA = \
lib/y2packager/licenses_fetchers/base.rb \ lib/y2packager/licenses_fetchers/base.rb \
lib/y2packager/licenses_fetchers/rpm.rb lib/y2packager/licenses_fetchers/libzypp.rb


y2licenses_handlersdir = "${yast2dir}/lib/y2packager/licenses_handlers" y2licenses_handlersdir = "${yast2dir}/lib/y2packager/licenses_handlers"
y2licenses_handlers_DATA = \ y2licenses_handlers_DATA = \
lib/y2packager/licenses_handlers/base.rb \ lib/y2packager/licenses_handlers/base.rb \
lib/y2packager/licenses_handlers/rpm.rb lib/y2packager/licenses_handlers/libzypp.rb


EXTRA_DIST = $(module_DATA) $(ynclude_DATA) $(ylib_DATA) $(y2packager_DATA) $(y2rns_fetchers_DATA) \ EXTRA_DIST = $(module_DATA) $(ynclude_DATA) $(ylib_DATA) $(y2packager_DATA) $(y2rns_fetchers_DATA) \
$(y2licenses_fetchers_DATA) $(y2licenses_handlers_DATA) $(y2licenses_fetchers_DATA) $(y2licenses_handlers_DATA)
Expand Down
12 changes: 6 additions & 6 deletions library/packages/src/lib/y2packager/license.rb
Expand Up @@ -36,9 +36,9 @@ class << self
# This method uses a cache to return the same license if it was already # This method uses a cache to return the same license if it was already
# used for another product. # used for another product.
# #
# @param product_name [String] Product's name # @param product_name [String] Product's name
# @param source [:rpm,nil] Source to get the license from. For the time being, # @param source [:libzypp,nil] Source to get the license from. For the time being,
# only :rpm is supported. # only :libzypp is supported.
# @param content [String] License content. If this argument is given, this # @param content [String] License content. If this argument is given, this
# string is used as the license's content (and `source` is ignored). # string is used as the license's content (and `source` is ignored).
# @return [License] # @return [License]
Expand Down Expand Up @@ -79,9 +79,9 @@ def cache
# #
# Bear in mind that `fetcher` will be ignored if `content` is specified. # Bear in mind that `fetcher` will be ignored if `content` is specified.
# #
# @param fetcher [:rpm] Fetcher to retrieve licenses information. For the time # @param fetcher [:libzypp] Fetcher to retrieve licenses information. For the time
# being, only :rpm is supported. # being, only :libzypp is supported.
# @param content [String] License content. If this argument is given, this # @param content [String] License content. If this argument is given, this
# string is used as the license's content (and `source` is ignored). # string is used as the license's content (and `source` is ignored).
def initialize(fetcher: nil, content: nil) def initialize(fetcher: nil, content: nil)
@accepted = false @accepted = false
Expand Down
6 changes: 3 additions & 3 deletions library/packages/src/lib/y2packager/licenses_fetchers.rb
Expand Up @@ -11,7 +11,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------


require "yast" require "yast"
require "y2packager/licenses_fetchers/rpm" require "y2packager/licenses_fetchers/libzypp"


module Y2Packager module Y2Packager
# This module contains licenses fetchers # This module contains licenses fetchers
Expand All @@ -21,8 +21,8 @@ module Y2Packager
module LicensesFetchers module LicensesFetchers
# Return the licenses proper fetcher for a given source # Return the licenses proper fetcher for a given source
# #
# @param source [:rpm,nil] Source to fetch license from (only :rpm is supported) # @param source [:libzypp,nil] Source to fetch license from (only :rpm is supported)
# @param product_name [String] Product's name # @param product_name [String] Product's name
def self.for(source, product_name) def self.for(source, product_name)
klass = const_get(source.to_s.capitalize) klass = const_get(source.to_s.capitalize)
klass.new(product_name) klass.new(product_name)
Expand Down
Expand Up @@ -16,7 +16,7 @@ module Y2Packager
module LicensesFetchers module LicensesFetchers
# This class is responsible for obtaining the license and license content # This class is responsible for obtaining the license and license content
# of a given product from libzypp. # of a given product from libzypp.
class Rpm < Base class Libzypp < Base
# Return the license text to be confirmed # Return the license text to be confirmed
# #
# @param lang [String] Language # @param lang [String] Language
Expand Down
6 changes: 3 additions & 3 deletions library/packages/src/lib/y2packager/licenses_handlers.rb
Expand Up @@ -10,7 +10,7 @@
# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------


require "y2packager/licenses_handlers/rpm" require "y2packager/licenses_handlers/libzypp"


module Y2Packager module Y2Packager
# This module contains licenses handlers # This module contains licenses handlers
Expand All @@ -21,8 +21,8 @@ module Y2Packager
module LicensesHandlers module LicensesHandlers
# Return the licenses proper fetcher for a given source # Return the licenses proper fetcher for a given source
# #
# @param source [:rpm,nil] Source to fetch license from (only :rpm is supported) # @param source [:libzypp,nil] Source to fetch license from (only :libzypp is supported)
# @param product_name [String] Product's name # @param product_name [String] Product's name
# @return [Object] # @return [Object]
def self.for(source, product_name) def self.for(source, product_name)
klass = const_get(source.to_s.capitalize) klass = const_get(source.to_s.capitalize)
Expand Down
Expand Up @@ -18,7 +18,7 @@ module Y2Packager
module LicensesHandlers module LicensesHandlers
# This class is responsible for interacting with libzypp in order to get/set # This class is responsible for interacting with libzypp in order to get/set
# the license acceptance status for a given product # the license acceptance status for a given product
class Rpm < Base class Libzypp < Base
# Determine whether the license should be accepted or not # Determine whether the license should be accepted or not
# #
# @return [Boolean] true if the license acceptance is required # @return [Boolean] true if the license acceptance is required
Expand Down
2 changes: 1 addition & 1 deletion library/packages/src/lib/y2packager/product.rb
Expand Up @@ -199,7 +199,7 @@ def label
# @param lang [String] Language # @param lang [String] Language
# @return [ProductLicense,nil] Product's license; nil if the license was not found. # @return [ProductLicense,nil] Product's license; nil if the license was not found.
def license def license
@license ||= ProductLicense.find(name, source: :rpm) @license ||= ProductLicense.find(name, source: :libzypp)
end end


# Return the license text to be confirmed # Return the license text to be confirmed
Expand Down
8 changes: 4 additions & 4 deletions library/packages/src/lib/y2packager/product_license.rb
Expand Up @@ -49,9 +49,9 @@ class << self
# #
# This method uses a cache to return an already fetched product license. # This method uses a cache to return an already fetched product license.
# #
# @param product_name [String] Product's name # @param product_name [String] Product's name
# @param source [:rpm,nil] Source to get the license from. For the time being, # @param source [:libzypp,nil] Source to get the license from. For the time being,
# only :rpm is really supported. # only :libzypp is really supported.
# @return [ProductLicense] # @return [ProductLicense]
def find(product_name, source: nil, content: nil) def find(product_name, source: nil, content: nil)
return cache[product_name] if cache[product_name] return cache[product_name] if cache[product_name]
Expand All @@ -74,7 +74,7 @@ def clear_cache
# #
# @param product_name [String] Product name to get licenses for # @param product_name [String] Product name to get licenses for
# @param source [Symbol] Backend to use when syncing the licenses acceptance status # @param source [Symbol] Backend to use when syncing the licenses acceptance status
# (only :rpm is supported) # (only :libzypp is supported)
def initialize(product_name, license, source: nil) def initialize(product_name, license, source: nil)
@product_name = product_name @product_name = product_name
@license = license @license = license
Expand Down
14 changes: 7 additions & 7 deletions library/packages/test/y2packager/license_test.rb
Expand Up @@ -19,20 +19,20 @@
subject(:license) { Y2Packager::License.new(fetcher: fetcher) } subject(:license) { Y2Packager::License.new(fetcher: fetcher) }


let(:fetcher) do let(:fetcher) do
instance_double(Y2Packager::LicensesFetchers::Rpm, content: "license") instance_double(Y2Packager::LicensesFetchers::Libzypp, content: "license")
end end


before do before do
described_class.clear_cache described_class.clear_cache
allow(Y2Packager::LicensesFetchers::Rpm).to receive(:new).and_return(fetcher) allow(Y2Packager::LicensesFetchers::Libzypp).to receive(:new).and_return(fetcher)
end end


describe ".find" do describe ".find" do
context "when a source is given" do context "when a source is given" do
it "uses a fetcher to build the license" do it "uses a fetcher to build the license" do
expect(Y2Packager::License).to receive(:new).with(fetcher: fetcher, content: nil) expect(Y2Packager::License).to receive(:new).with(fetcher: fetcher, content: nil)
.and_return(license) .and_return(license)
expect(described_class.find("SLES", source: :rpm)).to be(license) expect(described_class.find("SLES", source: :libzypp)).to be(license)
end end
end end


Expand All @@ -46,8 +46,8 @@


context "when a license with the same ID was already retrieved" do context "when a license with the same ID was already retrieved" do
it "returns the already retrieved instance" do it "returns the already retrieved instance" do
sles_license = described_class.find("SLES", source: :rpm) sles_license = described_class.find("SLES", source: :libzypp)
sled_license = described_class.find("SLED", source: :rpm) sled_license = described_class.find("SLED", source: :libzypp)
expect(sles_license).to be(sled_license) expect(sles_license).to be(sled_license)
end end
end end
Expand All @@ -58,8 +58,8 @@
end end


it "returns a new license instance" do it "returns a new license instance" do
sles_license = described_class.find("SLES", source: :rpm) sles_license = described_class.find("SLES", source: :libzypp)
sled_license = described_class.find("SLED", source: :rpm) sled_license = described_class.find("SLED", source: :libzypp)
expect(sles_license).to_not be(sled_license) expect(sles_license).to_not be(sled_license)
expect(sles_license.id).to_not eq(sled_license.id) expect(sles_license.id).to_not eq(sled_license.id)
end end
Expand Down
Expand Up @@ -15,7 +15,7 @@


require "y2packager/product_license" require "y2packager/product_license"


describe Y2Packager::LicensesHandlers::Rpm do describe Y2Packager::LicensesHandlers::Libzypp do
subject(:handler) { described_class.new(product_name) } subject(:handler) { described_class.new(product_name) }


let(:product_name) { "SLES" } let(:product_name) { "SLES" }
Expand Down
10 changes: 5 additions & 5 deletions library/packages/test/y2packager/product_license_test.rb
Expand Up @@ -31,17 +31,17 @@
end end


it "returns a product license for the given product" do it "returns a product license for the given product" do
expect(Y2Packager::License).to receive(:find).with("SLES", source: :rpm, content: nil) expect(Y2Packager::License).to receive(:find).with("SLES", source: :libzypp, content: nil)
.and_return(license) .and_return(license)
product_license = described_class.find("SLES", source: :rpm) product_license = described_class.find("SLES", source: :libzypp)
expect(product_license).to be_a(Y2Packager::ProductLicense) expect(product_license).to be_a(Y2Packager::ProductLicense)
expect(product_license.license).to eq(license) expect(product_license.license).to eq(license)
end end


context "when the product license was already found" do context "when the product license was already found" do
it "returns the already found instance" do it "returns the already found instance" do
cached_product_license = described_class.find("SLES", source: :rpm) cached_product_license = described_class.find("SLES", source: :libzypp)
product_license = described_class.find("SLES", source: :rpm) product_license = described_class.find("SLES", source: :libzypp)
expect(product_license).to be(cached_product_license) expect(product_license).to be(cached_product_license)
end end
end end
Expand All @@ -52,7 +52,7 @@
end end


it "returns nil" do it "returns nil" do
expect(described_class.find("SLES", source: :rpm)).to be_nil expect(described_class.find("SLES", source: :libzypp)).to be_nil
end end
end end


Expand Down
2 changes: 1 addition & 1 deletion library/packages/test/y2packager/product_test.rb
Expand Up @@ -192,7 +192,7 @@
end end


it "returns the product license" do it "returns the product license" do
expect(Y2Packager::ProductLicense).to receive(:find).with(product.name, source: :rpm) expect(Y2Packager::ProductLicense).to receive(:find).with(product.name, source: :libzypp)
.and_return(product_license) .and_return(product_license)
expect(product.license).to be(product_license) expect(product.license).to be(product_license)
end end
Expand Down

0 comments on commit 67ea5dd

Please sign in to comment.