Module: Kafkat::Formatting
- Included in:
- Command::Base
- Defined in:
- lib/kafkat/utility/formatting.rb
Instance Method Summary collapse
- #justify(field, width = 2) ⇒ Object
- #print_assignment(assignment) ⇒ Object
- #print_assignment_header ⇒ Object
- #print_broker(broker) ⇒ Object
- #print_broker_header ⇒ Object
- #print_partition(partition) ⇒ Object
- #print_partition_header ⇒ Object
- #print_topic(topic) ⇒ Object
- #print_topic_header ⇒ Object
- #print_topic_name(topic_name) ⇒ Object
Instance Method Details
#justify(field, width = 2) ⇒ Object
3 4 5 6 7 |
# File 'lib/kafkat/utility/formatting.rb', line 3 def justify(field, width=2) field = field.to_s count = [width - (field.length / 8), 1].max field + "\t" * count end |
#print_assignment(assignment) ⇒ Object
54 55 56 57 58 59 |
# File 'lib/kafkat/utility/formatting.rb', line 54 def print_assignment(assignment) print justify(assignment.topic_name) print justify(assignment.partition_id) print justify(assignment.replicas.inspect) print "\n" end |
#print_assignment_header ⇒ Object
61 62 63 64 65 66 |
# File 'lib/kafkat/utility/formatting.rb', line 61 def print_assignment_header print justify('Topic') print justify('Partition') print justify('Replicas') print "\n" end |
#print_broker(broker) ⇒ Object
9 10 11 12 13 |
# File 'lib/kafkat/utility/formatting.rb', line 9 def print_broker(broker) print justify(broker.id) print justify("#{broker.host}:#{broker.port}") print "\n" end |
#print_broker_header ⇒ Object
15 16 17 18 19 |
# File 'lib/kafkat/utility/formatting.rb', line 15 def print_broker_header print justify('Broker') print justify('Socket') print "\n" end |
#print_partition(partition) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/kafkat/utility/formatting.rb', line 36 def print_partition(partition) print justify(partition.topic_name) print justify(partition.id) print justify(partition.leader || 'none') print justify(partition.replicas.inspect, 7) print justify(partition.isr.inspect, 7) print "\n" end |
#print_partition_header ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/kafkat/utility/formatting.rb', line 45 def print_partition_header print justify('Topic') print justify('Partition') print justify('Leader') print justify('Replicas', 7) print justify('ISRs', 7) print "\n" end |
#print_topic(topic) ⇒ Object
21 22 23 24 |
# File 'lib/kafkat/utility/formatting.rb', line 21 def print_topic(topic) print justify(topic.name) print "\n" end |
#print_topic_header ⇒ Object
31 32 33 34 |
# File 'lib/kafkat/utility/formatting.rb', line 31 def print_topic_header print justify('Topic') print "\n" end |
#print_topic_name(topic_name) ⇒ Object
26 27 28 29 |
# File 'lib/kafkat/utility/formatting.rb', line 26 def print_topic_name(topic_name) print justify(topic_name) print "\n" end |