lib/cfa/augeas_parser/writer.rb
# It inserts a key at given position without setting its value.
# Its logic is to set it after the last valid entry. If it is not defined
# then tries to place it before the first valid entry in tree. If there is
# no entry in tree, then does not insert a position, which means that
# subsequent setting of value appends it to the end.
#
# @param located_entry [LocatedEntry] entry to insert
# @return [String] where value should be written. Can
#   contain path expressions.
#   See https://github.com/hercules-team/augeas/wiki/Path-expressions
It inserts a key at given position without setting its value.
Its logic is to set it after the last valid entry. If it is not defined
then tries to place it before the first valid entry in tree. If there is
no entry in tree, then does not insert a position, which means that
subsequent setting of value appends it to the end.
It inserts a key at given position without setting its value . Its logic is to set it after the last valid entry . If it is not defined then tries to place it before the first valid entry in tree . If there is no entry in tree then does not insert a position which means that subsequent setting of value appends it to the end .
def insert_entry(located_entry)
        preceding = located_entry.preceding_existing
        prefix = located_entry.prefix
        if preceding
          insert_after(preceding, located_entry)
        elsif located_entry.any_following?
          aug.insert(prefix + "/*[1]", located_entry.key, true)
          aug.match(prefix + "/*[1]").first
        else
          "#{prefix}/#{located_entry.key}"
        end
      end
def insert_entry ( located_entry ) preceding = located_entry . preceding_existing prefix = located_entry . prefix if preceding insert_after ( preceding , located_entry ) elsif located_entry . any_following? aug . insert ( prefix + "/*[1]" , located_entry . key , true ) aug . match ( prefix + "/*[1]" ) . first else "#{prefix}/#{located_entry.key}" end end
It inserts a key at given position without setting its value.
It inserts a key at given position without setting its value .
# entries with add not exist yet # entries with remove is already removed, otherwise find previously
None
String
located_entry
entry to insert
entry to insert