Top Level Namespace

Instance Method Summary collapse

Instance Method Details

#color_params(ini) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/awsprofiles.rb', line 19

def color_params(ini)
  colors  = random_colors
  src     = { }

  ini.each do |s,k,v|
    case k
    when 'source_profile' then src[v] = v.colorize(colors[src.length])
    when 'role_arn'       then
      acct = (v)
      src[acct] = acct.colorize(colors[src.length % colors.length])
    end
  end
  return src
end

#color_profiles(ini) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/awsprofiles.rb', line 34

def color_profiles(ini)
  colors  = random_colors
  tar     = { }

  ini.each_section do |s|
    prof = s.gsub(/^profile /, '')
    tar[prof] = prof.colorize(colors[tar.length % colors.length])
  end
  return tar
end

#get_account(arn) ⇒ Object



15
16
17
# File 'lib/awsprofiles.rb', line 15

def (arn)
  return arn.scan(/arn:aws:.*:(.*):.*/).last.first
end

#random_colorsObject



10
11
12
13
# File 'lib/awsprofiles.rb', line 10

def random_colors
  skip_colors = [:black, :light_black, :blue, :light_blue, :default]
  return String.colors.shuffle.select { |c| not skip_colors.include? c}
end