Class: Roast::Resources::FileResource
Overview
Resource implementation for files
Instance Attribute Summary
Attributes inherited from BaseResource
#target
Instance Method Summary
collapse
#initialize
Instance Method Details
#contents ⇒ Object
20
21
22
|
# File 'lib/roast/resources/file_resource.rb', line 20
def contents
File.read(target) if exists?
end
|
#exists? ⇒ Boolean
16
17
18
|
# File 'lib/roast/resources/file_resource.rb', line 16
def exists?
File.exist?(target) && !Dir.exist?(target)
end
|
#name ⇒ Object
24
25
26
|
# File 'lib/roast/resources/file_resource.rb', line 24
def name
File.basename(target) if target
end
|
#process ⇒ Object
7
8
9
10
11
12
13
14
|
# File 'lib/roast/resources/file_resource.rb', line 7
def process
if target.include?("*") || target.include?("?")
Dir.glob(target).map { |f| File.expand_path(f) unless Dir.exist?(f) }.compact.join("\n")
else
File.expand_path(target)
end
end
|
#type ⇒ Object
28
29
30
|
# File 'lib/roast/resources/file_resource.rb', line 28
def type
:file
end
|