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.
- checksums.yaml +4 -4
- data/lib/s3tatistic/formatter.rb +27 -0
- metadata +2 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: a0a716a1e7bf6bd56a9912986383b93b824aae72
         | 
| 4 | 
            +
              data.tar.gz: daa5686f9a08bc9b1fd7bb19a9a2edf936869323
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 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. | 
| 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
         |