Class: XmlConv::Util::DestinationDir
Constant Summary
Constants inherited
from Destination
XmlConv::Util::Destination::STATUS_COMPARABLE
Instance Attribute Summary collapse
Attributes inherited from Destination
#path, #status
Instance Method Summary
collapse
Methods inherited from Destination
book, #forget_credentials!, #sanitize, #status_comparable
Constructor Details
#initialize(uri = URI.parse('/')) ⇒ DestinationDir
62
63
64
65
|
# File 'lib/xmlconv/util/destination.rb', line 62
def initialize(uri = URI.parse('/'))
@path = uri.path
super()
end
|
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename.
61
62
63
|
# File 'lib/xmlconv/util/destination.rb', line 61
def filename
@filename
end
|
Instance Method Details
#deliver(delivery) ⇒ Object
66
67
68
69
70
|
# File 'lib/xmlconv/util/destination.rb', line 66
def deliver(delivery)
do_deliver(delivery)
@status = :pending_pickup
odba_store
end
|
#do_deliver(delivery) ⇒ Object
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/xmlconv/util/destination.rb', line 71
def do_deliver(delivery)
if(delivery.is_a?(Array))
delivery.each { |part| do_deliver(part) }
else
FileUtils.mkdir_p(@path)
@filename = delivery.filename
path = File.expand_path(sanitize(@filename), @path)
File.open(path, 'w') { |fh| fh << delivery.to_s }
end
end
|
#update_status ⇒ Object
81
82
83
84
85
86
87
|
# File 'lib/xmlconv/util/destination.rb', line 81
def update_status
if(@status == :pending_pickup \
&& !File.exist?(File.expand_path(sanitize(@filename), @path)))
@status = :picked_up
odba_store
end
end
|
#uri ⇒ Object
88
89
90
|
# File 'lib/xmlconv/util/destination.rb', line 88
def uri
URI.parse("file:#{File.expand_path(sanitize(@filename), @path)}")
end
|