awful 0.0.58 → 0.0.59
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/awful/dynamodb.rb +26 -6
- data/lib/awful/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8d0329197de69fca5aae9365a39775d3a84b856c
|
4
|
+
data.tar.gz: 2397ed2476fb3c2a18df4600c214d1606cd0cb7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b1b14cb57678613d9db3bcca59fbaf15dfdc99d91b81ec288db87b15a63fdaa4f6fc1975f7ec5112591c64d54c8e29467f18ef829ec3d01005182843ec5ccc8
|
7
|
+
data.tar.gz: ebe445a7a23fa343d3bba4b83f6940da885bac760b14f36515f52f2421e276daff346d69d3626d540441e8495804750d3ff241bd32064012b111e9c2a84e6fa8
|
data/lib/awful/dynamodb.rb
CHANGED
@@ -2,18 +2,36 @@ module Awful
|
|
2
2
|
|
3
3
|
class DynamoDB < Cli
|
4
4
|
|
5
|
+
COLORS = {
|
6
|
+
CREATING: :yellow,
|
7
|
+
UPDATING: :yellow,
|
8
|
+
DELETING: :red,
|
9
|
+
ACTIVE: :green,
|
10
|
+
}
|
11
|
+
|
12
|
+
no_commands do
|
13
|
+
def color(string)
|
14
|
+
set_color(string, COLORS.fetch(string.to_sym, :yellow))
|
15
|
+
end
|
16
|
+
|
17
|
+
## return array of tables names matching name
|
18
|
+
def all_matching_tables(name)
|
19
|
+
dynamodb.list_tables.table_names.select do |table|
|
20
|
+
table.match(name)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
5
25
|
desc 'ls [PATTERN]', 'list dynamodb tables [matching PATTERN]'
|
6
26
|
method_option :long, aliases: '-l', default: false, desc: 'Long listing'
|
7
27
|
def ls(name = /./)
|
8
|
-
tables =
|
9
|
-
table.match(name)
|
10
|
-
end
|
28
|
+
tables = all_matching_tables(name)
|
11
29
|
|
12
30
|
if options[:long]
|
13
31
|
tables.map do |table|
|
14
32
|
dynamodb.describe_table(table_name: table).table
|
15
33
|
end.tap do |list|
|
16
|
-
print_table list.map { |t| [ t.table_name, t.table_status, t.item_count, t.table_size_bytes, t.creation_date_time ] }
|
34
|
+
print_table list.map { |t| [ t.table_name, color(t.table_status), t.item_count, t.table_size_bytes, t.creation_date_time ] }
|
17
35
|
end
|
18
36
|
else
|
19
37
|
tables.tap { |t| puts t }
|
@@ -22,8 +40,10 @@ module Awful
|
|
22
40
|
|
23
41
|
desc 'dump NAME', 'dump table with name'
|
24
42
|
def dump(name)
|
25
|
-
|
26
|
-
|
43
|
+
all_matching_tables(name).map do |table_name|
|
44
|
+
dynamodb.describe_table(table_name: table_name).table.to_hash.tap do |table|
|
45
|
+
puts YAML.dump(stringify_keys(table))
|
46
|
+
end
|
27
47
|
end
|
28
48
|
end
|
29
49
|
|
data/lib/awful/version.rb
CHANGED