summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2015-12-10 18:13:46 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2015-12-14 12:51:58 -0800
commit469210218eaac8f38e9062c61a49a86a1e4a69fa (patch)
treeb2bcb22e66503701bd7b750f2ce4fb37cc0ff1a8
parentb60ad97446c064c71e5e1b03b94344eb0b5c136d (diff)
downloadchef-469210218eaac8f38e9062c61a49a86a1e4a69fa.tar.gz
make file resource use properties
-rw-r--r--lib/chef/resource/file.rb79
1 files changed, 9 insertions, 70 deletions
diff --git a/lib/chef/resource/file.rb b/lib/chef/resource/file.rb
index d278652cc3..9db53b991a 100644
--- a/lib/chef/resource/file.rb
+++ b/lib/chef/resource/file.rb
@@ -1,7 +1,7 @@
#
# Author:: Adam Jacob (<adam@opscode.com>)
# Author:: Seth Chisamore (<schisamo@opscode.com>)
-# Copyright:: Copyright (c) 2008, 2011 Opscode, Inc.
+# Copyright:: Copyright (c) 2008, 2011-2015 Chef Software, Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -52,78 +52,17 @@ class Chef
def initialize(name, run_context=nil)
super
- @path = name
- @backup = 5
- @atomic_update = Chef::Config[:file_atomic_update]
- @force_unlink = false
- @manage_symlink_source = nil
- @diff = nil
@verifications = []
end
- def content(arg=nil)
- set_or_return(
- :content,
- arg,
- :kind_of => String
- )
- end
-
- def backup(arg=nil)
- set_or_return(
- :backup,
- arg,
- :kind_of => [ Integer, FalseClass ]
- )
- end
-
- def checksum(arg=nil)
- set_or_return(
- :checksum,
- arg,
- :regex => /^[a-zA-Z0-9]{64}$/
- )
- end
-
- def path(arg=nil)
- set_or_return(
- :path,
- arg,
- :kind_of => String
- )
- end
-
- def diff(arg=nil)
- set_or_return(
- :diff,
- arg,
- :kind_of => String
- )
- end
-
- def atomic_update(arg=nil)
- set_or_return(
- :atomic_update,
- arg,
- :kind_of => [ TrueClass, FalseClass ]
- )
- end
-
- def force_unlink(arg=nil)
- set_or_return(
- :force_unlink,
- arg,
- :kind_of => [ TrueClass, FalseClass ]
- )
- end
-
- def manage_symlink_source(arg=nil)
- set_or_return(
- :manage_symlink_source,
- arg,
- :kind_of => [ TrueClass, FalseClass ]
- )
- end
+ property :content, [ String, NilClass ], desired_state: false
+ property :backup, [ Integer, FalseClass ], desired_state: false, default: 5
+ property :checksum, [ String, NilClass ], is: /^[a-zA-Z0-9]{64}$/
+ property :path, [ String ], name_property: true
+ property :diff, [ String, NilClass ], desired_state: false
+ property :atomic_update, [ TrueClass, FalseClass ], desired_state: false, default: Chef::Config[:file_atomic_update]
+ property :force_unlink, [ TrueClass, FalseClass ], desired_state: false, default: false
+ property :manage_symlink_source, [ TrueClass, FalseClass ], desired_state: false
def verify(command=nil, opts={}, &block)
if ! (command.nil? || [String, Symbol].include?(command.class))