requires 'Catalyst::View::JSON';
requires 'Moose';
requires 'namespace::clean';
+requires 'aliased';
+requires 'Catalyst::Model::Adaptor';
catalyst;
+test_requires 'Test::Exception';
+test_requires 'Test::More';
+
+
tests_recursive;
install_script glob('script/*.pl');
--- /dev/null
+Notes:
+
+Snippet Store:
+* In memory RS-like thing (i.e. a cache with an RS like interface)
+* Snippets are just hashes: { text => 'foo' }
+
+* create(text => $text): make a new snippet.
+* find(id): get a snippet
+
+Snippet:
+
+* has id and text accessors
+* knows if it has been translated
+* and how to translate itself.
+
+Translator:
+* A text -> text transformer
+* Work done by translation drivers
+* Queryable translations (can I go to X?)
+
+Translation Driver:
+* Has one method, 'translate' that takes a string and returns the translated one
+
+
+Practical sessions:
+
+* Snippets and Translators
+*
+
+Other Notes:
+* Not sure the point of Test::Moose, I often just call the accessor and
+ check that it behaves right, I don't really care at the test level if
+ this is an accessor or some vodoo sacrifice so long as it works how i
+ want.
+
+
--- /dev/null
+use strict;
+use warnings;
+use Test::More qw(no_plan);
+use Test::Moose;
+use Test::Exception;
+use aliased 'LolCatalyst::Lite::Snippet';
+
+{ package MockTranslator;
+ use Moose;
+ sub can_translate_to { $_[1] eq 'uc' };
+
+ sub translate { return uc $_[1] };
+}
+
+my ($id, $snippet);
+
+has_attribute_ok(Snippet, "id", "Snippets know about thier own id");
+has_attribute_ok(Snippet, "text", "Snippets have text attr");
+
+
+dies_ok {
+ $snippet = Snippet->new(
+ id => rand 9_999,
+ translator => MockTranslator->new
+ )
+} qr/\(text\) is required/;
+
+dies_ok {
+ $snippet = Snippet->new(
+ text => "hi there",
+ translator => MockTranslator->new
+ )
+} qr/\(id\) is required/;
+
+dies_ok {
+ $snippet = Snippet->new(
+ id => rand 9_999,
+ text => "hi there",
+ )
+} qr/\(translator\) is required/;
+
+lives_ok {
+ $snippet = Snippet->new(
+ id => ($id = rand 9_999),
+ text => "hi there",
+ translator => MockTranslator->new
+ )
+} "Can create a snippet";
+
+is($snippet->id, $id, "this snippet has the right id");
+is($snippet->text, "hi there");
+
+is($snippet->translated(), "HI THERE", "and the snippet can be translated");
+
+