diff options
author | Tim Smith <tsmith@chef.io> | 2017-09-30 13:54:44 -0700 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2018-02-26 12:22:02 -0800 |
commit | ff88ebeda1c9444cd4b10d2a1b0dd8f06a7784ff (patch) | |
tree | c83c779aacff7d3f98daeae192419770b554e44b | |
parent | 2e25f81b11cb6bb79240757efb85eb05baa60610 (diff) | |
download | chef-ff88ebeda1c9444cd4b10d2a1b0dd8f06a7784ff.tar.gz |
Extract repo components logic into its own method
Same old: Easier to read, easier to test
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/chef/provider/apt_repository.rb | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/chef/provider/apt_repository.rb b/lib/chef/provider/apt_repository.rb index af4ed10d07..40a9761a52 100644 --- a/lib/chef/provider/apt_repository.rb +++ b/lib/chef/provider/apt_repository.rb @@ -58,16 +58,10 @@ class Chef action :nothing end - components = if is_ppa_url?(new_resource.uri) && new_resource.components.empty? - "main" - else - new_resource.components - end - repo = build_repo( new_resource.uri, new_resource.distribution, - components, + repo_components, new_resource.trusted, new_resource.arch, new_resource.deb_src @@ -252,6 +246,20 @@ class Chef url.start_with?("ppa:") end + # determine the repository's components: + # - "components" property if defined + # - "main" if "components" not defined and the repo is a PPA URL + # - otherwise nothing + # + # @return [String] the repository component + def repo_components + if is_ppa_url?(new_resource.uri) && new_resource.components.empty? + "main" + else + new_resource.components + end + end + def make_ppa_url(ppa) return unless is_ppa_url?(ppa) owner, repo = ppa[4..-1].split("/") |