Class: Rush::Connection::Remote

Inherits:
Object
  • Object
show all
Defined in:
lib/rush/remote.rb

Overview

wrapper of command

sshfs '-o idmap=user <user_name>@<server_address>:<path> <local_path>'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(full_remote_path, local_path) ⇒ Remote

Returns a new instance of Remote.



10
11
12
13
14
15
16
17
# File 'lib/rush/remote.rb', line 10

def initialize(full_remote_path, local_path)
  local_path = local_path.full_path if local_path.respond_to?(:full_path)
  @full_remote_path = full_remote_path
  @local_path = Rush::Dir.new(local_path)
  @local_path.create unless @local_path.exists?
  @remote_user, server_and_path = *full_remote_path.split('@', 2)
  @remote_server, @remote_address = *server_and_path.split(':', 2)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



29
30
31
# File 'lib/rush/remote.rb', line 29

def method_missing(meth, *args, &block)
  @local_path.send(meth, *args, &block)
end

Instance Attribute Details

#full_remote_pathObject (readonly)

Returns the value of attribute full_remote_path.



8
9
10
# File 'lib/rush/remote.rb', line 8

def full_remote_path
  @full_remote_path
end

#local_pathObject (readonly)

Returns the value of attribute local_path.



8
9
10
# File 'lib/rush/remote.rb', line 8

def local_path
  @local_path
end

#remote_pathObject (readonly)

Returns the value of attribute remote_path.



8
9
10
# File 'lib/rush/remote.rb', line 8

def remote_path
  @remote_path
end

#remote_serverObject (readonly)

Returns the value of attribute remote_server.



8
9
10
# File 'lib/rush/remote.rb', line 8

def remote_server
  @remote_server
end

#remote_userObject (readonly)

Returns the value of attribute remote_user.



8
9
10
# File 'lib/rush/remote.rb', line 8

def remote_user
  @remote_user
end

Instance Method Details

#connectObject Also known as: mount



19
20
21
# File 'lib/rush/remote.rb', line 19

def connect
  system "sshfs -o idmap=user #{full_remote_path} #{local_path}"
end

#disconnectObject Also known as: umount



24
25
26
# File 'lib/rush/remote.rb', line 24

def disconnect
  system "fusermount -u #{local_path.full_path}"
end