Sha256: 7413076bb7ad169c4a253edde08d8e4c3cf16444ab8165d2463b6fa2fe8f1169

Contents?: true

Size: 1.17 KB

Versions: 1

Compression:

Stored size: 1.17 KB

Contents

module KeyControl

  class KeyRing

    attr_reader :system

    # Public: Get a new KeyControl::KeyRing instance with the specified keyring
    # identifier.
    #
    # keyring - A String or Integer identifying the desired keyring.
    #
    # Returns a KeyControl::KeyRing instance.
    def initialize(keyring)
      @keyring = keyring
      @system = System.new
    end

    # Public: Add the requested data to the keychain for the given description.
    #
    # name - The description of the data.
    # data - The data to store in the keychain.
    #
    # Returns nothing.
    def []=(name, data)
      system.run(:add, "user", name, data, data.length, @keyring)
    end

    # Public: Get the data matching the passed description from the keychain.
    #
    # name - The description of the data for which to search.
    #
    # Returns the requested data or nil.
    def [](name)
      handle = system.run(:search, "user", name, nil, @keyring)
      return nil if handle == -1

      system.get(:read, handle)
    end

    # Public: Inspect the structure of and data stored in the current keyring.
    #
    # Returns
    def inspect
      system.get(:describe, @keyring)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
key_control-0.0.4 lib/key_control/key_ring.rb