Class: Warg::Localhost::CommandOutcome

Inherits:
Object
  • Object
show all
Defined in:
lib/warg.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCommandOutcome

Returns a new instance of CommandOutcome.



600
601
602
603
604
# File 'lib/warg.rb', line 600

def initialize
  @console_status = Console::HostStatus.new(LOCALHOST, Warg.console)
  @started_at = nil
  @finished_at = nil
end

Instance Attribute Details

#errorObject

Returns the value of attribute error.



598
599
600
# File 'lib/warg.rb', line 598

def error
  @error
end

Instance Method Details

#command_finished!Object



621
622
623
624
625
626
627
628
629
630
# File 'lib/warg.rb', line 621

def command_finished!
  @finished_at = Time.now
  @finished_at.freeze

  if successful?
    @console_status.success!
  else
    @console_status.failed!(failure_summary)
  end
end

#command_started!Object



614
615
616
617
618
619
# File 'lib/warg.rb', line 614

def command_started!
  @started_at = Time.now
  @started_at.freeze

  @console_status.started!
end

#durationObject



648
649
650
651
652
# File 'lib/warg.rb', line 648

def duration
  if @started_at && @finished_at
    @finished_at - @started_at
  end
end

#failed?Boolean

Returns:

  • (Boolean)


636
637
638
# File 'lib/warg.rb', line 636

def failed?
  !successful?
end

#failure_reasonObject



654
655
656
# File 'lib/warg.rb', line 654

def failure_reason
  error
end

#failure_summaryObject



658
659
660
# File 'lib/warg.rb', line 658

def failure_summary
  error && error.full_message
end

#finished?Boolean

Returns:

  • (Boolean)


644
645
646
# File 'lib/warg.rb', line 644

def finished?
  not @finished_at.nil?
end

#hostObject



606
607
608
# File 'lib/warg.rb', line 606

def host
  LOCALHOST
end

#started?Boolean

Returns:

  • (Boolean)


640
641
642
# File 'lib/warg.rb', line 640

def started?
  not @started_at.nil?
end

#successful?Boolean

Returns:

  • (Boolean)


632
633
634
# File 'lib/warg.rb', line 632

def successful?
  error.nil?
end

#valueObject



610
611
612
# File 'lib/warg.rb', line 610

def value
  self
end