BusyBird
view release on metacpan or search on metacpan
lib/BusyBird/Main.pm view on Meta::CPAN
Users usually don't have to call this method.
The singleton instance of L<BusyBird::Main> object is maintained by L<BusyBird> module.
See L<BusyBird> and L<BusyBird::Manual::Tutorial> for detail.
=head1 OBJECT METHODS
=head2 $timeline = $main->timeline($name)
Returns the C<$timeline> whose name is C<$name> from the C<$main>.
C<$timeline> is a L<BusyBird::Timeline> object.
If C<$name> includes Unicode characters, it must be a character string (decoded string), not a binary string (encoded string).
If there is no timeline named C<$name> in C<$main>, a new timeline is created, installed and returned.
In L<BusyBird::Main>, timeline names must not contain a slash "/", because it confuses Web API.
If C<$name> contains a slash, the timeline IS created and returned, but it's NOT installed in the C<$main> object.
In that case, it logs a warning message.
If a new timeline is created by this method, it uses the StatusStorage object
given by C<< $main->get_config("default_status_storage") >> for that timeline.
See L<BusyBird::Manual::Config> for defail.
lib/BusyBird/StatusStorage.pm view on Meta::CPAN
See L<BusyBird::Timeline> for the specification.
In addition to L<BusyBird::Timeline>'s specification,
C<%args> in all the methods has the following field.
=over
=item C<timeline> => TIMELINE_NAME (mandatory)
Specifies the name of the timeline.
If the name includes Unicode characters, it must be a character string (decoded string), not a binary string (encoded string).
=back
These methods are all in callback-style, that is,
the results are not returned but given to the callback functions.
This allows for both synchronous and asynchronous implementations.
=head1 GUIDELINE
lib/BusyBird/Timeline.pm view on Meta::CPAN
You can also create a timeline via L<BusyBird::Main>'s C<timeline()> method.
Fields in C<%args> are as follows.
=over
=item C<name> => STRING (mandatory)
Specifies the name of the timeline.
If it includes Unicode characters, it must be a character string (decoded string), not a binary string (encoded string).
=item C<storage> => STATUS_STORAGE (mandatory)
Specifies a L<BusyBird::StatusStorage> object.
Statuses in C<$timeline> is saved to the C<storage>.
=back
=head1 OBJECT METHODS
lib/BusyBird/Timeline.pm view on Meta::CPAN
Specifies the IDs of the statuses to be acked.
If it is a defined scalar, the status with the specified ID is acked.
If it is an array-ref of IDs, the statuses with those IDs are acked.
If both C<max_id> and C<ids> are omitted or set to C<undef>, all unacked statuses are acked.
If both C<max_id> and C<ids> are specified, both statuses older than or equal to C<max_id>
and statuses specifed by C<ids> are acked.
If Status IDs include Unicode characters, they should be character strings (decoded strings), not binary strings (encoded strings).
=item C<max_id> => ID (optional, default: C<undef>)
Specifies the latest ID of the statuses to be acked.
If specified, unacked statuses with IDs older than or equal to the specified C<max_id> are acked.
If there is no unacked status with ID C<max_id>, no status is acked.
If both C<max_id> and C<ids> are omitted or set to C<undef>, all unacked statuses are acked.
If both C<max_id> and C<ids> are specified, both statuses older than or equal to C<max_id>
and statuses specifed by C<ids> are acked.
If the Status ID includes Unicode characters, it should be a character string (decoded string), not a binary string (encoded string).
=item C<callback> => CODEREF($error, $acked_num) (optional, default: C<undef>)
Specifies a subroutine reference that is called when the operation completes.
In success, the C<callback> is called with two arguments (C<$error> and C<$acked_num>).
C<$error> is C<undef>, and C<$acked_num> is the number of acked statuses.
In failure, C<$error> is a truthy value describing the error.
lib/BusyBird/Timeline.pm view on Meta::CPAN
Specifies the latest ID of the statuses to be fetched. It fetches
statuses with IDs older than or equal to the specified C<max_id>.
If there is no such status that has the ID equal to C<max_id> in
specified C<ack_state>, the result is an empty array-ref.
If this option is omitted or set to C<undef>, statuses starting from
the latest status are fetched.
If the Status ID includes Unicode characters, it should be a character string (decoded string), not a binary string (encoded string).
=item C<count> => {'all', NUMBER} (optional)
Specifies the maximum number of statuses to be fetched.
If C<'all'> is specified, all statuses starting from C<max_id> in
specified C<ack_state> are fetched.
The default value of this option is up to implementation of the status storage
the C<$timeline> uses.
lib/BusyBird/Timeline.pm view on Meta::CPAN
C<$timeline>. If C<mode> is C<"update">, the statuses in the
C<$timeline> are updated to the given statuses. If C<mode> is
C<"upsert">, statuses already in the C<$timeline> are updated while
statuses not in the C<$timeline> are inserted.
The statuses are identified by C<< $status->{id} >> field. The
C<< $status->{id} >> field must be unique in the C<$timeline>.
So if C<mode> is C<"insert">, statuses whose ID is already in the C<$timeline>
are ignored and not inserted.
If C<< $status->{id} >> includes Unicode characters, it should be a character string (decoded string), not a binary string (encoded string).
=item C<statuses> => {STATUS, ARRAYREF_OF_STATUSES} (mandatory)
The statuses to be saved in the C<$timeline>. It is either a status object
or an array-ref of status objects.
See L<BusyBird::Manual::Status> for specification of status objects.
lib/BusyBird/Timeline.pm view on Meta::CPAN
=item C<ids> => {C<undef>, ID, ARRAYREF_OF_IDS} (mandatory)
Specifies the IDs (value of C<< $status->{id} >> field) of the
statuses to be deleted.
If it is a defined scalar, the status with the specified ID is
deleted. If it is an array-ref of IDs, the statuses with those IDs
are deleted. If it is explicitly set to C<undef>, all statuses in the C<$timeline> are deleted.
If Status IDs include Unicode characters, they should be character strings (decoded strings), not binary strings (encoded strings).
=item C<callback> => CODEREF($error, $deleted_num) (optional, default: C<undef>)
Specifies a subroutine reference that is called when the operation completes.
In success, the C<callback> is called with two arguments (C<$error> and C<$deleted_num>).
C<$error> is C<undef>, and C<$deleted_num> is the number of deleted statuses.
In failure, C<$error> is a truthy value describing the error.
lib/BusyBird/Timeline.pm view on Meta::CPAN
Specifies the statuses or IDs to be checked.
If it is a scalar, that value is treated as a status ID.
If it is a hash-ref, that object is treated as a status object.
If it is an array-ref,
elements in the array-ref are treated as status objects or IDs.
Status objects and IDs can be mixed in a single array-ref.
If some statuses in C<query> don't have their C<id> field, those statuses are always treated as "not contained" in the C<$timeline>.
If Status IDs include Unicode characters, they should be character strings (decoded strings), not binary strings (encoded strings).
=item C<callback> => CODEREF($error, $contained, $not_contained) (mandatory)
Specifies a subroutine reference that is called when the check has completed.
In success, C<callback> is called with three arguments (C<$error>, C<$contained>, C<$not_contained>).
C<$error> is C<undef>.
C<$contained> is an array-ref of given statuses or IDs that are contained in the C<$timeline>.
C<$not_contained> is an array-ref of given statuses or IDs that are NOT contained in the C<$timeline>.
t/testlib/HTTP.pm view on Meta::CPAN
return from_json($self->request_ok(@_));
}
sub request_ok {
my ($self, $method, $request_url, $content, $res_code_like, $msg) = @_;
local $Test::Builder::Level = $Test::Builder::Level + 1;
my $res = $self->{requester}->(HTTP::Request->new($method, $request_url, undef, $content));
if(defined $res_code_like) {
like($res->code, $res_code_like, $msg);
}
return $res->decoded_content(raise_error => 1);
}
sub request_htmltree_ok {
my ($self, $method, $request_url, $content, $res_code_like, $msg) = @_;
local $Test::Builder::Level = $Test::Builder::Level + 1;
my $res = $self->request_ok($method, $request_url, $content, $res_code_like, $msg);
return ref($self)->parse_html($res);
}
sub parse_html {
( run in 0.298 second using v1.01-cache-2.11-cpan-a9ef4e587e4 )