Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Dist::Zilla and Pod::Weaver

  • Loading branch information...
commit 351f19bd7d80247105f15832ccbcfb27b07d30c5 1 parent 94c0bef
@gphat authored
View
6 Changes
@@ -1,6 +1,10 @@
Revision history for Data-SearchEngine
-0.21 2011-07-04
+{{$NEXT}}
+ * Convert README to README.mkdn
+ * Various tiny form and style fixes related to rejiggering docs for
+ Pod::Weaver
+ * Convert to Dist::Zilla and Pod::Weaver
* Change 'order' to be a Str|HashRef for more complex sorting features.
0.20 2011-07-03
View
30 MANIFEST
@@ -1,30 +0,0 @@
-Changes
-ignore.txt
-inc/Module/Install.pm
-inc/Module/Install/Base.pm
-inc/Module/Install/Can.pm
-inc/Module/Install/Fetch.pm
-inc/Module/Install/Makefile.pm
-inc/Module/Install/Metadata.pm
-inc/Module/Install/Win32.pm
-inc/Module/Install/WriteAll.pm
-lib/Data/SearchEngine.pm
-lib/Data/SearchEngine/Item.pm
-lib/Data/SearchEngine/Meta/Attribute/Trait/Digestable.pm
-lib/Data/SearchEngine/Modifiable.pm
-lib/Data/SearchEngine/Paginator.pm
-lib/Data/SearchEngine/Query.pm
-lib/Data/SearchEngine/Results.pm
-lib/Data/SearchEngine/Results/Faceted.pm
-lib/Data/SearchEngine/Results/Spellcheck.pm
-lib/Data/SearchEngine/Results/Spellcheck/Suggestion.pm
-lib/Moose/Meta/Attribute/Custom/Trait/Digestable.pm
-Makefile.PL
-MANIFEST This list of files
-META.yml
-README
-t/01-query.t
-t/01-simple.t
-t/02-storage.t
-t/lib/SearchEngineWee.pm
-t/lib/SEWeeResults.pm
View
18 Makefile.PL
@@ -1,18 +0,0 @@
-use inc::Module::Install;
-
-name 'Data-SearchEngine';
-all_from 'lib/Data/SearchEngine.pm';
-author q{Cory G Watson <gphat@cpan.org>};
-license 'perl';
-
-build_requires 'Test::More' => '0.88';
-
-requires 'Data::Paginator' => '0.03';
-requires 'Digest::MD5' => '2.39';
-requires 'JSON::Any';
-requires 'Moose' => '0.89';
-requires 'MooseX::Storage' => '0.21';
-requires 'Time::HiRes' => '1.9719';
-
-WriteAll;
-
View
25 README
@@ -1,25 +0,0 @@
-NAME
-
-Data::SearchEngine - A role for search engines and cacheable results.
-
-SYNOPSIS
-
-There are B<lots> of search engine libraries. Each has a different interface.
-The goal of Data::SearchEngine is to provide a simple, extensive set of
-classes and roles that you can use to wrap a search implementation. The net
-result will be an easily swappable backend with a common set of features, such
-as serialize of results for use with a cache.
-
-AUTHOR
-
-Cory G Watson, C<< <gphat at cpan.org> >>
-
-COPYRIGHT & LICENSE
-
-Copyright 2009 Cory G Watson
-
-This program is free software; you can redistribute it and/or modify it
-under the terms of either: the GNU General Public License as published
-by the Free Software Foundation; or the Artistic License.
-
-See http://dev.perl.org/licenses/ for more information.
View
97 README.mkdn
@@ -0,0 +1,97 @@
+# NAME
+
+Data::SearchEngine - A role for search engine abstraction.
+
+# VERSION
+
+version 0.21
+
+# SYNOPSIS
+
+ package Data::SearchEngine::MySearch;
+
+ with 'Data::SearchEngine';
+
+ sub search {
+ my ($self, $query) = @_;
+
+ # ... your internal search junk
+
+ my $result = Data::SearchEngine::Results->new(
+ query => $query,
+ pager => # ... make a Data::Page
+ );
+
+ foreach my $hit (@hits) {
+ $result->add(Data::SearchEngine::Item->new(
+ values => {
+ name => $hit->name,
+ description => $hit->description
+ },
+ score => $hit->score
+ ));
+ }
+
+ return $result;
+ }
+
+# DESCRIPTION
+
+There are __lots__ of search engine libraries. Each has a different interface.
+The goal of Data::SearchEngine is to provide a simple, extensive set of
+classes and roles that you can use to wrap a search implementation. The net
+result will be an easily swappable backend with a common set of features.
+
+# IMPLEMENTATION
+
+## Step 1 - Extend the Query
+
+If you have specific attributes that you need for your query, subclass the
+[Data::SearchEngine::Query](http://search.cpan.org/perldoc?Data::SearchEngine::Query) object and add the attributes. This part is
+optional.
+
+## Step 2 - Wrap a search implementation
+
+Next use the [Data::SearchEngine](http://search.cpan.org/perldoc?Data::SearchEngine) role in a class that wraps your search
+implementation. You can find an example in [Data::SearchEngine::Results](http://search.cpan.org/perldoc?Data::SearchEngine::Results).
+
+## Step 3 - Profit!!!
+
+!!!
+
+# DIGESTS
+
+Data::SearchEngine provides a Digestable trait that can be applied to
+attributes of `Query`. Attributes with this trait will be added to
+a base64 MD5 digest to produce a unique key identifying this query. You can
+then serialize the Result using [MooseX::Storage](http://search.cpan.org/perldoc?MooseX::Storage) and store it under the
+digest of the Query for caching.
+
+# ATTRIBUTES
+
+## defaults
+
+The `defaults` attribute is a simple HashRef that backends may use to get
+default settings from the user. The implementation of `search` may then use
+these defaults when setting up instances of a search.
+
+# METHODS
+
+## get_default ($key)
+
+Returns the value from `defaults` (if any) for the specified key.
+
+## set_default ($key, $value)
+
+Sets the value in `defaults`.
+
+# AUTHOR
+
+Cory G Watson <gphat@cpan.org>
+
+# COPYRIGHT AND LICENSE
+
+This software is copyright (c) 2011 by Cold Hard Code, LLC.
+
+This is free software; you can redistribute it and/or modify it under
+the same terms as the Perl 5 programming language system itself.
View
47 dist.ini
@@ -0,0 +1,47 @@
+name = Data-SearchEngine
+author = Cory G Watson <gphat@cpan.org>
+license = Perl_5
+copyright_holder= Cold Hard Code, LLC
+
+[@Basic]
+
+[Git::NextVersion]
+first_version = 0.01
+version_regexp = ^(\d+\.\d+)$
+
+[ReadmeMarkdownFromPod]
+
+[PkgVersion]
+
+[AutoPrereqs]
+
+[Prereqs]
+Data::Paginator = 0.03
+JSON::Any = 0
+JSON::XS = 0
+
+[NextRelease]
+format = %v %{MMM d yyyy}d
+
+[SynopsisTests]
+
+[PodSyntaxTests]
+
+[MetaJSON]
+
+[MetaResources]
+repository.url = https://github.com/gphat/data-searchengine
+repository.type = git
+
+[CopyFilesFromBuild]
+copy = README.mkdn
+
+[PruneFiles]
+filenames = dist.ini
+
+[Git::Commit]
+
+[Git::Tag]
+tag_format = %v
+
+[PodWeaver]
View
63 lib/Data/SearchEngine.pm
@@ -1,29 +1,10 @@
package Data::SearchEngine;
use Moose::Role;
-our $VERSION = '0.20';
-
-has defaults => (
- traits => [ 'Hash' ],
- is => 'ro',
- isa => 'HashRef',
- handles => {
- set_default => 'set',
- get_default => 'get'
- }
-);
+# ABSTRACT: A role for search engine abstraction.
requires qw(search);
-no Moose::Role;
-1;
-
-__END__
-
-=head1 NAME
-
-Data::SearchEngine - A role for search engine abstraction.
-
=head1 SYNOPSIS
package Data::SearchEngine::MySearch;
@@ -60,6 +41,8 @@ The goal of Data::SearchEngine is to provide a simple, extensive set of
classes and roles that you can use to wrap a search implementation. The net
result will be an easily swappable backend with a common set of features.
+=begin :prelude
+
=head1 IMPLEMENTATION
=head2 Step 1 - Extend the Query
@@ -77,24 +60,14 @@ implementation. You can find an example in L<Data::SearchEngine::Results>.
!!!
-=head1 ATTRIBUTES
+=end :prelude
-=head2 defaults
+=attr defaults
The C<defaults> attribute is a simple HashRef that backends may use to get
default settings from the user. The implementation of C<search> may then use
these defaults when setting up instances of a search.
-=head1 METHODS
-
-=head2 get_default ($key)
-
-Returns the value from C<defaults> (if any) for the specified key.
-
-=head2 set_default ($key, $value)
-
-Sets the value in C<defaults>.
-
=head1 DIGESTS
Data::SearchEngine provides a Digestable trait that can be applied to
@@ -103,17 +76,27 @@ a base64 MD5 digest to produce a unique key identifying this query. You can
then serialize the Result using L<MooseX::Storage> and store it under the
digest of the Query for caching.
-=head1 AUTHOR
+=cut
-Cory G Watson, C<< <gphat at cpan.org> >>
+has defaults => (
+ traits => [ 'Hash' ],
+ is => 'ro',
+ isa => 'HashRef',
+ handles => {
+ set_default => 'set',
+ get_default => 'get'
+ }
+);
-=head1 COPYRIGHT & LICENSE
+=method get_default ($key)
-Copyright 2009 Cory G Watson
+Returns the value from C<defaults> (if any) for the specified key.
-This program is free software; you can redistribute it and/or modify it
-under the terms of either: the GNU General Public License as published
-by the Free Software Foundation; or the Artistic License.
+=method set_default ($key, $value)
-See http://dev.perl.org/licenses/ for more information.
+Sets the value in C<defaults>.
+
+=cut
+no Moose::Role;
+1;
View
89 lib/Data/SearchEngine/Item.pm
@@ -2,38 +2,9 @@ package Data::SearchEngine::Item;
use Moose;
use MooseX::Storage;
-with 'MooseX::Storage::Deferred';
-
-has id => (
- is => 'rw',
- isa => 'Str'
-);
+# ABSTRACT: An individual search result.
-has score => (
- is => 'rw',
- isa => 'Num',
- default => 0
-);
-
-has values => (
- traits => [ 'Hash' ],
- is => 'rw',
- isa => 'HashRef[Str|ArrayRef[Str]|Undef]',
- default => sub { {} },
- handles => {
- keys => 'keys',
- get_value => 'get',
- set_value => 'set',
- },
-);
-
-__PACKAGE__->meta->make_immutable;
-
-1;
-
-=head1 NAME
-
-Data::SearchEngine::Item - An individual search result.
+with 'MooseX::Storage::Deferred';
=head1 SYNOPSIS
@@ -51,45 +22,61 @@ Data::SearchEngine::Item - An individual search result.
An item represents an individual search result. It's really just a glorified
HashRef.
-=head1 ATTRIBUTES
-
-=head2 id
+=attr id
A unique identifier for this item.
-=head2 values
+=cut
-The name value pairs for this item.
+has id => (
+ is => 'rw',
+ isa => 'Str'
+);
-=head2 score
+=attr score
The score this item earned.
-=head1 METHODS
+=cut
+
+has score => (
+ is => 'rw',
+ isa => 'Num',
+ default => 0
+);
+
+=attr values
+
+The name value pairs for this item.
-=head2 keys
+=method keys
Returns the keys from the values HashRef, e.g. a list of the value names for
this item.
-=head2 get_value
+=method get_value
Returns the value for the specified key for this item.
-=head2 set_value
+=method set_value
Sets the value for the specified key for this item.
-=head1 AUTHOR
+=cut
-Cory G Watson, C<< <gphat at cpan.org> >>
-
-=head1 COPYRIGHT & LICENSE
-
-Copyright 2009 Cory G Watson
+has values => (
+ traits => [ 'Hash' ],
+ is => 'rw',
+ isa => 'HashRef[Str|ArrayRef[Str]|Undef]',
+ default => sub { {} },
+ handles => {
+ keys => 'keys',
+ get_value => 'get',
+ set_value => 'set',
+ },
+);
-This program is free software; you can redistribute it and/or modify it
-under the terms of either: the GNU General Public License as published
-by the Free Software Foundation; or the Artistic License.
+no Moose;
+__PACKAGE__->meta->make_immutable;
-See http://dev.perl.org/licenses/ for more information.
+1;
View
37 lib/Data/SearchEngine/Meta/Attribute/Trait/Digestable.pm
@@ -1,19 +1,7 @@
package Data::SearchEngine::Meta::Attribute::Trait::Digestable;
use Moose::Role;
-has digest_value => (
- is => 'ro',
- isa => 'CodeRef',
- predicate => 'has_digest_value'
-);
-
-1;
-
-__END__
-
-=head1 NAME
-
-Data::SearchEngine::Meta::Attribute::Trait::Digestable - Digest flag & configuration
+# ABSTRACT: Digest flag & configuration
=head1 SYNOPSIS
@@ -37,23 +25,18 @@ categories (or lack thereof) to have different digests.
When computing it's digest, your query will now add the value of the category
to the computation, thereby guaranteeing uniqueness!
-=head1 ATTRIBUTES
-
-=head2 digest_value
+=attr digest_value
A coderef that will return a string identifying the value of this attribute
for adding to the Query's digst.
-=head1 AUTHOR
-
-Cory G Watson, C<< <gphat at cpan.org> >>
-
-=head1 COPYRIGHT & LICENSE
+=cut
-Copyright 2009 Cory G Watson
-
-This program is free software; you can redistribute it and/or modify it
-under the terms of either: the GNU General Public License as published
-by the Free Software Foundation; or the Artistic License.
+has digest_value => (
+ is => 'ro',
+ isa => 'CodeRef',
+ predicate => 'has_digest_value'
+);
-See http://dev.perl.org/licenses/ for more information.
+no Moose::Role;
+1;
View
39 lib/Data/SearchEngine/Modifiable.pm
@@ -1,17 +1,7 @@
package Data::SearchEngine::Modifiable;
use Moose::Role;
-requires qw(add present remove remove_by_id update);
-
-no Moose::Role;
-1;
-
-__END__
-
-=head1 NAME
-
-Data::SearchEngine::Modifiable - A role for search engines with an updateable
-index.
+# ABSTRACT: A role for search engines with an updateable index.
=head1 SYNOPSIS
@@ -20,40 +10,31 @@ when wrapping an index that can be updated. Since some indexes may be read
only, the idea is to keep the required methods in this role separate from the
base one.
-=head1 METHODS
-
-=head2 add ($thing)
+=method add ($thing)
Adds the specified thing to the index.
-=head2 present ($thing)
+=method present ($thing)
Returns true if the specified thing is present in the index.
-=head2 remove ($thing)
+=method remove ($thing)
Removes the specified thing from the index. Consult the documentation
for your specific backend.
-=head2 remove_by_id ($id)
+=method remove_by_id ($id)
Remove a specific thing by id.
-=head2 update ($thing)
+=method update ($thing)
Updates the specified thing in the index.
-=head1 AUTHOR
-
-Cory G Watson, C<< <gphat at cpan.org> >>
-
-=head1 COPYRIGHT & LICENSE
-
-Copyright 2009 Cory G Watson
+=cut
-This program is free software; you can redistribute it and/or modify it
-under the terms of either: the GNU General Public License as published
-by the Free Software Foundation; or the Artistic License.
+requires qw(add present remove remove_by_id update);
-See http://dev.perl.org/licenses/ for more information.
+no Moose::Role;
+1;
View
182 lib/Data/SearchEngine/Query.pm
@@ -2,11 +2,29 @@ package Data::SearchEngine::Query;
use Moose;
use MooseX::Storage;
+# ABSTRACT: Query to pass to an engine.
+
with 'MooseX::Storage::Deferred';
use Data::SearchEngine::Meta::Attribute::Trait::Digestable;
use Digest::MD5;
+=head1 SYNOPSIS
+
+The query object has some common attributes one would expect when performing
+a search. It has the added benefit of producing a digest that can be used
+with L<Data::SearchEngine::Results> ability to serialize to implement caching.
+
+If you add new attributes to a subclass, be sure and add the Digestable
+trait to any attributes you want to be included in the digest as document in
+L<Data::SearchEngine::Meta::Attribute::Trait::Digestable>.
+
+=attr count
+
+The number of results this query should return.
+
+=cut
+
has count => (
traits => [qw(Digestable)],
is => 'ro',
@@ -14,6 +32,30 @@ has count => (
default => 10
);
+=attr filters
+
+A HashRef of filters used with the query. The key should be the filter name
+and the value is the filter's value. Consult the documentation for your
+backend to see how this is used.
+
+=method filter_names
+
+Return an array of filter names that are present in this query.
+
+=method get_filter
+
+Gets the value for the specified filter.
+
+=method has_filters
+
+Predicate that returns true if this query has filters.
+
+=head2 set_filter
+
+Sets the value for the specified filter.
+
+=cut
+
has filters => (
traits => [ 'Hash', 'Digestable' ],
is => 'rw',
@@ -27,6 +69,12 @@ has filters => (
}
);
+=attr order
+
+The order in which the results should be sorted.
+
+=cut
+
has order => (
traits => [qw(Digestable)],
is => 'rw',
@@ -34,6 +82,15 @@ has order => (
predicate => 'has_order'
);
+=attr original_query
+
+The "original" query that the user searched for. Provided because some
+backends may need to modify the C<query> attribute to a more palatable form.
+If no value is provided for this attribute then it will assume the same
+value as C<query>.
+
+=cut
+
has original_query => (
traits => [qw(Digestable)],
is => 'ro',
@@ -42,12 +99,28 @@ has original_query => (
default => sub { my $self = shift; return $self->query }
);
+=attr page
+
+Which page of results to show.
+
+=cut
+
has page => (
is => 'ro',
isa => 'Int',
default => 1
);
+=attr query
+
+The query string to search for.
+
+=method has_query
+
+Returns true if this Query has a query string.
+
+=cut
+
has query => (
traits => [qw(Digestable)],
is => 'rw',
@@ -55,6 +128,12 @@ has query => (
predicate => 'has_query'
);
+=method digest
+
+Returns a unique digest identifying this Query. Useful as a key when caching.
+
+=cut
+
sub digest {
my $self = shift;
@@ -80,107 +159,22 @@ sub digest {
return $digester->b64digest;
}
-sub has_filter_like {
- my ($self, $predicate) = @_;
-
- return grep { $predicate->() } $self->filter_names;
-}
-
-__PACKAGE__->meta->make_immutable;
-
-1;
-
-__END__
-
-=head1 NAME
-
-Data::SearchEngine::Query - Query to pass to an engine.
-
-=head1 SYNOPSIS
-
-The query object has some common attributes one would expect when performing
-a search. It has the added benefit of producing a digest that can be used
-with L<Data::SearchEngine::Results> ability to serialize to implement caching.
-
-If you add new attributes to a subclass, be sure and add the Digestable
-trait to any attributes you want to be included in the digest as document in
-L<Data::SearchEngine::Meta::Attribute::Trait::Digestable>.
-
-=head1 ATTRIBUTES
-
-=head2 count
-
-The number of results this query should return.
-
-=head2 filters
-
-A HashRef of filters used with the query. The key should be the filter name
-and the value is the filter's value. Consult the documentation for your
-backend to see how this is used.
-
-=head2 order
-
-The order in which the results should be sorted.
-
-=head2 original_query
-
-The "original" query that the user searched for. Provided because some
-backends may need to modify the C<query> attribute to a more palatable form.
-If no value is provided for this attribute then it will assume the same
-value as C<query>.
-
-=head2 page
-
-Which page of results to show.
-
-=head2 query
-
-The query string to search for.
-
-=head1 METHODS
-
-=head2 digest
-
-Returns a unique digest identifying this Query. Useful as a key when
-caching.
-
-=head2 filter_names
-
-Return an array of filter names that are present in this query.
-
-=head2 get_filter
-
-Gets the value for the specified filter.
-
-=head2 has_filters
-
-Predicate that returns true if this query has filters.
-
-=head2 has_filter_like
+=method has_filter_like
Returns true if any of the filter names match the provided subroutine:
$query->set_filter('foo', 'bar');
$query->has_filter_like(sub { /^fo/ })s; # true!
-=head2 has_query
-
-Returns true if this Query has a query string.
-
-=head2 set_filter
-
-Sets the value for the specified filter.
-
-=head1 AUTHOR
+=cut
-Cory G Watson, C<< <gphat at cpan.org> >>
-
-=head1 COPYRIGHT & LICENSE
+sub has_filter_like {
+ my ($self, $predicate) = @_;
-Copyright 2009 Cory G Watson
+ return grep { $predicate->() } $self->filter_names;
+}
-This program is free software; you can redistribute it and/or modify it
-under the terms of either: the GNU General Public License as published
-by the Free Software Foundation; or the Artistic License.
+no Moose;
+__PACKAGE__->meta->make_immutable;
-See http://dev.perl.org/licenses/ for more information.
+1;
View
111 lib/Data/SearchEngine/Results.pm
@@ -2,42 +2,9 @@ package Data::SearchEngine::Results;
use Moose;
use MooseX::Storage;
-with 'MooseX::Storage::Deferred';
+# ABSTRACT: Results of a Data::SearchEngine search
-has elapsed => (
- is => 'rw',
- isa => 'Num'
-);
-has items => (
- traits => [ 'Array' ],
- is => 'rw',
- isa => 'ArrayRef[Data::SearchEngine::Item]',
- default => sub { [] },
- handles => {
- count => 'count',
- get => 'get',
- add => 'push',
- }
-);
-has query => (
- is => 'ro',
- isa => 'Data::SearchEngine::Query',
- required => 1,
-);
-has pager => (
- is => 'ro',
- isa => 'Data::SearchEngine::Paginator'
-);
-
-__PACKAGE__->meta->make_immutable;
-
-1;
-
-__END__
-
-=head1 NAME
-
-Data::SearchEngine::Results - Results of a Data::SearchEngine serach
+with 'MooseX::Storage::Deferred';
=head1 SYNOPSIS
@@ -75,6 +42,8 @@ you are likely to use.
return $results;
}
+=begin :prelude
+
=head1 SERIALIZATION
This module uses L<MooseX::Storage::Deferred> to provide serialization. You
@@ -84,56 +53,68 @@ may serialize it thusly:
# ...
my $results = Data::SearchEngine::Results->thaw($json, { format => 'JSON' });
-=head1 ATTRIBUTES
-
-=head2 add ($item)
-
-Add an item to this result.
+=end :prelude
-=head2 count
-
-Count of items in this result.
-
-=head2 elapsed
+=attr elapsed
The time it took to complete this search.
-=head2 get ($n)
+=cut
-Get the nth item.
+has elapsed => (
+ is => 'rw',
+ isa => 'Num'
+);
-=head2 items
+=attr items
The list of L<Data::SearchEngine::Item>s found for the query.
-=head2 pager
+=method add ($item)
-The L<Data::Page> for this result.
+Add an item to this result.
-=head2 query
+=method get ($n)
-The L<Data::SearchEngine::Query> that yielded this Results object.
+Get the nth item.
+
+=cut
-=head1 METHODS
+has items => (
+ traits => [ 'Array' ],
+ is => 'rw',
+ isa => 'ArrayRef[Data::SearchEngine::Item]',
+ default => sub { [] },
+ handles => {
+ count => 'count',
+ get => 'get',
+ add => 'push',
+ }
+);
-=head add
+=attr query
-Appends an Item onto the end of this Results object's item list.
+The L<Data::SearchEngine::Query> that yielded this Results object.
-=head get
+=cut
-Gets the item at the specified index.
+has query => (
+ is => 'ro',
+ isa => 'Data::SearchEngine::Query',
+ required => 1,
+);
-=head1 AUTHOR
+=attr pager
-Cory G Watson, C<< <gphat at cpan.org> >>
+The L<Data::Page> for this result.
-=head1 COPYRIGHT & LICENSE
+=cut
-Copyright 2009 Cory G Watson
+has pager => (
+ is => 'ro',
+ isa => 'Data::SearchEngine::Paginator'
+);
-This program is free software; you can redistribute it and/or modify it
-under the terms of either: the GNU General Public License as published
-by the Free Software Foundation; or the Artistic License.
+__PACKAGE__->meta->make_immutable;
-See http://dev.perl.org/licenses/ for more information.
+1;
View
56 lib/Data/SearchEngine/Results/Faceted.pm
@@ -1,25 +1,7 @@
package Data::SearchEngine::Results::Faceted;
use Moose::Role;
-has facets => (
- traits => [ 'Hash' ],
- is => 'rw',
- isa => 'HashRef[Any]',
- default => sub { {} },
- handles => {
- facet_names=> 'keys',
- get_facet => 'get',
- set_facet => 'set',
- }
-);
-
-1;
-
-__END__
-
-=head1 NAME
-
-Data::SearchEngine::Results::Faceted - Facet role for Results
+# ABSTRACT: Facet role for Results
=head1 SYNOPSIS
@@ -36,37 +18,35 @@ Data::SearchEngine::Results::Faceted - Facet role for Results
Provides storage and methods for retrieving facet information.
-=head1 ATTRIBUTES
-
-=head2 facets
+=attr facets
HashRef of facets for this query. The HashRef is keyed by the name of the
facet and the values are the facet's value.
-=head1 METHODS
-
-=head2 facet_names
+=method facet_names
Returns an array of all the keys of C<facets>.
-=head get_facet
+=method get_facet
Gets the facet with the specified name. Returns undef if one does not exist.
-=head set_facet
+=method set_facet
Sets the facet with the specified name.
-=head1 AUTHOR
-
-Cory G Watson, C<< <gphat at cpan.org> >>
-
-=head1 COPYRIGHT & LICENSE
-
-Copyright 2009 Cory G Watson
+=cut
-This program is free software; you can redistribute it and/or modify it
-under the terms of either: the GNU General Public License as published
-by the Free Software Foundation; or the Artistic License.
+has facets => (
+ traits => [ 'Hash' ],
+ is => 'rw',
+ isa => 'HashRef[Any]',
+ default => sub { {} },
+ handles => {
+ facet_names=> 'keys',
+ get_facet => 'get',
+ set_facet => 'set',
+ }
+);
-See http://dev.perl.org/licenses/ for more information.
+1;
View
125 lib/Data/SearchEngine/Results/Spellcheck.pm
@@ -1,47 +1,7 @@
package Data::SearchEngine::Results::Spellcheck;
use Moose::Role;
-has spell_collation => (
- is => 'rw',
- isa => 'Str',
- predicate => 'has_spell_collation'
-);
-
-has spell_frequencies => (
- traits => [ 'Hash' ],
- is => 'rw',
- isa => 'HashRef[Num]',
- default => sub { {} },
- handles => {
- set_spell_frequency => 'set',
- get_spell_frequency => 'get'
- }
-);
-
-has spell_suggestions => (
- traits => [ 'Hash' ],
- is => 'rw',
- isa => 'HashRef[Data::SearchEngine::Results::Spellcheck::Suggestion]',
- default => sub { {} },
- handles => {
- spell_suggestion_words=> 'keys',
- set_spell_suggestion => 'set',
- get_spell_suggestion => 'get'
- }
-);
-
-has spelled_correctly => (
- is => 'rw',
- isa => 'Bool',
-);
-
-1;
-
-__END__
-
-=head1 NAME
-
-Data::SearchEngine::Results::Spellcheck - spellcheck role for Spellchecking
+# ABSTRACT: spellcheck role for Spellchecking
=head1 SYNOPSIS
@@ -62,61 +22,88 @@ Data::SearchEngine::Results::Spellcheck - spellcheck role for Spellchecking
Provides storage and methods for retrieving spellcheck information.
-=head1 ATTRIBUTES
-
-=head2 spell_collation
+=attr spell_collation
Intended to hold the 'suggested' spelling result from spellchecking. A search
for "basebll bat" would likely have a collation of "baseball bat". It is so
named as it contains a collation of the best results for the various tokens.
-=head2 spell_frequencies
+=cut
+
+has spell_collation => (
+ is => 'rw',
+ isa => 'Str',
+ predicate => 'has_spell_collation'
+);
+
+=attr spell_frequencies
Hash containing the original token in as the key and the frequency it occurs
in the index as the value. This may not be used by all backends.
-=head2 spell_sugguestions
-
-HashRef of spellcheck suggestions for this query. The HashRef is keyed by the
-word for which spellcheck suggestions are being provided and the values are
-the suggestions.
+=method get_spell_frequency ($word)
-=head2 spelled_correctly
+Gets the frequency for the specified word.
-Boolean value to signal to the front end if the query was spelled correctly.
+=method set_spell_frequency ($word, $frequency)
-=head1 METHODS
+Sets the frequency for the provided word.
-=head2 get_spell_frequency ($word)
+=cut
-Gets the frequency for the specified word.
+has spell_frequencies => (
+ traits => [ 'Hash' ],
+ is => 'rw',
+ isa => 'HashRef[Num]',
+ default => sub { {} },
+ handles => {
+ set_spell_frequency => 'set',
+ get_spell_frequency => 'get'
+ }
+);
-=head2 get_spell_suggestion ($word)
+=attr spell_sugguestions
-Gets the suggestion with the specified name. Returns undef if one does not exist.
+HashRef of spellcheck suggestions for this query. The HashRef is keyed by the
+word for which spellcheck suggestions are being provided and the values are
+the suggestions.
-=head2 set_spell_frequency ($word, $frequency)
+=method get_spell_suggestion ($word)
-Sets the frequency for the provided word.
+Gets the suggestion with the specified name. Returns undef if one does not exist.
-=head2 set_spell_suggestion
+=method set_spell_suggestion
Sets the suggestion with the specified name.
-=head2 spell_suggestion_words
+=method spell_suggestion_words
Returns an array of all the keys of C<suggestions>.
-=head1 AUTHOR
+=cut
-Cory G Watson, C<< <gphat at cpan.org> >>
+has spell_suggestions => (
+ traits => [ 'Hash' ],
+ is => 'rw',
+ isa => 'HashRef[Data::SearchEngine::Results::Spellcheck::Suggestion]',
+ default => sub { {} },
+ handles => {
+ spell_suggestion_words=> 'keys',
+ set_spell_suggestion => 'set',
+ get_spell_suggestion => 'get'
+ }
+);
+
+=attr spelled_correctly
-=head1 COPYRIGHT & LICENSE
+Boolean value to signal to the front end if the query was spelled correctly.
-Copyright 2009 Cory G Watson
+=cut
-This program is free software; you can redistribute it and/or modify it
-under the terms of either: the GNU General Public License as published
-by the Free Software Foundation; or the Artistic License.
+has spelled_correctly => (
+ is => 'rw',
+ isa => 'Bool',
+);
-See http://dev.perl.org/licenses/ for more information.
+no Moose::Role;
+1;
View
23 weaver.ini
@@ -0,0 +1,23 @@
+[@CorePrep]
+
+[Name]
+[Version]
+
+[Generic / SYNOPSIS]
+[Generic / DESCRIPTION]
+[Generic / OVERVIEW]
+
+[Region / prelude]
+
+[Leftovers]
+
+[Collect / ATTRIBUTES]
+command = attr
+
+[Collect / METHODS]
+command = method
+
+[Region / postlude]
+
+[Authors]
+[Legal]
Please sign in to comment.
Something went wrong with that request. Please try again.