class Hookit::Resource::File
Public Class Methods
new(name)
click to toggle source
Calls superclass method
Hookit::Resource::Base::new
# File lib/hookit/resource/file.rb, line 14 def initialize(name) path name unless path super end
Public Instance Methods
run(action)
click to toggle source
# File lib/hookit/resource/file.rb, line 19 def run(action) case action when :create create! chown! chmod! when :create_if_missing create_if_missing! chown! chmod! when :delete delete! when :touch touch! end end
Protected Instance Methods
chmod!()
click to toggle source
# File lib/hookit/resource/file.rb, line 59 def chmod! if ::File.exists? path and mode ::File.chmod(mode, path) end end
chown!()
click to toggle source
# File lib/hookit/resource/file.rb, line 52 def chown! return unless owner or group if ::File.exists? path `chown #{(group.nil?) ? owner : "#{owner}:#{group}"} #{path}` end end
create!()
click to toggle source
# File lib/hookit/resource/file.rb, line 38 def create! ::File.write path, (content || "") end
create_if_missing!()
click to toggle source
# File lib/hookit/resource/file.rb, line 42 def create_if_missing! if not ::File.exists? path create! end end
delete!()
click to toggle source
# File lib/hookit/resource/file.rb, line 48 def delete! ::File.delete path end
touch!()
click to toggle source
# File lib/hookit/resource/file.rb, line 65 def touch! `touch -c #{path}` end