Class: Wright::Resource::File

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

Overview

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

Initializes a File.

Parameters:

  • name (String)

    the file’s name



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

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

Instance Attribute Details

#contentString

Returns the file’s intended content.

Returns:

  • (String)

    the file’s intended content



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

def content
  @content
end

#groupString

Returns the file’s intended group.

Returns:

  • (String)

    the file’s intended group



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

def group
  @group
end

#modeString, Integer

Returns the file’s intended mode.

Returns:

  • (String, Integer)

    the file’s intended mode



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

def mode
  @mode
end

#ownerString

Returns the file’s intended owner.

Returns:

  • (String)

    the file’s intended owner



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

def owner
  @owner
end

Instance Method Details

#createBool

Creates or updates the file.

Returns:

  • (Bool)

    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

#removeBool

Removes the file.

Returns:

  • (Bool)

    true if the file was updated and false otherwise



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

def remove
  might_update_resource do
    @provider.remove
  end
end