Class: Roast::Resources::DirectoryResource
Overview
Resource implementation for directories
Instance Attribute Summary
Attributes inherited from BaseResource
#target
Instance Method Summary
collapse
#initialize
Instance Method Details
#contents ⇒ Object
20
21
22
23
24
25
|
# File 'lib/roast/resources/directory_resource.rb', line 20
def contents
if exists?
Dir.entries(target).reject { |f| f == "." || f == ".." }.join("\n")
end
end
|
#exists? ⇒ Boolean
16
17
18
|
# File 'lib/roast/resources/directory_resource.rb', line 16
def exists?
Dir.exist?(target)
end
|
#name ⇒ Object
27
28
29
30
31
32
33
|
# File 'lib/roast/resources/directory_resource.rb', line 27
def name
if target
File.basename(target) + "/"
else
"Unnamed Directory"
end
end
|
#process ⇒ Object
7
8
9
10
11
12
13
14
|
# File 'lib/roast/resources/directory_resource.rb', line 7
def process
if target.include?("*") || target.include?("?")
Dir.glob(target).select { |f| Dir.exist?(f) }.map { |d| File.expand_path(d) }.join("\n")
else
File.expand_path(target)
end
end
|
#type ⇒ Object
35
36
37
|
# File 'lib/roast/resources/directory_resource.rb', line 35
def type
:directory
end
|