Class: DearS3::Cli::AuthenticationHelper

Inherits:
Object
  • Object
show all
Includes:
Thor::Shell
Defined in:
lib/dears3/cli/authentication_helper.rb

Instance Method Summary collapse

Constructor Details

#initialize(authentication) ⇒ AuthenticationHelper

Returns a new instance of AuthenticationHelper.



6
7
8
# File 'lib/dears3/cli/authentication_helper.rb', line 6

def initialize authentication
  @authentication = authentication
end

Instance Method Details

#connectObject



10
11
12
13
14
15
16
17
# File 'lib/dears3/cli/authentication_helper.rb', line 10

def connect
  begin
    authentication.connect
  rescue Errno::ENOENT
    say "Credentials file not found. Please run 's3:auth' to authenticate.", :red
    abort
  end
end

#maybe_get_credentialsObject



23
24
25
26
27
28
29
# File 'lib/dears3/cli/authentication_helper.rb', line 23

def maybe_get_credentials
  if File.exists?(credentials_path) && !override_credentials?
    nil
  else
    request_credentials
  end
end

#save_credentials!(credentials) ⇒ Object



19
20
21
# File 'lib/dears3/cli/authentication_helper.rb', line 19

def save_credentials! credentials
  authentication.create_credentials_file! credentials
end