diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-12-15 14:08:49 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-12-15 14:08:49 -0800 |
commit | d14efdb0be57f59a0e93ba96c7342fd29fc8e656 (patch) | |
tree | f70395f9c813bb69d0ee96611a39b3264ea2392b | |
parent | 1ce528e4a36bb6aad6eb03cf94e3cb7af11a2ed1 (diff) | |
download | chef-d14efdb0be57f59a0e93ba96c7342fd29fc8e656.tar.gz |
also extract out the utility class
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r-- | lib/chef/provider/package/dnf.rb | 32 | ||||
-rw-r--r-- | lib/chef/provider/package/dnf/python_helper.rb | 1 | ||||
-rw-r--r-- | lib/chef/provider/package/dnf/version.rb | 56 |
3 files changed, 58 insertions, 31 deletions
diff --git a/lib/chef/provider/package/dnf.rb b/lib/chef/provider/package/dnf.rb index 0d026a49b7..84594bf4a6 100644 --- a/lib/chef/provider/package/dnf.rb +++ b/lib/chef/provider/package/dnf.rb @@ -20,6 +20,7 @@ require "chef/resource/dnf_package" require "chef/mixin/which" require "chef/mixin/get_source_from_package" require "chef/provider/package/dnf/python_helper" +require "chef/provider/package/dnf/version" class Chef class Provider @@ -28,37 +29,6 @@ class Chef extend Chef::Mixin::Which include Chef::Mixin::GetSourceFromPackage - # helper class to assist in passing around name/version/arch triples - class Version - attr_accessor :name - attr_accessor :version - attr_accessor :arch - - def initialize(name, version, arch) - @name = name - @version = version - @arch = arch - end - - def to_s - "#{name}-#{version}.#{arch}" - end - - def version_with_arch - "#{version}.#{arch}" unless version.nil? - end - - def matches_name_and_arch?(other) - other.version == version && other.arch == arch - end - - def ==(other) - name == other.name && version == other.version && arch == other.arch - end - - alias_method :eql?, :== - end - allow_nils use_multipackage_api use_package_name_for_source diff --git a/lib/chef/provider/package/dnf/python_helper.rb b/lib/chef/provider/package/dnf/python_helper.rb index b2538ef5b9..ff5f66cb17 100644 --- a/lib/chef/provider/package/dnf/python_helper.rb +++ b/lib/chef/provider/package/dnf/python_helper.rb @@ -15,6 +15,7 @@ # limitations under the License. # +require "chef/provider/package/dnf/version" require "timeout" class Chef diff --git a/lib/chef/provider/package/dnf/version.rb b/lib/chef/provider/package/dnf/version.rb new file mode 100644 index 0000000000..b326913c3a --- /dev/null +++ b/lib/chef/provider/package/dnf/version.rb @@ -0,0 +1,56 @@ +# +# Copyright:: Copyright 2016, Chef Software, Inc. +# License:: Apache License, Version 2.0 +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +class Chef + class Provider + class Package + class Dnf < Chef::Provider::Package + + # helper class to assist in passing around name/version/arch triples + class Version + attr_accessor :name + attr_accessor :version + attr_accessor :arch + + def initialize(name, version, arch) + @name = name + @version = version + @arch = arch + end + + def to_s + "#{name}-#{version}.#{arch}" + end + + def version_with_arch + "#{version}.#{arch}" unless version.nil? + end + + def matches_name_and_arch?(other) + other.version == version && other.arch == arch + end + + def ==(other) + name == other.name && version == other.version && arch == other.arch + end + + alias_method :eql?, :== + end + end + end + end +end |