Class: AssistedWorkflow::Output

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/assisted_workflow/output.rb

Overview

a helper class to provide custom shell print methods

Instance Method Summary collapse

Constructor Details

#initialize(shell) ⇒ Output

Returns a new instance of Output.



5
6
7
8
# File 'lib/assisted_workflow/output.rb', line 5

def initialize(shell)
  super
  @shell = shell
end

Instance Method Details

#next_command(title, commands) {|_commands| ... } ⇒ Object

Yields:

  • (_commands)


40
41
42
43
44
45
46
47
# File 'lib/assisted_workflow/output.rb', line 40

def next_command(title, commands, &block)
  say title, :green
  _commands = Array(commands)
  yield(_commands) if block_given?
  _commands.each do |command|
    print_wrapped command, :indent => 2
  end
end

prints as table with stories data



25
26
27
28
29
30
31
# File 'lib/assisted_workflow/output.rb', line 25

def print_stories(title, stories, options = {})
  print_title title
  rows = stories.map do |story|
    [story.id, story.current_state, story.owners_str, story.name]
  end
  print_table(rows)
end

#print_story(story) ⇒ Object



33
34
35
36
37
38
# File 'lib/assisted_workflow/output.rb', line 33

def print_story(story)
  say "-" * 40
  print_wrapped story.name.to_s, :indent => 2
  print_wrapped story.description.to_s, :indent => 2
  say "-" * 40
end

prints a highlighted title section



18
19
20
21
22
# File 'lib/assisted_workflow/output.rb', line 18

def print_title(title)
  say "-" * title.length, :green
  say title.upcase, :green
  say "-" * title.length, :green
end

#say_comment(comment) ⇒ Object

prints a wrapped gray line, showing as comments between log lines



11
12
13
14
15
# File 'lib/assisted_workflow/output.rb', line 11

def say_comment(comment)
  @shell.padding = 4
  say comment, [:black, :bold]
  @shell.padding = 0
end