summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-04-27 16:33:37 -0700
committerTim Smith <tsmith@chef.io>2018-04-27 16:54:52 -0700
commit3ac7383d286f0aba074f1062530c107fd73e6db4 (patch)
tree574b07b3d498ce471a985f677972670032f8736a
parent2651a43b251f209a63ebc814330271ec5f1735b2 (diff)
downloadchef-remote_directory.tar.gz
Convert some of remote_directory to use propertiesremote_directory
This isn't all of it, but it's a start Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/resource/remote_directory.rb50
-rw-r--r--spec/unit/resource/remote_directory_spec.rb4
2 files changed, 7 insertions, 47 deletions
diff --git a/lib/chef/resource/remote_directory.rb b/lib/chef/resource/remote_directory.rb
index 677f358cc2..fdafb4c8f4 100644
--- a/lib/chef/resource/remote_directory.rb
+++ b/lib/chef/resource/remote_directory.rb
@@ -41,16 +41,11 @@ class Chef
def initialize(name, run_context = nil)
super
@path = name
- @source = ::File.basename(name)
@delete = false
@recursive = true
- @purge = false
- @files_backup = 5
@files_owner = nil
@files_group = nil
@files_mode = 0644 unless Chef::Platform.windows?
- @overwrite = true
- @cookbook = nil
end
if Chef::Platform.windows?
@@ -58,29 +53,11 @@ class Chef
rights_attribute(:files_rights)
end
- def source(args = nil)
- set_or_return(
- :source,
- args,
- :kind_of => String
- )
- end
-
- def files_backup(arg = nil)
- set_or_return(
- :files_backup,
- arg,
- :kind_of => [ Integer, FalseClass ]
- )
- end
-
- def purge(arg = nil)
- set_or_return(
- :purge,
- arg,
- :kind_of => [ TrueClass, FalseClass ]
- )
- end
+ property :source, String, default: lazy { ::File.basename(name) }
+ property :files_backup, [ Integer, FalseClass ], default: 5, desired_state: false
+ property :purge, [ TrueClass, FalseClass ], default: false, desired_state: false
+ property :overwrite, [ TrueClass, FalseClass ], default: false
+ property :cookbook, String
def files_group(arg = nil)
set_or_return(
@@ -105,23 +82,6 @@ class Chef
:regex => Chef::Config[:user_valid_regex]
)
end
-
- def overwrite(arg = nil)
- set_or_return(
- :overwrite,
- arg,
- :kind_of => [ TrueClass, FalseClass ]
- )
- end
-
- def cookbook(args = nil)
- set_or_return(
- :cookbook,
- args,
- :kind_of => String
- )
- end
-
end
end
end
diff --git a/spec/unit/resource/remote_directory_spec.rb b/spec/unit/resource/remote_directory_spec.rb
index c016213c4a..d9cef7edd9 100644
--- a/spec/unit/resource/remote_directory_spec.rb
+++ b/spec/unit/resource/remote_directory_spec.rb
@@ -22,7 +22,7 @@ describe Chef::Resource::RemoteDirectory do
let(:resource) { Chef::Resource::RemoteDirectory.new("/etc/dunk") }
- it "sets the path to the first argument to new" do
+ it "path is the name property" do
expect(resource.path).to eql("/etc/dunk")
end
@@ -45,7 +45,7 @@ describe Chef::Resource::RemoteDirectory do
expect(resource.files_backup).to eql(false)
end
- it "accepts 3 or 4 digets for the files_mode" do
+ it "accepts 3 or 4 digits for the files_mode" do
resource.files_mode 100
expect(resource.files_mode).to eql(100)
resource.files_mode 1000