module CfScript::Output::Parser::Attributes

Constants

ATTRIBUTE_REGEXP

Public Instance Methods

parse_attribute(line, symbolize_name = false) click to toggle source
# File lib/cf_script/output/parser/attributes.rb, line 5
def parse_attribute(line, symbolize_name = false)
  if line =~ ATTRIBUTE_REGEXP
    name  = Regexp.last_match[:name].strip
    value = Regexp.last_match[:value].strip

    CfScript::Attribute.new(
      symbolize_name ? symbolize(name) : name,
      value
    )
  end
end
parse_attribute_list(buffer, symbolize_names = true) click to toggle source
# File lib/cf_script/output/parser/attributes.rb, line 17
def parse_attribute_list(buffer, symbolize_names = true)
  attribute_list = CfScript::AttributeList.new

  buffer.each_line do |line|
    if attribute = parse_attribute(line, symbolize_names)
      attribute_list << attribute
    end
  end

  attribute_list
end
parse_line_attributes(buffer, regexp) click to toggle source
# File lib/cf_script/output/parser/attributes.rb, line 29
def parse_line_attributes(buffer, regexp)
  if matched = buffer.match(regexp)
    attribute_list = CfScript::AttributeList.new

    matched.names.each do |name|
      attribute_list << CfScript::Attribute.new(
        symbolize(name),
        matched[name].strip
      )
    end

    attribute_list
  end
end