Class: CfScript::Output

Inherits:
Object
  • Object
show all
Includes:
Parser, Tests, Utils
Defined in:
lib/cf_script/output.rb

Defined Under Namespace

Modules: Parser, Tests, Utils Classes: Buffer

Constant Summary

Constants included from Parser::Attributes

Parser::Attributes::ATTRIBUTE_REGEXP

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Utils

#dump

Methods included from Tests

#already_exists?, #authenticated?, #contains?, #credentials_rejected?, #failed?, #is_already?, #matches?, #no_api_endpoint?, #not_authorized?, #not_found?, #not_logged_in?, #ok?

Methods included from Parser::Table

#parse_columns, #parse_row, #parse_rows, #parse_table

Methods included from Parser::Section

#extract_section, #parse_section_attributes

Methods included from Parser::Attributes

#parse_attribute, #parse_attribute_list, #parse_line_attributes

Methods included from Utils

symbolize, symbolize_keys

Constructor Details

#initialize(command, stdout, stderr, status) ⇒ Output

Returns a new instance of Output.



19
20
21
22
23
24
# File 'lib/cf_script/output.rb', line 19

def initialize(command, stdout, stderr, status)
  @command = command
  @stdout  = stdout
  @stderr  = stderr
  @status  = status
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



10
11
12
# File 'lib/cf_script/output.rb', line 10

def command
  @command
end

#statusObject (readonly)

Returns the value of attribute status.



13
14
15
# File 'lib/cf_script/output.rb', line 13

def status
  @status
end

#stderrObject (readonly)

Returns the value of attribute stderr.



12
13
14
# File 'lib/cf_script/output.rb', line 12

def stderr
  @stderr
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



11
12
13
# File 'lib/cf_script/output.rb', line 11

def stdout
  @stdout
end

Instance Method Details

#attributesObject



42
43
44
# File 'lib/cf_script/output.rb', line 42

def attributes
  parse_attribute_list(out)
end

#attributes_from(line_start) ⇒ Object



50
51
52
# File 'lib/cf_script/output.rb', line 50

def attributes_from(line_start)
  parse_attribute_list(out.from(line_start))
end

#errObject



34
35
36
# File 'lib/cf_script/output.rb', line 34

def err
  @sane_stderr ||= Buffer.new(stderr)
end

#good?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/cf_script/output.rb', line 26

def good?
  status.success? && status.exitstatus == 0
end

#last_lineObject



38
39
40
# File 'lib/cf_script/output.rb', line 38

def last_line
  out.last_line
end

#line_attributes(line_regexp) ⇒ Object



46
47
48
# File 'lib/cf_script/output.rb', line 46

def line_attributes(line_regexp)
  parse_line_attributes(out, line_regexp)
end

#outObject



30
31
32
# File 'lib/cf_script/output.rb', line 30

def out
  @sane_stdout ||= Buffer.new(stdout)
end

#section_attributes(header) ⇒ Object



58
59
60
# File 'lib/cf_script/output.rb', line 58

def section_attributes(header)
  parse_section_attributes(out, header)
end

#table(headers) ⇒ Object



54
55
56
# File 'lib/cf_script/output.rb', line 54

def table(headers)
  parse_table(out, headers)
end