Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
diff --git a/Changes b/Changes
index a0cfc93..c19f1b7 100644
--- a/Changes
+++ b/Changes
@@ -1,3 +1,20 @@
+0.20 Sun Feb 28 00:29:32 GMT 2010
+
+ - Use Mouse instead of Moose by default but depend on both of
+ them.
+
+ This saves about 8MB of resident memory bringing Hailo's memory
+ usage with SQLite from 28MB to 20MB. Startup time is also
+ reduced with the test suite running around 46% faster.
+
+ - Run tests with Moose and Mouse during `make test`
+
+ - Drop MouseX::Role::Strict / MooseX::Role::Strict. Spotted when
+ switching to Moose but mainly we just didn't care about using
+ it.
+
+ - Word tokenizer: Improve punctuation when words are split with '/'
+
0.19 Sat Feb 27 04:23:03 GMT 2010
- Move File::Slurp from 'requires' to 'test_requires'
diff --git a/MANIFEST b/MANIFEST
index 7c515b8..dc2c201 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -29,6 +28,7 @@ MANIFEST.SKIP
META.yml
README
script/hailo
+t/00_diag.t
t/01_compile.t
t/02_chat.t
t/03_sanity.t
diff --git a/Makefile.PL b/Makefile.PL
index f3700d1..0ad2861 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -21,14 +25,22 @@ resources ('Time::HiRes' => '0');
resources ('FindBin' => '0');
resources ('File::Spec::Functions' => '0');
+## Depend on Mouse or Moose, we can use either one
+# Mouse
+requires('Mouse' => '0.50_04');
+requires('MouseX::Types' => '0.05');
+requires('MouseX::Getopt' => '0.2601');
+# Moose
+requires('Moose' => '0.94');
+requires('MooseX::Types' => '0.21');
+requires('MooseX::StrictConstructor' => '0.08');
+requires('MooseX::Getopt' => '0.26');
+
# Hailo.pm
+requires ('Any::Moose' => '0.11');
requires ('autodie' => '2.08');
-requires ('Moose' => '0.94');
-requires ('Class::MOP' => '0.98');
requires ('Data::Section' => '0.100270');
requires ('File::CountLines' => '0.0.2');
-requires ('MooseX::Getopt' => '0.26');
-requires ('MooseX::Getopt::Dashes' => '0');
requires ('Getopt::Long::Descriptive' => '0.083');
requires ('IO::Interactive' => '0.0.6');
requires ('Module::Pluggable' => '3.9');
@@ -45,10 +57,6 @@ requires ('Template' => '2.22');
requires ('DBD::SQLite' => '1.29');
# everywhere
-requires ('MooseX::Role::Strict' => '0.03');
-requires ('MooseX::StrictConstructor' => '0.08');
-requires ('MooseX::Types' => '0.21');
-requires ('MooseX::Types::Moose' => '0.21');
requires ('namespace::clean' => '0.13');
# Pg/mysql: optional backends
@@ -70,6 +78,16 @@ author_requires('Test::Perl::Critic' => '1.02');
author_requires('Test::Pod' => '1.41');
author_requires('Test::Pod::Coverage' => '1.08');
author_requires('Test::Script' => '1.07');
-author_tests ('xt');
-
+auto_provides ();
WriteAll();
+
+package MY;
+
+sub test {
+ my $inherited = shift->SUPER::test(@_);
+
+ # Run tests with Moose and Mouse
+ $inherited =~ s/^test_dynamic :: pure_all\n\t(.*?)\n/test_dynamic :: pure_all\n\tANY_MOOSE=Mouse $1\n\tANY_MOOSE=Moose $1\n/m;
+
+ return $inherited;
+}
diff --git a/README b/README
index 64d86aa..f46920f 100644
--- a/README
+++ b/README
@@ -31,8 +31,8 @@ SYNOPSIS
DESCRIPTION
Hailo is a fast and lightweight markov engine intended to replace
- AI::MegaHAL. It has a lightweight Moose-based core with pluggable
- storage and tokenizer backends.
+ AI::MegaHAL. It has a Mouse (or Moose) based core with pluggable storage
+ and tokenizer backends.
It is similar to MegaHAL in functionality, the main differences (with
the default backends) being better scalability, drastically less memory
diff --git a/lib/Hailo.pm b/lib/Hailo.pm
index f1a9b6b..c1e8824 100644
--- a/lib/Hailo.pm
+++ b/lib/Hailo.pm
@@ -2,11 +2,14 @@ package Hailo;
use 5.010;
use autodie qw(open close);
-use Class::MOP;
-use Moose;
-use MooseX::StrictConstructor;
-use MooseX::Types::Moose qw/Int Str Bool HashRef/;
-use MooseX::Getopt;
+use Any::Moose;
+use Any::Moose 'X::Getopt';
+use Any::Moose 'X::Types::'.any_moose() => [qw/Int Str Bool HashRef/];
+BEGIN {
+ return unless Any::Moose::moose_is_preferred();
+ require MooseX::StrictConstructor;
+ MooseX::StrictConstructor->import;
+}
use Module::Pluggable (
search_path => [ map { "Hailo::$_" } qw(Storage Tokenizer UI) ],
except => [
@@ -21,7 +24,7 @@ use namespace::clean -except => [ qw(meta plugins) ];
our $VERSION = '0.19';
-with qw(MooseX::Getopt::Dashes);
+with any_moose('X::Getopt::Dashes');
has help => (
traits => [qw(Getopt)],
@@ -264,7 +267,12 @@ sub _new_class {
die "Couldn't find a class name matching '$class' in plugins '@plugins'";
}
- eval { Class::MOP::load_class($pkg) };
+ if (Any::Moose::moose_is_preferred()) {
+ require Class::MOP;
+ eval { Class::MOP::load_class($pkg) };
+ } else {
+ eval qq[require $pkg];
+ }
die $@ if $@;
return $pkg->new(%$args);
@@ -589,8 +598,8 @@ command-line invocation.
=head1 DESCRIPTION
Hailo is a fast and lightweight markov engine intended to replace
-L<AI::MegaHAL|AI::MegaHAL>. It has a lightweight L<Moose|Moose>-based core
-with pluggable L<storage|Hailo::Role::Storage> and
+L<AI::MegaHAL|AI::MegaHAL>. It has a L<Mouse|Mouse> (or L<Moose|Moose>)
+based core with pluggable L<storage|Hailo::Role::Storage> and
L<tokenizer|Hailo::Role::Tokenizer> backends.
It is similar to MegaHAL in functionality, the main differences (with the
diff --git a/lib/Hailo/Role/Arguments.pm b/lib/Hailo/Role/Arguments.pm
index 903b8be..45de217 100644
--- a/lib/Hailo/Role/Arguments.pm
+++ b/lib/Hailo/Role/Arguments.pm
@@ -1,7 +1,7 @@
package Hailo::Role::Arguments;
use 5.010;
-use MooseX::Role::Strict;
-use MooseX::Types::Moose qw/HashRef/;
+use Any::Moose '::Role';
+use Any::Moose 'X::Types::'.any_moose() => [qw/HashRef/];
use namespace::clean -except => 'meta';
our $VERSION = '0.19';
diff --git a/lib/Hailo/Role/Storage.pm b/lib/Hailo/Role/Storage.pm
index cf999d4..9518620 100644
--- a/lib/Hailo/Role/Storage.pm
+++ b/lib/Hailo/Role/Storage.pm
@@ -1,7 +1,7 @@
package Hailo::Role::Storage;
use 5.010;
-use MooseX::Role::Strict;
-use MooseX::Types::Moose qw<Str Int>;
+use Any::Moose '::Role';
+use Any::Moose 'X::Types::'.any_moose() => [qw/Str Int/];
use List::Util qw<min>;
use namespace::clean -except => 'meta';
diff --git a/lib/Hailo/Role/Tokenizer.pm b/lib/Hailo/Role/Tokenizer.pm
index c2537ce..63ab3a4 100644
--- a/lib/Hailo/Role/Tokenizer.pm
+++ b/lib/Hailo/Role/Tokenizer.pm
@@ -1,6 +1,6 @@
package Hailo::Role::Tokenizer;
use 5.010;
-use MooseX::Role::Strict;
+use Any::Moose '::Role';
use namespace::clean -except => 'meta';
our $VERSION = '0.19';
diff --git a/lib/Hailo/Role/UI.pm b/lib/Hailo/Role/UI.pm
index bad33f7..4aa872f 100644
--- a/lib/Hailo/Role/UI.pm
+++ b/lib/Hailo/Role/UI.pm
@@ -1,6 +1,6 @@
package Hailo::Role::UI;
use 5.010;
-use MooseX::Role::Strict;
+use Any::Moose '::Role';
use namespace::clean -except => 'meta';
our $VERSION = '0.19';
diff --git a/lib/Hailo/Storage/DBD.pm b/lib/Hailo/Storage/DBD.pm
index 48cc551..ec78928 100644
--- a/lib/Hailo/Storage/DBD.pm
+++ b/lib/Hailo/Storage/DBD.pm
@@ -1,8 +1,12 @@
package Hailo::Storage::DBD;
use 5.010;
-use Moose;
-use MooseX::StrictConstructor;
-use MooseX::Types::Moose qw<ArrayRef HashRef Int Str Bool>;
+use Any::Moose;
+use Any::Moose 'X::Types::'.any_moose() => [qw<ArrayRef HashRef Int Str Bool>];
+BEGIN {
+ return unless Any::Moose::moose_is_preferred();
+ require MooseX::StrictConstructor;
+ MooseX::StrictConstructor->import;
+}
use DBI;
use List::Util qw<first shuffle>;
use List::MoreUtils qw<uniq>;
diff --git a/lib/Hailo/Storage/DBD/Pg.pm b/lib/Hailo/Storage/DBD/Pg.pm
index ab571a0..6d28247 100644
--- a/lib/Hailo/Storage/DBD/Pg.pm
+++ b/lib/Hailo/Storage/DBD/Pg.pm
@@ -1,7 +1,11 @@
package Hailo::Storage::DBD::Pg;
use 5.010;
-use Moose;
-use MooseX::StrictConstructor;
+use Any::Moose;
+BEGIN {
+ return unless Any::Moose::moose_is_preferred();
+ require MooseX::StrictConstructor;
+ MooseX::StrictConstructor->import;
+}
use namespace::clean -except => 'meta';
our $VERSION = '0.19';
diff --git a/lib/Hailo/Storage/DBD/SQLite.pm b/lib/Hailo/Storage/DBD/SQLite.pm
index 8c90718..73ff75e 100644
--- a/lib/Hailo/Storage/DBD/SQLite.pm
+++ b/lib/Hailo/Storage/DBD/SQLite.pm
@@ -1,7 +1,11 @@
package Hailo::Storage::DBD::SQLite;
use 5.010;
-use Moose;
-use MooseX::StrictConstructor;
+use Any::Moose;
+BEGIN {
+ return unless Any::Moose::moose_is_preferred();
+ require MooseX::StrictConstructor;
+ MooseX::StrictConstructor->import;
+}
use namespace::clean -except => 'meta';
our $VERSION = '0.19';
diff --git a/lib/Hailo/Storage/DBD/mysql.pm b/lib/Hailo/Storage/DBD/mysql.pm
index 66ea7d8..68e6bbf 100644
--- a/lib/Hailo/Storage/DBD/mysql.pm
+++ b/lib/Hailo/Storage/DBD/mysql.pm
@@ -1,7 +1,11 @@
package Hailo::Storage::DBD::mysql;
use 5.010;
-use Moose;
-use MooseX::StrictConstructor;
+use Any::Moose;
+BEGIN {
+ return unless Any::Moose::moose_is_preferred();
+ require MooseX::StrictConstructor;
+ MooseX::StrictConstructor->import;
+}
use List::MoreUtils qw< all >;
use namespace::clean -except => 'meta';
diff --git a/lib/Hailo/Tokenizer/Chars.pm b/lib/Hailo/Tokenizer/Chars.pm
index 153886b..e8eb7a9 100644
--- a/lib/Hailo/Tokenizer/Chars.pm
+++ b/lib/Hailo/Tokenizer/Chars.pm
@@ -1,6 +1,11 @@
package Hailo::Tokenizer::Chars;
use 5.010;
-use Moose;
+use Any::Moose;
+BEGIN {
+ return unless Any::Moose::moose_is_preferred();
+ require MooseX::StrictConstructor;
+ MooseX::StrictConstructor->import;
+}
use namespace::clean -except => 'meta';
our $VERSION = '0.19';
diff --git a/lib/Hailo/Tokenizer/Words.pm b/lib/Hailo/Tokenizer/Words.pm
index 0c1f4fc..8fa258d 100644
--- a/lib/Hailo/Tokenizer/Words.pm
+++ b/lib/Hailo/Tokenizer/Words.pm
@@ -1,8 +1,12 @@
package Hailo::Tokenizer::Words;
use 5.010;
use utf8;
-use Moose;
-use MooseX::StrictConstructor;
+use Any::Moose;
+BEGIN {
+ return unless Any::Moose::moose_is_preferred();
+ require MooseX::StrictConstructor;
+ MooseX::StrictConstructor->import;
+}
use namespace::clean -except => 'meta';
our $VERSION = '0.19';
diff --git a/lib/Hailo/UI/ReadLine.pm b/lib/Hailo/UI/ReadLine.pm
index 0549519..5d8e693 100644
--- a/lib/Hailo/UI/ReadLine.pm
+++ b/lib/Hailo/UI/ReadLine.pm
@@ -1,7 +1,11 @@
package Hailo::UI::ReadLine;
use 5.010;
-use Moose;
-use MooseX::StrictConstructor;
+use Any::Moose;
+BEGIN {
+ return unless Any::Moose::moose_is_preferred();
+ require MooseX::StrictConstructor;
+ MooseX::StrictConstructor->import;
+}
use Encode 'decode';
use Hailo;
use Term::ReadLine;
diff --git a/script/hailo b/script/hailo
index b6c6e6f..a072b9e 100755
--- a/script/hailo
+++ b/script/hailo
@@ -1,7 +1,7 @@
#!/usr/bin/env perl
use 5.010;
use open qw< :encoding(utf8) :std >;
-use Moose;
+use Any::Moose;
use Encode qw(decode);
use Hailo;
use namespace::clean -except => 'meta';
diff --git a/t/00_diag.t b/t/00_diag.t
new file mode 100644
index 0000000..4f7d3ee
--- /dev/null
+++ b/t/00_diag.t
@@ -0,0 +1,7 @@
+use strict;
+use Any::Moose;
+use Test::More tests => 1;
+
+my $m = any_moose();
+diag("Testing with $^X $] using $m for Moose");
+pass("Token test");
diff --git a/t/lib/Hailo/Test.pm b/t/lib/Hailo/Test.pm
index af47bcc..061eb12 100644
--- a/t/lib/Hailo/Test.pm
+++ b/t/lib/Hailo/Test.pm
@@ -1,7 +1,7 @@
package Hailo::Test;
use 5.010;
use autodie;
-use Moose;
+use Any::Moose;
use Hailo;
use Test::More;
use File::Spec::Functions qw(catfile);
@@ -124,7 +124,14 @@ sub spawn_storage {
);
if (exists $classes{$storage}) {
- eval { Class::MOP::load_class($classes{$storage}) };
+ my $pkg = $classes{$storage};
+ if (Any::Moose::moose_is_preferred()) {
+ require Class::MOP;
+ eval { Class::MOP::load_class($pkg) };
+ } else {
+ eval qq[require $pkg];
+ }
+
return if $@;
}
diff --git a/t/usage/options-and-usage.t b/t/usage/options-and-usage.t
index 79303b9..1996499 100644
--- a/t/usage/options-and-usage.t
+++ b/t/usage/options-and-usage.t
@@ -2,7 +2,7 @@ use 5.010;
use strict;
use warnings;
use List::MoreUtils qw(uniq);
-use Test::More tests => 39;
+use Test::More tests => 22;
use Test::Exception;
use Test::Output;
use Hailo;
@@ -93,12 +93,17 @@ is( sub {
# order
dies_ok { Hailo->new( order => undef ) } "undef order";
dies_ok { Hailo->new( order => "foo" ) } "Str order";
-for (my $i = 1; $i <= 10e10; $i += $i * 2) {
+for (my $i = 1; $i <= 10e2; $i += $i * 2) {
cmp_ok( Hailo->new( order => $i )->order, '==', $i, "The order is what we put in ($i)" );
}
# new
-dies_ok { Hailo->new( qw( a b c d ) ) } "Hailo dies on unknown arguments";
+SKIP: {
+ if (Any::Moose::mouse_is_preferred()) {
+ skip "Mouse doesn't have X::StrictConstructor", 1;
+ }
+ dies_ok { Hailo->new( qw( a b c d ) ) } "Hailo dies on unknown arguments";
+}
### Usage
diff --git a/utils/crunchbase-companies b/utils/crunchbase-companies
index 59196b6..0db64d3 100755
--- a/utils/crunchbase-companies
+++ b/utils/crunchbase-companies
@@ -1,6 +1,6 @@
#!/usr/bin/env perl
use 5.010;
-use Moose;
+use Any::Moose;
use WWW::Mechanize;
=head1 NAME
diff --git a/utils/hailo-benchmark b/utils/hailo-benchmark
index c47dd74..1acc5c8 100755
--- a/utils/hailo-benchmark
+++ b/utils/hailo-benchmark
@@ -1,7 +1,7 @@
#!/usr/bin/env perl
use 5.010;
use lib 't/lib';
-use Moose;
+use Any::Moose;
use Hailo::Test;
use Benchmark qw(:all);
use File::Temp qw(tempfile tempdir);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.