class Hookit::Resource::Link
Public Class Methods
new(name)
click to toggle source
Calls superclass method
Hookit::Resource::Base::new
# File lib/hookit/resource/link.rb, line 14 def initialize(name) target_file name unless target_file link_type :symbolic super end
Public Instance Methods
run(action)
click to toggle source
# File lib/hookit/resource/link.rb, line 20 def run(action) case action when :create create! chown! when :delete delete! end end
Protected Instance Methods
chown!()
click to toggle source
# File lib/hookit/resource/link.rb, line 52 def chown! return unless owner or group if ::File.exists? target_file `chown #{(group.nil?) ? owner : "#{owner}:#{group}"} #{target_file}` end end
create!()
click to toggle source
# File lib/hookit/resource/link.rb, line 32 def create! args = ['f'] args << 'sn' if link_type == :symbolic cmd = "ln -#{args.join} #{to} #{target_file}" `#{cmd}` code = $?.exitstatus if code != 0 raise Hookit::Error::UnexpectedExit, "#{cmd} failed with exit code '#{code}'" end end
delete!()
click to toggle source
# File lib/hookit/resource/link.rb, line 43 def delete! cmd = "rm -f #{target_file}" `#{cmd}` code = $?.exitstatus if code != 0 raise Hookit::Error::UnexpectedExit, "#{cmd} failed with exit code '#{code}'" end end