summaryrefslogtreecommitdiff
path: root/lib/chef/resource/windows_package.rb
diff options
context:
space:
mode:
authorJay Mundrawala <jdmundrawala@gmail.com>2015-05-05 06:12:34 -0700
committerJay Mundrawala <jdmundrawala@gmail.com>2015-05-15 07:04:19 -0700
commit53ae86b9eb116d156bed369f99be02acea86cdad (patch)
tree73919d3f188c622a45bc0e398ad0528a468694f3 /lib/chef/resource/windows_package.rb
parentfdcfa8df0a27e7e552e81e15645349696e0485c0 (diff)
downloadchef-53ae86b9eb116d156bed369f99be02acea86cdad.tar.gz
Refactor uri detection
Diffstat (limited to 'lib/chef/resource/windows_package.rb')
-rw-r--r--lib/chef/resource/windows_package.rb16
1 files changed, 3 insertions, 13 deletions
diff --git a/lib/chef/resource/windows_package.rb b/lib/chef/resource/windows_package.rb
index de4f2573d4..c02d38fba9 100644
--- a/lib/chef/resource/windows_package.rb
+++ b/lib/chef/resource/windows_package.rb
@@ -16,6 +16,7 @@
# limitations under the License.
#
+require 'chef/mixin/uris'
require 'chef/resource/package'
require 'chef/provider/package/windows'
require 'chef/win32/error' if RUBY_PLATFORM =~ /mswin|mingw|windows/
@@ -23,6 +24,7 @@ require 'chef/win32/error' if RUBY_PLATFORM =~ /mswin|mingw|windows/
class Chef
class Resource
class WindowsPackage < Chef::Resource::Package
+ include Chef::Mixin::Uris
provides :package, os: "windows"
provides :windows_package, os: "windows"
@@ -69,7 +71,7 @@ class Chef
@source
else
raise ArgumentError, "Bad type for WindowsPackage resource, use a String" unless arg.is_a?(String)
- if is_url?(arg)
+ if uri_scheme?(arg)
@source = arg
else
@source = ::File.absolute_path(arg).gsub(::File::SEPARATOR, ::File::ALT_SEPARATOR)
@@ -77,18 +79,6 @@ class Chef
end
end
- private
-
- def is_url?(source)
- begin
- scheme = URI.split(source).first
- return false unless scheme
- %w(http https ftp file).include?(scheme.downcase)
- rescue URI::InvalidURIError
- return false
- end
- end
-
end
end
end