awful 0.0.58 → 0.0.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82532df739883f1b25a7b7be0b92fd88c521028a
4
- data.tar.gz: dfdb638efb7a51acb47aefdcb8f5e7bc6df13acb
3
+ metadata.gz: 8d0329197de69fca5aae9365a39775d3a84b856c
4
+ data.tar.gz: 2397ed2476fb3c2a18df4600c214d1606cd0cb7a
5
5
  SHA512:
6
- metadata.gz: f2bd86aa8d5c5345aec0cff44296722f1f878e523c528ac7f7390349a217a89b00aede555558614bc4ad8ce32f2578b529c952464cd176a3a4a07c904a4a5dfc
7
- data.tar.gz: 78d510e6dc5a29c80f8e32e110f952d655eb5c04f658eef2520709a6076396e620e0ee9f8623a49435ae7afb3b27af80e61a166a03e38565910cea6e207e5ff8
6
+ metadata.gz: 3b1b14cb57678613d9db3bcca59fbaf15dfdc99d91b81ec288db87b15a63fdaa4f6fc1975f7ec5112591c64d54c8e29467f18ef829ec3d01005182843ec5ccc8
7
+ data.tar.gz: ebe445a7a23fa343d3bba4b83f6940da885bac760b14f36515f52f2421e276daff346d69d3626d540441e8495804750d3ff241bd32064012b111e9c2a84e6fa8
@@ -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 = dynamodb.list_tables.table_names.select do |table|
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
- dynamodb.describe_table(table_name: name).table.tap do |table|
26
- puts YAML.dump(stringify_keys(table.to_hash))
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
 
@@ -1,3 +1,3 @@
1
1
  module Awful
2
- VERSION = "0.0.58"
2
+ VERSION = "0.0.59"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awful
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.58
4
+ version: 0.0.59
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ric Lister