Blerg::Database - Perl extension for reading Blërg! databases
use Blerg::Database;
my $blerg = Blerg::Database->open_existing('foo'); my $record = $blerg->post('This is some data!'); $blerg->fetch($record);
Blerg::Database is a utility library wrapping the core Blërg! database. It provides nicer OO wrappers around the core C library that powers Blërg!.
Returns 1 if the named database exists, or undef
if it doesn't.
Returns a list of hashrefs describing blerg posts related to the given tag.
tag
includes the leading '@' or '#'. Each item has two keys, author
and
record
.
Convenience for tag_list
so that you don't have to prepend '#' to the name.
Convenience for tag_list
so that you don't have to prepend '@' to the name.
Adds a subscription from from
to to
.
The opposite of subscription_add.
Validates that name
is a valid tag name.
Validates that name
is a valid username.
configuration()
Returns a hashref containing runtime configuration information. Contains these fields:
The base path to the Blërg database
The path under base_path for account data
The path under base_path for hashtag data
The path under base_path for mention data
Sets the password for the given username. Returns 1 on success, 0 otherwise.
Checks the password for the given username. Returns 1 on successful authentication, 0 on failed authentication or error.
Authenticates and logs the user in. Returns the authentication token if successful, or undef on failure or error.
Logs the given user out if the token represents a valid session. Returns 1 on success, or 0 on failure. Failure can happen if the token is no longer valid (meaning the user has been automatically logged out), so the return status is probably best ignored..
Checks that the token represents a valid session for the given username. Returns 1 if the session is valid, 0 otherwise. Also resets the expiration time of the session.
Gets an opaque "counter" value for the auth information of the given username. This counter is changed every time the authentication information is changed, making it useful for protecting password changes against replay attacks. Returns a 32-bit integer on success, or undef on failure.
Opens the named database, creating it if it doesn't exist.
Opens the named database. If it doesn't exist, returns undef
.
record_count()
Returns the number of records in the database.
Stores a new record containing data
. Returns the record number of the new
record.
Fetches a record from the database.
Returns a unix epoch timestamp for when the record was created.
set_subscription_mark()
Mark all items on the subscription list as read.
get_subscription_mark()
Return the subscription list mark.
subscription_list()
Return a list of hashrefs describing posts in your subscription feed. Each
hashref has a author
and record
key.
refs()
Convenience for listing references to the database. Equivalent to
tag_list('@' . $obj->{name})
.
When v = 1, mute the user, otherwise, unmute. If v is absent, return the mute status.
close()
Closes the database.
See the Blërg! website at http://blerg.cc. More detailed docs about the database internals are available in the source repo under www/doc, or at http://blerg.cc/doc/
Chip Black, <bytex64@bytex64.net>
Copyright (C) 2013 by Chip Black
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.16.1 or, at your option, any later version of Perl 5 you may have available.