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.


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

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


629
630
631
# File 'lib/warg.rb', line 629

def error
  @error
end

Instance Method Details

#command_finished!Object


652
653
654
655
656
657
658
659
660
661
# File 'lib/warg.rb', line 652

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


645
646
647
648
649
650
# File 'lib/warg.rb', line 645

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

  @console_status.started!
end

#durationObject


679
680
681
682
683
# File 'lib/warg.rb', line 679

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

#failed?Boolean

Returns:

  • (Boolean)

667
668
669
# File 'lib/warg.rb', line 667

def failed?
  !successful?
end

#failure_summaryObject


685
686
687
# File 'lib/warg.rb', line 685

def failure_summary
  error && error.full_message
end

#finished?Boolean

Returns:

  • (Boolean)

675
676
677
# File 'lib/warg.rb', line 675

def finished?
  not @finished_at.nil?
end

#hostObject


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

def host
  LOCALHOST
end

#started?Boolean

Returns:

  • (Boolean)

671
672
673
# File 'lib/warg.rb', line 671

def started?
  not @started_at.nil?
end

#successful?Boolean

Returns:

  • (Boolean)

663
664
665
# File 'lib/warg.rb', line 663

def successful?
  error.nil?
end

#valueObject


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

def value
  self
end