summary refs log tree commit diff
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-06-08 15:31:32 +0200
committerfranck cuny <franck@lumberjaph.net>2010-06-08 15:31:32 +0200
commite71a441a81f6f1d7e61fdb3c07e2f48ee10ba97d (patch)
tree082cc92aa529f373dec8ac497929f57068660afe
parentswitch to MX::Declare; rename some roles and dispatcher (diff)
downloadnet-http-console-e71a441a81f6f1d7e61fdb3c07e2f48ee10ba97d.tar.gz
move code to appropriate role
-rw-r--r--lib/Net/HTTP/Console.pm20
-rw-r--r--lib/Net/HTTP/Console/Dispatcher/HTTP.pm1
-rw-r--r--lib/Net/HTTP/Console/Role/API.pm7
-rw-r--r--lib/Net/HTTP/Console/Role/Plugins.pm13
4 files changed, 20 insertions, 21 deletions
diff --git a/lib/Net/HTTP/Console.pm b/lib/Net/HTTP/Console.pm
index 2036b47..eef3ba8 100644
--- a/lib/Net/HTTP/Console.pm
+++ b/lib/Net/HTTP/Console.pm
@@ -4,7 +4,6 @@ our $VERSION = 0.01;
 use MooseX::Declare;
 
 class Net::HTTP::Console {
-    use Try::Tiny;
 
     with 'MooseX::Getopt';
     with 'Net::HTTP::Console::Role::Headers';
@@ -16,25 +15,6 @@ class Net::HTTP::Console {
     has url         => (isa => 'Str', is => 'rw', predicate => 'has_url');
     has format      => (isa => 'Str', is => 'rw', predicate => 'has_format');
     has format_mode => (isa => 'Str', is => 'rw', predicate => 'has_format_mode');
-
-    method dispatch ($input)  {
-        my $result;
-        try {
-            foreach ($self->all_plugins) {
-                last if ($result = $_->dispatch($input));
-            }
-        }catch{
-            print "[ERROR]: ".$_;
-        };
-    }
-
-    method new_anonymous_method ($http_method, $path) {
-        $self->api_object->meta->add_net_api_method(
-            'anonymous',
-            method => $http_method,
-            path   => $path,
-        );
-    }
 }
 
 1;
diff --git a/lib/Net/HTTP/Console/Dispatcher/HTTP.pm b/lib/Net/HTTP/Console/Dispatcher/HTTP.pm
index 789c04c..5dc5719 100644
--- a/lib/Net/HTTP/Console/Dispatcher/HTTP.pm
+++ b/lib/Net/HTTP/Console/Dispatcher/HTTP.pm
@@ -30,7 +30,6 @@ class Net::HTTP::Console::Dispatcher::HTTP with Net::HTTP::Console::Dispatcher {
         return 1;
     }
 
-
     method _do_request($http_method, $path) {
         $self->application->new_anonymous_method($http_method, $path);
         try {
diff --git a/lib/Net/HTTP/Console/Role/API.pm b/lib/Net/HTTP/Console/Role/API.pm
index f9abc30..0b99796 100644
--- a/lib/Net/HTTP/Console/Role/API.pm
+++ b/lib/Net/HTTP/Console/Role/API.pm
@@ -30,6 +30,13 @@ role Net::HTTP::Console::Role::API {
         $o;
     }
 
+    method new_anonymous_method ($http_method, $path) {
+        $self->api_object->meta->add_net_api_method(
+            'anonymous',
+            method => $http_method,
+            path   => $path,
+        );
+    }
 }
 
 1;
diff --git a/lib/Net/HTTP/Console/Role/Plugins.pm b/lib/Net/HTTP/Console/Role/Plugins.pm
index a3136f2..d7bf7b5 100644
--- a/lib/Net/HTTP/Console/Role/Plugins.pm
+++ b/lib/Net/HTTP/Console/Role/Plugins.pm
@@ -4,6 +4,8 @@ use MooseX::Declare;
 
 role Net::HTTP::Console::Role::Plugins {
 
+    use Try::Tiny;
+    
     has dispatchers => (
         is         => 'rw',
         isa        => 'ArrayRef[Str]',
@@ -33,6 +35,17 @@ role Net::HTTP::Console::Role::Plugins {
             \@p;
         },
     );
+
+    method dispatch ($input)  {
+        my $result;
+        try {
+            foreach ($self->all_plugins) {
+                last if ($result = $_->dispatch($input));
+            }
+        }catch{
+            print "[ERROR]: ".$_;
+        };
+    }
 }
 
 1;