awsam 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/awsam/ec2.rb +28 -4
  2. data/lib/awsam/version.rb +1 -1
  3. metadata +4 -4
@@ -84,22 +84,46 @@ module Awsam
84
84
  puts "Please select which node you wish to use:"
85
85
  puts
86
86
 
87
+ namemax = 0
88
+ instmax = 0
89
+ ipmax = 0
87
90
  results.each_with_index do |elem, i|
88
91
  inst = rmap[elem[:resource_id]]
89
- puts "%d) %s (%s, %s, %s, %s)" %
90
- [i+1, elem[:value], inst[:aws_instance_id],
92
+ if elem[:value].length > namemax
93
+ namemax = elem[:value].length
94
+ end
95
+ if inst[:aws_instance_id].length > instmax
96
+ instmax = inst[:aws_instance_id].length
97
+ end
98
+ if inst[:private_ip_address].length > ipmax
99
+ ipmax =inst[:private_ip_address].length
100
+ end
101
+ end
102
+
103
+ countmax = results.size.to_s.length
104
+ results.each_with_index do |elem, i|
105
+ inst = rmap[elem[:resource_id]]
106
+
107
+ puts "%*d) %-*s (%*s %*s %11s %s %s)" %
108
+ [countmax, i + 1,
109
+ namemax, elem[:value],
110
+ instmax, inst[:aws_instance_id],
111
+ ipmax, inst[:private_ip_address],
91
112
  inst[:aws_instance_type],
92
113
  inst[:aws_availability_zone],
93
114
  inst[:aws_launch_time]]
94
115
  end
95
- puts "q) Quit"
116
+ puts "%*s) Quit" % [countmax, "q"]
96
117
  puts
97
118
 
98
119
  print "> "
99
120
  input = $stdin.gets
100
121
  puts
101
122
  exit unless input =~ /^\d+$/
102
- node = results[input.to_i-1]
123
+ sel = input.to_i
124
+ exit unless sel > 0 && sel <= results.size
125
+
126
+ node = results[sel - 1]
103
127
  end
104
128
 
105
129
  return rmap[node[:resource_id]]
@@ -1,3 +1,3 @@
1
1
  module Awsam
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awsam
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-03-14 00:00:00.000000000 Z
12
+ date: 2016-06-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: right_aws
@@ -119,7 +119,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
119
119
  version: '0'
120
120
  segments:
121
121
  - 0
122
- hash: -2225821481215170753
122
+ hash: -1945513254015237322
123
123
  required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  none: false
125
125
  requirements:
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  version: '0'
129
129
  segments:
130
130
  - 0
131
- hash: -2225821481215170753
131
+ hash: -1945513254015237322
132
132
  requirements: []
133
133
  rubyforge_project:
134
134
  rubygems_version: 1.8.23.2