Class: InteractiveS3::Commands::InternalCommand::Chdir

Inherits:
Base
  • Object
show all
Defined in:
lib/interactive_s3/commands/internal_command.rb

Instance Attribute Summary

Attributes inherited from Base

#arguments, #name, #s3, #state

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from InteractiveS3::Commands::Base

Instance Method Details

#executeObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/interactive_s3/commands/internal_command.rb', line 8

def execute
  state[:previous_stack] ||= []

  if target.nil?
    state[:previous_stack] = s3.stack
    s3.reset
    return
  elsif target.strip == '-'
    s3.stack, state[:previous_stack] = state[:previous_stack], s3.stack
  else
    target.sub!('s3://', '/')
    state[:previous_stack] = s3.stack
    s3.stack = InteractiveS3::S3Path.new(target, s3.stack).resolve
  end
ensure
  unless s3.exists?
    s3.stack = state[:previous_stack]
  end
end