Class: Hexx::Suit::Utils::System Private

Inherits:
String
  • Object
show all
Defined in:
lib/hexx/suit/utils/system.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

The utility sends multiline string to system

Allows stubbing system calls in specifications.

Examples:

System.call %(
  inch --pedantic
  rubocop
)

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ undefined

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializes multiline text to be sent to system

Removes repetitive spaces from itself

Parameters:

  • text (#to_s)

    Multiline text to be sent to system


28
29
30
31
32
# File 'lib/hexx/suit/utils/system.rb', line 28

def initialize(text)
  super
  strip!
  gsub!(/ {2,}/, " ")
end

Class Method Details

.call(text) ⇒ Hexx::Suit::Utils::System

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Sends multiline string to system

Examples:

System.call %(
  inch --pedantic
  rubocop
)

Parameters:

  • text (#to_s)

    Multiline text to be sent to system

Returns:


58
59
60
61
62
# File 'lib/hexx/suit/utils/system.rb', line 58

def self.call(text)
  new(text).call

  self
end

Instance Method Details

#callself

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Sends itself to system line by line

Returns:

  • (self)

44
45
46
47
48
# File 'lib/hexx/suit/utils/system.rb', line 44

def call
  lines.each(&method(:system))

  self
end

#linesArray<String>

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns non-empty lines without trailing spaces

Returns:

  • (Array<String>)

37
38
39
# File 'lib/hexx/suit/utils/system.rb', line 37

def lines
  super.map(&:strip).reject(&:empty?)
end