Class: Wright::Resource::Directory

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

Overview

Directory resource, represents a directory.

Examples:

dir = Wright::Resource::Directory.new('/tmp/foobar')
dir.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) ⇒ Directory

Initializes a Directory.

Parameters:

  • name (String)

    the directory’s name



15
16
17
18
19
20
21
# File 'lib/wright/resource/directory.rb', line 15

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

Instance Attribute Details

#groupString

Returns the directory’s group.

Returns:

  • (String)

    the directory’s group



38
39
40
# File 'lib/wright/resource/directory.rb', line 38

def group
  @group
end

#modeString, Integer

Returns the directory’s mode.

Returns:

  • (String, Integer)

    the directory’s mode



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

def mode
  @mode
end

#ownerString

Returns the directory’s owner.

Returns:

  • (String)

    the directory’s owner



27
28
29
# File 'lib/wright/resource/directory.rb', line 27

def owner
  @owner
end

Instance Method Details

#createBool

Creates or updates the directory.

Returns:

  • (Bool)

    true if the directory was updated and false otherwise



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

def create
  might_update_resource do
    @provider.create
  end
end

#removeBool

Removes the directory.

Returns:

  • (Bool)

    true if the directory was updated and false otherwise



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

def remove
  might_update_resource do
    @provider.remove
  end
end