[Jifty-commit] r580 - jifty/trunk/lib/Jifty jifty/trunk/lib/Jifty/Mason

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Mon Feb 13 23:02:27 EST 2006


Author: jesse
Date: Mon Feb 13 23:02:20 2006
New Revision: 580

Modified:
   /   (props changed)
   jifty/trunk/lib/Jifty/Action/Devel/FileEditor.pm
   jifty/trunk/lib/Jifty/Dispatcher.pm
   jifty/trunk/lib/Jifty/JSON.pm
   jifty/trunk/lib/Jifty/Mason/Halo.pm
   jifty/trunk/lib/Jifty/Response.pm
   jifty/trunk/lib/Jifty/Test.pm

Log:
 r23699 at truegrounds:  jesse | 2006-02-13 22:46:11 -0500
 * Documentation coverage pass.


Modified: jifty/trunk/lib/Jifty/Action/Devel/FileEditor.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Action/Devel/FileEditor.pm	(original)
+++ jifty/trunk/lib/Jifty/Action/Devel/FileEditor.pm	Mon Feb 13 23:02:20 2006
@@ -4,14 +4,73 @@
 use File::Spec;
 
 
+=head1 NAME
+
+Jifty::Action::Devel::FileEditor
+
+=head1 DESCRIPTION
+
+This action allows you to edit mason components (and eventually libraries)
+using Jifty's I<Action> system.  It should only be enabled when you're
+running Jifty in C<DevelMode>. 
+
+=head1 WARNING
+
+B<THIS ACTION LETS YOU REMOTELY EDIT EXECUTABLE CODE>.
+
+B<THIS IS DANGEROUS>
+
+
+
+=cut
+
+=head2 new
+
+Create a new C<FileEditor> action.
+
+=cut
+
 sub new {
-    my $class = shift; my $self = $class->SUPER::new(@_);
+    my $class = shift; 
+    my $self = $class->SUPER::new(@_);
     $self->sticky_on_success(1);
     $self->get_default_content; 
     return($self);
 
 }
 
+=head2 arguments
+
+Sets up this action's arguments.
+
+=over
+
+=item path
+
+Where to save the file
+
+=item file_type
+
+(One of mason_component or library)
+
+=item source_path
+
+Where to read the file from.
+
+=item destination_path
+
+Where to write the file to. If the current user can't write to 
+the source_path, defaults to something inside the app's directory.
+
+=item content
+
+The actual content of the file we're editing.
+
+
+=back
+
+=cut
+
 
 sub arguments {
     my $self = shift;
@@ -31,6 +90,14 @@
 
 }
 
+
+=head2 get_default_content
+
+Finds the version of the C<source_path> (of type C<file_type>) and loads it into C<content>.
+
+
+=cut
+
 sub get_default_content {
     my $self = shift;
 
@@ -58,10 +125,16 @@
     $self->argument_value(destination_path => File::Spec->catfile($local_template_base, $path));
 }
 
+=head2 validate_destination_path PATH
+
+Returns true if the user can write to the directory C<PATH>. False otherwise. Should be refactored to a C<path_writable> routine and a trivial validator.
+
+=cut
+
 sub validate_destination_path {
     my $self = shift;
     my $value = shift;
-    $self->{'write_to'} = ($value or $self->argument_value('qualified_path'));
+    $self->{'write_to'} = $value;
     unless ($self->{'write_to'}) {
         return  $self->validation_error( destination_path => "No destination path set. Where should I write this file?");
     }
@@ -71,6 +144,13 @@
     return $self->validation_ok;
 }
 
+
+=head2 take_action
+
+Writes the C<content> out to the C<destination_path>.
+
+=cut
+
 sub take_action {
     my $self = shift;
     my $dest  = $self->{'write_to'};

Modified: jifty/trunk/lib/Jifty/Dispatcher.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Dispatcher.pm	(original)
+++ jifty/trunk/lib/Jifty/Dispatcher.pm	Mon Feb 13 23:02:20 2006
@@ -111,6 +111,10 @@
 
 =head1 Data your dispatch routines has access to
 
+=head2 request
+
+The current L<Jifty::Request> object.
+
 =head2 $Dispatcher
 
 The current dispatcher object.
@@ -196,7 +200,7 @@
 
 =head2 dispatch $path
 
-Dispatch again using $path as the request path, preserving args.
+eispatch again using $path as the request path, preserving args.
 
 =head2 next_rule
 
@@ -214,6 +218,11 @@
 
 Redirect to another URI.
 
+
+=head2 next_show
+
+INTERNAL MAGIC YOU SHOULD NOT USE THAT ALEX SHOULD RENAME ;)
+
 =cut
 
 our @EXPORT = qw<

Modified: jifty/trunk/lib/Jifty/JSON.pm
==============================================================================
--- jifty/trunk/lib/Jifty/JSON.pm	(original)
+++ jifty/trunk/lib/Jifty/JSON.pm	Mon Feb 13 23:02:20 2006
@@ -30,13 +30,13 @@
     no strict 'refs';
     no warnings 'once';
     if (eval { require JSON::Syck; $JSON::Syck::VERSION >= 0.05 }) {
-        *jsonToObj = *jsonToObj_syck;
-        *objToJson = *objToJson_syck;
+        *jsonToObj = *_jsonToObj_syck;
+        *objToJson = *_objToJson_syck;
     }
     else {
         require JSON;
-        *jsonToObj = *jsonToObj_pp;
-        *objToJson = *objToJson_pp;
+        *jsonToObj = *_jsonToObj_pp;
+        *objToJson = *_objToJson_pp;
     }
 }
 
@@ -47,12 +47,12 @@
 
 =cut
 
-sub jsonToObj_syck {
+sub _jsonToObj_syck {
     local $JSON::Syck::SingleQuote = 0;
     JSON::Syck::Load($_[0]);
 }
 
-sub jsonToObj_pp {
+sub _jsonToObj_pp {
     return JSON::jsonToObj(@_);
 }
 
@@ -66,7 +66,7 @@
 
 =cut
 
-sub objToJson_syck {
+sub _objToJson_syck {
     my ($obj, $args) = @_;
 
     local $JSON::Syck::SingleQuote = $args->{singlequote};
@@ -76,7 +76,7 @@
 # We should escape double-quotes somehow, so that we can guarantee
 # that double-quotes *never* appear in the JSON string that is
 # returned.
-sub objToJson_pp {
+sub _objToJson_pp {
     my ($obj, $args) = @_;
 
     # Unless we're asking for single-quoting, just do what JSON.pm

Modified: jifty/trunk/lib/Jifty/Mason/Halo.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Mason/Halo.pm	(original)
+++ jifty/trunk/lib/Jifty/Mason/Halo.pm	Mon Feb 13 23:02:20 2006
@@ -5,6 +5,25 @@
 use Time::HiRes ();
 
 
+=head1 NAME
+
+Jifty::Mason::Halo
+
+=head1 DESCRIPTION
+
+
+=cut
+
+
+=head2 start_component_hook CONTEXT_OBJECT
+
+Whenever we start to render a component, check to see if we can draw a halo around the component.
+
+Either way, record halo metadata.
+
+=cut
+
+
 sub start_component_hook {
     my $self    = shift;
     my $context = shift;
@@ -38,6 +57,14 @@
     $context->request->out('<span class="halo">');
 }
 
+=head2 end_component_hook CONTEXT_OBJECT
+
+When we're done rendering a component, record how long it took
+and close off the halo C<span> if we have one.
+
+
+=cut
+
 sub end_component_hook {
     my $self    = shift;
     my $context = shift;
@@ -63,6 +90,15 @@
 
 }
 
+
+=head2 render_halo_actions STACK_FRAME
+
+When we're rendering the whole Mason component tree, this routine will
+render our bits for just one stack frame.
+
+
+=cut
+
 sub render_halo_actions {
     my $self    = shift;
     my $stack_frame = shift;
@@ -113,6 +149,15 @@
 
 }
 
+=head2 render_component_tree
+
+Once we're just about to finish rendering our HTML page (just before
+the C<</body>> tag, we should call render_component_tree to output all
+the halo data and metadata.
+
+
+=cut
+
 sub render_component_tree {
     my $self  = shift;
     my @stack = @{ Jifty->web->mason->notes('_halo_stack') };

Modified: jifty/trunk/lib/Jifty/Response.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Response.pm	(original)
+++ jifty/trunk/lib/Jifty/Response.pm	Mon Feb 13 23:02:20 2006
@@ -28,6 +28,14 @@
     bless {results => {}, headers => []}, $class;
 }
 
+
+=head2 add_header KEY => VALUE
+
+Add an HTTP header to the outgoing HTTP response. 
+
+=cut
+
+
 sub add_header {
     my $self = shift;
     # This one is so we can get jifty's headers into mason
@@ -38,6 +46,14 @@
     push @{$self->{headers}}, [@_];
 }
 
+=head2 headers
+
+Returns an array of key-value pairs of all the HTTP headers we want to
+stick on the outgoing HTTP request.
+
+
+=cut
+
 sub headers {
     my $self = shift;
     return @{$self->{headers}};

Modified: jifty/trunk/lib/Jifty/Test.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Test.pm	(original)
+++ jifty/trunk/lib/Jifty/Test.pm	Mon Feb 13 23:02:20 2006
@@ -173,7 +173,7 @@
         unlink mailbox();
 
         # Remove testing db
-        Jifty->handle->disconnect();
+        Jifty->handle->disconnect() if (Jifty->handle);
         Log::Log4perl->get_logger("SchemaTool")->less_logging(3);
         my $schema = Jifty::Script::Schema->new;
         $schema->{drop_database} = 1;


More information about the Jifty-commit mailing list