Class: Wright::Resource::File

Inherits:
Wright::Resource show all
Defined in:
lib/wright/resource/file.rb

Overview

Public: Symlink resource, represents a symlink.

Examples

file = Wright::Resource::File.new('/tmp/foo')
file.content = 'bar'
file.create

Instance Attribute Summary collapse

Attributes inherited from Wright::Resource

#action, #ignore_failure, #name, #resource_name

Instance Method Summary collapse

Methods inherited from Wright::Resource

#on_update=, #run_action

Constructor Details

#initialize(name) ⇒ File

Public: Initialize a File.

name - The file’s name.



29
30
31
32
33
34
35
36
# File 'lib/wright/resource/file.rb', line 29

def initialize(name)
  super
  @content = nil
  @mode = nil
  @owner = nil
  @group = nil
  @action = :create
end

Instance Attribute Details

#contentObject

Public: Get/Set the file’s content.



15
16
17
# File 'lib/wright/resource/file.rb', line 15

def content
  @content
end

#groupObject

Public: Get/Set the file’s group.



18
19
20
# File 'lib/wright/resource/file.rb', line 18

def group
  @group
end

#modeObject

Public: Get/Set the file’s mode.



21
22
23
# File 'lib/wright/resource/file.rb', line 21

def mode
  @mode
end

#ownerObject

Public: Get the file’s owner.



24
25
26
# File 'lib/wright/resource/file.rb', line 24

def owner
  @owner
end

Instance Method Details

#createObject

Public: Create or update the File.

Returns true if the file was updated and false otherwise.



49
50
51
52
53
# File 'lib/wright/resource/file.rb', line 49

def create
  might_update_resource do
    @provider.create
  end
end

#removeObject

Public: Remove the File.

Returns true if the file was updated and false otherwise.



58
59
60
61
62
# File 'lib/wright/resource/file.rb', line 58

def remove
  might_update_resource do
    @provider.remove
  end
end