Skip to content
Ruby bindings for Augeas
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
ext/augeas
lib
tests
.gitignore
.travis.yml
AUTHORS
COPYING
Gemfile
NEWS
README.md
Rakefile
ruby-augeas.spec

README.md

Ruby bindings for augeas

The class Augeas provides bindings to Augeas library.

Building

To build the bindings, which unfortunately includes installing them from a gem, you need to have Augeas and its header file installed as well as pkg-config.

On Fedora, you can do that simply by running

dnf install augeas-devel pkgconfig

On OSX, you need to set up Homebrew and then run

brew install augeas pkg-config

Usage

Setting Data

    Augeas::open do |aug|
      aug.set("/files/etc/sysconfig/firstboot/RUN_FIRSTBOOT", "YES")
      unless aug.save
        raise IOError, "Failed to save changes"
      end
    end

Accessing Data

    firstboot = Augeas::open { |aug| aug.get("/files/etc/sysconfig/firstboot/RUN_FIRSTBOOT") }

Removing Data

    Augeas::open do |aug|
      aug.rm("/files/etc/sysconfig/firstboot/RUN_FIRSTBOOT")
      unless aug.save
        raise IOError, "Failed to save changes"
      end
    end

Minimal Setup with a Custom Root

By passing NO_MODL_AUTOLOAD, no files are read on startup; that allows setting up a custom transform.

  Augeas::open("/var/tmp/augeas-root", "/usr/local/share/mylenses",
                Augeas::NO_MODL_AUTOLOAD) do |aug|
    aug.transform(:lens => "Aliases.lns", :incl => "/etc/aliases")
    aug.load
    aug.get("/files/etc/aliases/*[name = 'postmaster']/value")
  end
You can’t perform that action at this time.