class GitTopic::Formatter::Topics
summarizes topics information Topic
means theme that not start to implement
Constants
- LIST_TOPIC_COMMAND
- Topic
Public Instance Methods
print()
click to toggle source
# File lib/git_topic/formatter/topics.rb, line 13 def print puts "#{bold}[Topics]#{clear}" topics = parse_topics print_header print_contents topics end
Private Instance Methods
parse_topic(line)
click to toggle source
# File lib/git_topic/formatter/topics.rb, line 41 def parse_topic(line) matched = line.match(/topic\.(?<topic_name>\S+)\s+(?<summary>.*)/) raise 'cannot parse topic' unless matched topic_name = matched[:topic_name] summary = matched[:summary] [topic_name, summary] end
parse_topics()
click to toggle source
# File lib/git_topic/formatter/topics.rb, line 31 def parse_topics topics = [] _stdin, stdout, _stderr, _wait_thr = *Open3.popen3(LIST_TOPIC_COMMAND) stdout.each do |line| name, summary = parse_topic(line) topics << Topic.new(name, summary) end topics end
print_contents(topics)
click to toggle source
# File lib/git_topic/formatter/topics.rb, line 49 def print_contents(topics) topics.each do |topic| print_line topic end end
print_header()
click to toggle source
# File lib/git_topic/formatter/topics.rb, line 22 def print_header header_format = ' %-20s %s' puts format(header_format, :Topic, :Summary) puts '-' * 80 end
print_line(topic)
click to toggle source
# File lib/git_topic/formatter/topics.rb, line 55 def print_line(topic) truncated_name = truncate(topic.name) summary = topic.summary puts format(" #{bold}%-20s#{clear} %s", truncated_name, summary) end