Class: InteractiveS3::Commands::S3Command

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

Constant Summary collapse

S3_PATH_PREFIX =
/^s3:\/\//
LOCAL_PATH_PREFIX =
/^:/
OPTION_PREFIX =
/^--/
HELP_SUB_COMMAND =
/^help$/
TARGET_SUB_COMMANDS =
%w(mv rb rm).freeze

Instance Attribute Summary

Attributes inherited from Base

#arguments, #name, #s3, #state

Instance Method Summary collapse

Constructor Details

#initialize(context, name, arguments = []) ⇒ S3Command

Returns a new instance of S3Command.



9
10
11
12
# File 'lib/interactive_s3/commands/s3_command.rb', line 9

def initialize(context, name, arguments = [])
  super
  parse_arguments
end

Instance Method Details

#executeObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/interactive_s3/commands/s3_command.rb', line 14

def execute
  pid = Process.spawn(
    *command_with_arguments,
    out: $stdout,
    err: $stderr
  )
  wait_for_process(pid)
  $? && $?.success?
rescue SystemCallError => e
  puts e.message
  false
ensure
  if reset_target?
    s3.reset unless s3.exists?
  end
end