Class: Monster::Remote::Sync

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(wrapper, local_dir = nil, remote_dir = nil, verbose = nil) ⇒ Sync

Returns a new instance of Sync.



8
9
10
11
12
13
# File 'lib/monster/remote/sync.rb', line 8

def initialize(wrapper, local_dir=nil, remote_dir=nil, verbose=nil)
  @wrapper = wrapper
  local_dir && @local_dir = local_dir
  remote_dir && @remote_dir = remote_dir
  verbose && @verbose = verbose
end

Instance Attribute Details

#host=(value) ⇒ Object (writeonly)

Sets the attribute host

Parameters:

  • value

    the value to set the attribute host to.



6
7
8
# File 'lib/monster/remote/sync.rb', line 6

def host=(value)
  @host = value
end

#port=(value) ⇒ Object (writeonly)

Sets the attribute port

Parameters:

  • value

    the value to set the attribute port to.



6
7
8
# File 'lib/monster/remote/sync.rb', line 6

def port=(value)
  @port = value
end

#verbose=(value) ⇒ Object (writeonly)

Sets the attribute verbose

Parameters:

  • value

    the value to set the attribute verbose to.



6
7
8
# File 'lib/monster/remote/sync.rb', line 6

def verbose=(value)
  @verbose = value
end

Instance Method Details

#start(user = nil, password = nil, host = "localhost", port = 21) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/monster/remote/sync.rb', line 15

def start(user = nil, password = nil, host = "localhost", port = 21)
  @host = host
  @port = port
  @user = user || ""
  @password = password || ""

  @wrapper || raise(MissingProtocolWrapperError)
  local_dir || raise(MissingLocalDirError)
  remote_dir || raise(MissingRemoteDirError)

  out("syncing from: #{local_dir} to: #{remote_dir}")

  open(@wrapper) do |wrapper|
    out("connection openned, using: #{wrapper}")
    copy_to_remote(wrapper, local_dir)
  end
end