Class: RServiceBus::AppResource_Dir

Inherits:
AppResource show all
Defined in:
lib/rservicebus/AppResource/Dir.rb

Instance Method Summary collapse

Methods inherited from AppResource

#Begin, #Commit, #Rollback, #_connect, #finished, #getResource, #initialize, #reconnect

Constructor Details

This class inherits a constructor from RServiceBus::AppResource

Instance Method Details

#connect(uri) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/rservicebus/AppResource/Dir.rb', line 5

def connect(uri)
    begin
        inputDir = Dir.new( uri.path )
        unless File.writable?(uri.path) then
          puts "*** Warning. Directory is not writable, #{uri.path}."
          puts "*** Warning. Make the directory, #{uri.path}, writable and try again."
        end
        rescue Errno::ENOENT => e
        puts "***** Directory does not exist, #{uri.path}."
        puts "***** Create the directory, #{uri.path}, and try again."
        puts "***** eg, mkdir #{uri.path}"
        abort();
        rescue Errno::ENOTDIR => e
        puts "***** The specified path does not point to a directory, #{uri.path}."
        puts "***** Either repoint path to a directory, or remove, #{uri.path}, and create it as a directory."
        puts "***** eg, rm #{uri.path} && mkdir #{uri.path}"
        abort();
    end
    
    return inputDir;
end