[Jifty-commit] r3083 - in jifty/trunk: .

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Tue Apr 3 03:52:08 EDT 2007


Author: jesse
Date: Tue Apr  3 03:52:07 2007
New Revision: 3083

Modified:
   jifty/trunk/   (props changed)
   jifty/trunk/doc/talks/present-slides
   jifty/trunk/doc/talks/yapc.asia.2007.txt

Log:
 r54417 at dhcp207:  jesse | 2007-04-03 16:51:42 +0900
  * ok. mostly ready


Modified: jifty/trunk/doc/talks/present-slides
==============================================================================
--- jifty/trunk/doc/talks/present-slides	(original)
+++ jifty/trunk/doc/talks/present-slides	Tue Apr  3 03:52:07 2007
@@ -5,21 +5,16 @@
 use Term::ANSIScreen qw/:color :cursor :screen :keyboard/;
 use Term::ReadKey;
 use Text::Autoformat;
+our @SLIDES;
 
-my $file = shift @ARGV;
-my $handle;
-open( $handle, "<$file" ) || die $!;
-
-my $datadata = join( '', <$handle> );
-
-my @slides  = split( /^----?\s*$/mi, $datadata );
+load_slides();
 my $counter = 0;
 my $slides_played = {};
 	my $title;
-while ( $counter <= $#slides ) {
+while ( $counter <= $#SLIDES ) {
     my $mode = 'text';
     my ( $cols, $rows, undef, undef ) = GetTerminalSize();
-    my $slide = $slides[$counter];
+    my $slide = $SLIDES[$counter];
     my $console = Term::ANSIScreen->new;
     $console->Cls;
     $console->Cursor(1,1);
@@ -34,10 +29,10 @@
 	}
 
     if ($slide =~ s/#\s*`(.*?)`//m) {
-	#my $cmd = $1;
-	#if(!$slides_played->{$counter} && ($slides_played->{$counter} = fork() )) {
-	#`$cmd>/dev/null 2>/dev/null`;
-	#}
+	my $cmd = $1;
+	if(!$slides_played->{$counter}) {
+	`$cmd>/dev/null 2>/dev/null &`;
+	$slides_played->{$counter}++}
     }
     if ( $slide =~ s/#\s*mode.*?perl.*?$//gms ) {
         $mode = 'perl';
@@ -55,7 +50,8 @@
     }
  
     if ( $slide =~ /(\S+)\s*\n\s*(\S+)/m ) {
-	
+	my $lines = scalar split(/\n/,$slide);
+	$console->Cursor(0, int(($rows/2)-($lines/2))-1);
     	print $slide;
     } else {
 	chomp $slide;
@@ -64,17 +60,13 @@
 	if ($left < 0 ){
 		$left = 0;
 	}
-        $console->Cursor( 
-		$left,	
-		int($rows/2)-1, 
-
-);
+        $console->Cursor( $left,	int($rows/2)-1, );
 	print $slide."\n";
     }
 
 
     $console->Cursor( 0, ( $rows - 1 ) );
-    print "$counter/" . $#slides;
+    print "$counter/" . $#SLIDES;
     ReadMode 4;
     my $key = ReadKey(0);
     ReadMode 0;
@@ -84,7 +76,9 @@
     if ( $key =~ /^(?: |\n|n)/ ) {
         $counter++;
     } elsif ( $key eq 'r' ) {
+	load_slides();
         next;
+
     } else {
         $counter--;
         if ( $counter < 0 ) {
@@ -93,3 +87,12 @@
     }
 }
 
+sub load_slides {
+my $file = $ARGV[0];
+my $handle;
+open( $handle, "<$file" ) || die $!;
+
+my $datadata = join( '', <$handle> );
+
+ @SLIDES  = split( /^----?\s*$/mi, $datadata );
+}

Modified: jifty/trunk/doc/talks/yapc.asia.2007.txt
==============================================================================
--- jifty/trunk/doc/talks/yapc.asia.2007.txt	(original)
+++ jifty/trunk/doc/talks/yapc.asia.2007.txt	Tue Apr  3 03:52:07 2007
@@ -1,7 +1,7 @@
 !!Jesse Vincent - Best Practical
 Domain Specific Languages in Perl
 ---
-!!DSLs in Perl 
+!!A bit about DSLs
 DSLs are 'little languages' for specific programming tasks
 ---
 DSLs are easier to read
@@ -249,6 +249,7 @@
 - Injection of functions
 ---
 #mode perl
+# The syntax we wanted
 score => type is 'int',
   is immutable,
   default is '0',
@@ -256,7 +257,18 @@
   label is 'Score',
   since is '0.0.7';
 ---
-Prototype hacking
+#mode perl
+How it parsed
+'is'->type('int', 
+  'immutable'->is, 
+   'is'->default('0', 
+      'as'->render('text', 
+        'is'->label('Score', 
+          'is'->since('0.0.7')))));
+---
+How can we fix that?
+---
+Prototype hacking!
 ---
 #mode perl
 sub is ($) { return shift };
@@ -276,11 +288,18 @@
   label is 'Score',
   since is '0.0.7';
 
-# parses to:
+# Now this parses like this:
 
- type(is('int')), is('immutable'), default(is('0')), render(as('text')), label(is('Score')), since(is('0.0.7'));
----
-TODO: function injection
+ type(is('int')), 
+ is('immutable'), 
+ default(is('0')), 
+ render(as('text')), 
+ label(is('Score')), 
+ since(is('0.0.7'));
+---
+Downsides
+- Limited flexibility
+- Needs new functions for every attribute
 ---
 !!Take 2:
 Object::Declare
@@ -317,6 +336,7 @@
 - it installs some methods...
 - ...is::AUTOLOAD and UNIVERSAL::is and as::AUTOLOAD
 - it runs the closure
+- it hands the result off to a method of your choice
 - it removes its magic symbols
 
 ---
@@ -384,9 +404,9 @@
 
 sub item {
     my $content = shift;
-    return 
-	div { attr { class => 'item' };
-       	      h2 {$content};
+    div {
+        attr { class => 'item' };
+        h2 {$content};
     };
 
 }
@@ -398,12 +418,6 @@
 Our HTML is magically valid.
 (Syntax errors are...Syntax Errors)
 ---
-Inheritance
----
-Mixins
----
-Tricks we use
----
 !!Stashing our templates
 #mode perl
 template '/foo/index.html' => sub {... };
@@ -446,11 +460,11 @@
 !!Closures
 Now, about that syntax.
 ---
-HTML tags take blocks
-of content.
+HTML tags take blocks of content.
+---
+Our tag methods take blocks of perl.
 ---
-Our tag methods take 
-blocks. (Of perl)
+They return closures when you want them to
 ---
 #mode perl
 sub h1 (&;$) {
@@ -465,6 +479,14 @@
   }
 }
 ---
+We install methods for all the HTML tags
+---
+#mode perl
+use CGI ();
+install_tag($_) for ( @CGI::EXPORT_TAGS{
+		qw/:html2 :html3 :html4 :netscape :form/}
+);
+---
 !!Not everything is roses
 (Here's where it all goes wrong)
 ---
@@ -500,24 +522,28 @@
 ---
 ORZ
 ---
-Not covering:
-
-- Our own method dispatch and inheritance tree
-- $self hacking
-- buffers
-
+Can anybody help me?
 ---
+!!
 Test::WWW::Declare
 ---
 !!Test::WWW::Declare
+In early development
+---
+It might change
+---
 Web test scripts are UGLY
 ---
+Test::WWW::Declare is PRETTY
+---
 - Simple, declarative web testing
 - Easy to read
 - Easy to write
 - Looks more like what users do
 ---
 #mode perl
+# Test::WWW::Mechanize
+
 my $server=Jifty::Test->make_server;
 isa_ok($server, 'Jifty::Server');
 my $URL = $server->started_ok;
@@ -532,70 +558,68 @@
 We built on Test::More and WWW::Mechanize
 ---
 #mode perl
-session "check logins" => run {
-    flow "basic connectivity" => check {
-        get 'http://fsck.com';
-        content should match qr{fsck.com};
-        click href qr{book};
-        content should match qr{RT Essentials}i;
-    };
+
+# Test::WWW::Declare
+
+session "search" => run {
+    flow "google searches work" => check {
+        get 'http://google.com/ncr'; 
+        fill form 'f' => { q   => 'Squeamish ossifrage' };
+        click button 'Google Search';
+    }
 };
 ---
-In early development
+Regular tests keep running on failure
 ---
-- Sample usage
-    - Explanation of the sample usage's meaning
-    - Comparison with traditional code 
-    - Why we like it
+Makes no sense when a failure means you lose context
 ---
-- Tricks we use to make it go
+Every 'check' block aborts on failure
 ---
-
+Abort means 'failing test'
+---
+Every named 'session' gets its own cookie jar and WWW::Mechanize
+---
+#mode perl
 session "check logins" => run {
     flow "basic connectivity" => check {
         get 'http://fsck.com';
         content should match qr{fsck.com};
         click href qr{book};
         content should match qr{RT Essentials}i;
-   
-
     };
 };
-
----
-Why do we make this valid syntax?
- content should match qr{RT Essentials}i;
----
-Readability
 ---
-Understandability
+What's the weird syntax?
 ---
-It feels English-y.
+# mode perl
+content should match qr{RT Essentials}i;
 ---
-
+#mode perl
 content should match qr{RT Essentials}i;
 
-   vs
+#   vs
 
 ok($req->content =~ /RT Essentials/i);
-
 ---
+# mode perl
+# How do we make this valid perl?
 
-How do we make this valid perl?
- content should match qr{RT Essentials}i;
+content should match qr{RT Essentials}i;
 ---
-
-        - Prototypes
+Prototypes
 ---
+#mode perl
 sub match ($) {
     return shift;
 }   
 ---
+#mode perl
 sub should ($) {
     my $item = shift;
     return $item;
 }
 ---
+#mode perl
 sub content ($) { 
     my $regex = shift;
     unless ( mech()->content =~ /$regex/ ) {
@@ -603,24 +627,18 @@
     }
 }
 ---
- - eval, the  (&) prototype and  custom test functions
+!!Conclusion
+Creating DSLs is lots of fun
 ---
-     check {
-        # do stuff that won't fail
-    };
+Creating DSLs can be a lot of work
 ---
-
-
-* Other interesting usages of DSLs in Perl
-
-
+Creating DSLs helps you learn Perl internals
 ---
-Problems with DSLs
+Creating DSLs helps find bugs in Perl
 ---
-Debugging can get harder
+DSLs can make coding more fun
 ---
-Editors can get confused
+Challenge: CPAN some Japanese DSLs
 ---
-Hackers can get confused
+Thanks
 ---
-


More information about the Jifty-commit mailing list