Class: Captivate::Command

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = nil) ⇒ Command

Returns a new instance of Command.



6
7
8
# File 'lib/captivate.rb', line 6

def initialize(args = nil)
  @args = args
end

Instance Attribute Details

#path ⇒ Object (readonly)

Returns the value of attribute path.



4
5
6
# File 'lib/captivate.rb', line 4

def path
  @path
end

Instance Method Details

#invoke ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/captivate.rb', line 10

def invoke
  config = Config.new(config_options).to_hash
  @host = config['host']
  @path = config['working_path']
  @remote_dir = RemoteDir.new(:host => @host, :path => @path)
  @remote_dir.upload('Capfile')
  @remote_config_dir = @remote_dir.new_subdir('config')
  @remote_config_dir.upload('config/deploy.rb')
  @remote_config_dir.upload('config/deploy') if File.directory?('config/deploy')
  @remote_script = RemoteScript.new(:command => command, :remote_path => @path)
  remote_script_path = @remote_script.local_path
  File.chmod(0555, remote_script_path)
  @remote_dir.upload(remote_script_path, 'captivate-remote.sh')
  SystemCall.new(%{ssh -t #{@host} screen #{@path}/captivate-remote.sh})
end