Class: Gisture::File
- Inherits:
-
Object
show all
- Defined in:
- lib/gisture/file.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
39
40
41
42
|
# File 'lib/gisture/file.rb', line 39
def method_missing(meth, *args, &block)
return file.send(meth, *args, &block) if file.respond_to?(meth)
super
end
|
Instance Attribute Details
#basename ⇒ Object
Returns the value of attribute basename.
5
6
7
|
# File 'lib/gisture/file.rb', line 5
def basename
@basename
end
|
#file ⇒ Object
Returns the value of attribute file.
5
6
7
|
# File 'lib/gisture/file.rb', line 5
def file
@file
end
|
Instance Method Details
#eval!(&block) ⇒ Object
19
20
21
22
23
|
# File 'lib/gisture/file.rb', line 19
def eval!(&block)
clean_room = Evaluator.new(content)
clean_room.instance_eval &block if block_given?
clean_room
end
|
#load!(&block) ⇒ Object
13
14
15
16
17
|
# File 'lib/gisture/file.rb', line 13
def load!(&block)
loaded = load tempfile.path
unlink_tempfile
block_given? ? yield : loaded
end
|
#require!(&block) ⇒ Object
7
8
9
10
11
|
# File 'lib/gisture/file.rb', line 7
def require!(&block)
required = require tempfile.path
unlink_tempfile
block_given? ? yield : required
end
|
#respond_to_missing?(meth, include_private = false) ⇒ Boolean
44
45
46
|
# File 'lib/gisture/file.rb', line 44
def respond_to_missing?(meth, include_private=false)
file.respond_to?(meth, include_private)
end
|
#tempfile ⇒ Object
25
26
27
28
29
30
31
32
|
# File 'lib/gisture/file.rb', line 25
def tempfile
@tempfile ||= begin
file = Tempfile.new([basename, filename, ::File.extname(filename)].compact, Gisture.configuration.tmpdir)
file.write(content)
file.close
file
end
end
|
#unlink_tempfile ⇒ Object
34
35
36
37
|
# File 'lib/gisture/file.rb', line 34
def unlink_tempfile
tempfile.unlink
@tempfile = nil
end
|