Module: Plankton::Helpers
- Defined in:
- lib/plankton/helpers.rb
Instance Method Summary collapse
- #detailed_tags_table(tags) ⇒ Object
- #opts ⇒ Object
- #pretty_size(bytes) ⇒ Object
- #registry ⇒ Object
- #total_size(tags) ⇒ Object
Instance Method Details
#detailed_tags_table(tags) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/plankton/helpers.rb', line 22 def () return if .size.zero? headers = ['Image tag', 'Created at', 'Size'] = .sort_by { |t| t.created_at }.reverse rows = .map do |tag| [ tag.tag, tag.created_at.to_s, pretty_size(tag.layer_size) ] end puts TTY::Table.new(headers, rows).render(:basic) end |
#opts ⇒ Object
3 4 5 |
# File 'lib/plankton/helpers.rb', line 3 def opts @opts_struct ||= RecursiveOpenStruct.new() end |
#pretty_size(bytes) ⇒ Object
18 19 20 |
# File 'lib/plankton/helpers.rb', line 18 def pretty_size(bytes) Filesize.from("#{bytes} B").pretty end |
#registry ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/plankton/helpers.rb', line 7 def registry unless username? || password? return @registry ||= DockerRegistry2.connect(hostname, verbose: verbose?) end @registry ||= DockerRegistry2.connect(hostname, verbose: verbose?, user: username, password: password) end |
#total_size(tags) ⇒ Object
36 37 38 |
# File 'lib/plankton/helpers.rb', line 36 def total_size() pretty_size(.reduce(0) { |sum, t| sum + t.layer_size }) end |