s3tatistic 0.1.0 → 0.1.1

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/s3tatistic/formatter.rb +27 -0
  3. metadata +2 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f1a280d4769e8428c710252ddf3ef1dbc952e3f5
4
- data.tar.gz: 9c04845ad85429683d3e28443446bf6201bdf048
3
+ metadata.gz: a0a716a1e7bf6bd56a9912986383b93b824aae72
4
+ data.tar.gz: daa5686f9a08bc9b1fd7bb19a9a2edf936869323
5
5
  SHA512:
6
- metadata.gz: 5e92c81951296796e8d7fdcc86a43270579bc805bb0dcb4d6aa006869ae3b364e2835977e9821444d01741253d4c4e5ee7b90004d9226f0c95d141eca259f775
7
- data.tar.gz: ed87bb2c998caf171e41ea017d932f6994a634a6321642b7626d19ef5495e1f7325832deda51d32213a2dded8ce7cb89a03210e78fe7602805c405d580c196c4
6
+ metadata.gz: 25235f0f8add457fc1c7660260fa2e93db37db63f0f6757681eff8e09b11aa762ab338f94b951419d06515481b3c5e367947b6886b8bfe5f915b84ab1537ce5f
7
+ data.tar.gz: f496fa34dcf7a9ef1934f39c4ec7fda2221505f4ea3b3b37946413d423bad452905a8dfe315bf9992883c4cb884845f8b1ee52b015f865dfee11c87baaa3e0a6
@@ -0,0 +1,27 @@
1
+ require 'tty-table'
2
+ require 'humanize-bytes'
3
+
4
+ class S3tatistic::Formatter
5
+ class << self
6
+ def format_buckets(buckets, options)
7
+ first, = buckets
8
+ headers = first.keys
9
+ rows = buckets
10
+ .map(&:values)
11
+ .map { |b| format_size(b, options.block) }
12
+
13
+ table = TTY::Table.new(headers, rows)
14
+ table.render(:basic)
15
+ end
16
+
17
+ def format_bucket_info(bucket)
18
+ end
19
+
20
+ def format_size(values, format)
21
+ puts "values[3] : #{values[3]}"
22
+ formatted = Humanize::Byte.new(values[3]).public_send("to_#{format}")
23
+ values[3] = "#{formatted} #{format}b"
24
+ values
25
+ end
26
+ end
27
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3tatistic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien Lucca
@@ -20,6 +20,7 @@ files:
20
20
  - bin/s3tatistic
21
21
  - lib/s3tatistic.rb
22
22
  - lib/s3tatistic/amazon_s3.rb
23
+ - lib/s3tatistic/formatter.rb
23
24
  homepage:
24
25
  licenses:
25
26
  - MIT