diff options
author | mwrock <matt@mattwrock.com> | 2020-09-04 18:46:27 -0700 |
---|---|---|
committer | mwrock <matt@mattwrock.com> | 2020-09-08 14:46:36 -0700 |
commit | 41ae92bd5070b450e04f02ae9a1d30987d14bb93 (patch) | |
tree | 952399197c5344e29a648560fda242ef77a7dd7e /lib/chef/resource/windows_printer.rb | |
parent | 313afa345a0d19019218807a16bf6fdd6447a87b (diff) | |
download | chef-41ae92bd5070b450e04f02ae9a1d30987d14bb93.tar.gz |
use autoloading for many required gems
Signed-off-by: mwrock <matt@mattwrock.com>
Diffstat (limited to 'lib/chef/resource/windows_printer.rb')
-rw-r--r-- | lib/chef/resource/windows_printer.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/chef/resource/windows_printer.rb b/lib/chef/resource/windows_printer.rb index 947477baeb..dea15ba112 100644 --- a/lib/chef/resource/windows_printer.rb +++ b/lib/chef/resource/windows_printer.rb @@ -24,7 +24,7 @@ class Chef class WindowsPrinter < Chef::Resource unified_mode true - require "resolv" + autoload :Resolv, "resolv" provides(:windows_printer) { true } @@ -78,8 +78,10 @@ class Chef property :ipv4_address, String, description: "The IPv4 address of the printer, such as `10.4.64.23`", - validation_message: "The ipv4_address property must be in the IPv4 format of `WWW.XXX.YYY.ZZZ`", - regex: Resolv::IPv4::Regex + callbacks: { + "The ipv4_address property must be in the IPv4 format of `WWW.XXX.YYY.ZZZ`" => + proc { |v| v.match(Resolv::IPv4::Regex) }, + } PRINTERS_REG_KEY = 'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Print\Printers\\'.freeze unless defined?(PRINTERS_REG_KEY) |