Class: HashDotRailtie

Inherits:
Rails::Railtie
  • Object
show all
Defined in:
lib/hash-dot-evil.rb

Instance Method Summary collapse

Instance Method Details

#extract_aws_creds_from_fileObject



69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/hash-dot-evil.rb', line 69

def extract_aws_creds_from_file
  aws_creds_file = "#{ENV['HOME']}/.aws/credentials"
  aws_access_key_id = ''
  aws_secret_access_key = ''
  if File.exist?(aws_creds_file)
    File.read(aws_creds_file).split("\n").each do |line|
      aws_access_key_id = line.split(' ')[2] if line =~ /aws_access_key_id/
      aws_secret_access_key = line.split(' ')[2] if line =~ /aws_secret_access_key/
    end
  end
  [aws_access_key_id, aws_secret_access_key]
end

#has_aws_creds_in_file?Boolean

Returns:

  • (Boolean)


64
65
66
67
# File 'lib/hash-dot-evil.rb', line 64

def has_aws_creds_in_file?
  aws_access_key_id, aws_secret_access_key = extract_aws_creds_from_file
  !aws_access_key_id.empty? || !aws_secret_access_key.empty?
end


53
54
55
56
57
58
59
60
61
62
# File 'lib/hash-dot-evil.rb', line 53

def print_creds(access_key_id, secret_access_key)
  #puts ''.bg(:yellow)
  puts "\n\n*********************************************************************************".red.bright
  puts "*\n* ATTENTION:  I could totally steal your AWS credentials right now if I wanted to\n*\n*".red.bright
  puts "* Your AWS creds are:\n*\n*".red.bright
  puts "*\t#{access_key_id}".red.bright
  puts "*\t#{secret_access_key}\n*".red.bright
  puts '*******************************************************************************'.red.bright
  puts ''.bg(:yellow)
end