Class: RServiceBus2::AppResourceDir

Inherits:
AppResource show all
Defined in:
lib/rservicebus2/appresource/dir.rb

Overview

AppResourceDir

Instance Attribute Summary

Attributes inherited from AppResource

#connection

Instance Method Summary collapse

Methods inherited from AppResource

#_connect, #begin, #commit, #finished, #get_resource, #initialize, #reconnect, #rollback

Constructor Details

This class inherits a constructor from RServiceBus2::AppResource

Instance Method Details

#connect(uri) ⇒ Object

rubocop:disable Metrics/AbcSize,Metrics/MethodLength



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/rservicebus2/appresource/dir.rb', line 5

def connect(uri)
  begin
    input_dir = Dir.new(uri.path)
    unless File.writable?(uri.path)
      puts "*** Warning. Directory is not writable, #{uri.path}."
      puts "*** Warning. Make the directory, #{uri.path}, writable and try
            again."
    end
  rescue Errno::ENOENT
    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
    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

  input_dir
end