<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>Job van Achterberg</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/job_van_achterberg/" />
    <link rel="self" type="application/atom+xml" href="http://blogs.perl.org/users/job_van_achterberg/atom.xml" />
    <id>tag:blogs.perl.org,2009-11-03:/users/job_van_achterberg//465</id>
    <updated>2011-09-02T11:32:13Z</updated>
    <subtitle>A blog about the Perl programming language</subtitle>
    <generator uri="http://www.sixapart.com/movabletype/">Movable Type Pro 4.38</generator>

<entry>
    <title>Making RESTful Dancing easy with Dancer::Plugin::REST</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/job_van_achterberg/2011/09/making-restful-dancing-easy-with-dancerpluginrest.html" />
    <id>tag:blogs.perl.org,2011:/users/job_van_achterberg//465.2158</id>

    <published>2011-09-01T14:01:30Z</published>
    <updated>2011-09-02T11:32:13Z</updated>

    <summary>An useful plugin for writing RESTful Dancer web applications is Dancer::Plugin::Rest by Alexis Sukrieh, available at https://metacpan.org/module/Dancer::Plugin::REST. To use it when defining routes, easily: package MyApp; use Dancer; use Dancer::Plugin::REST; This exports the resource keyword, which can be used as...</summary>
    <author>
        <name>Job van Achterberg</name>
        
    </author>
    
    <category term="dancerrest" label="dancer rest" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/job_van_achterberg/">
        <![CDATA[<p>An useful plugin for writing RESTful Dancer web applications is Dancer::Plugin::Rest by <a href="https://metacpan.org/author/SUKRIA">Alexis Sukrieh</a>, available at <a href="https://metacpan.org/module/Dancer::Plugin::REST">https://metacpan.org/module/Dancer::Plugin::REST</a>. </p>

<p>To use it when defining routes, easily:</p>

<p><code><br />
package MyApp;</p>

<p>use Dancer;<br />
use Dancer::Plugin::REST;<br />
</code></p>

<p>This exports the <strong>resource</strong> keyword, which can be used as such:</p>

<p><code><br />
resource camel => (<br />
    create => sub {},<br />
    get => sub {},<br />
    update => sub {},<br />
    delete => sub {},<br />
);<br />
</code></p>

<p>This automatically creates the following route handlers:</p>

<ul>
	<li><b>post</b> /camel <i>(create)</i></li>
	<li><b>post</b> /camel.:format <i>(create)</i></li>
	<li><b>get</b> /camel/:id <i>(read)</i></li>
	<li><b>get</b> /camel/:id.:format <i>(read)</i></li>
	<li><b>put</b> /camel/:id <i>(update)</i></li>
	<li><b>put</b> /camel/:id.:format <i>(update)</i></li>
	<li><b>del</b> /camel/:id <i>(delete)</i></li>
	<li><b>del</b> /camel/:id.:format <i>(delete)</i></li>
</ul>

<p>The format param can be used in requests such as</p>

<p><code><br />
GET /camel/larry.xml<br />
</code></p>

<p>Next to that, this module exports a whole bunch of error handler methods, such as</p>

<ul>
	<li>status_unauthorized</li>
        <li>status_ok</li>
        <li>status_length_required</li>
        <li>status_not_found</li>
        <li>status_forbidden</li> 
</ul>

<p>which can be used to make life easier:<br />
<code><br />
<in update handler><br />
return status_unauthorized("Not Larry") unless $user->is_larry;<br />
</code></p>

<p>If the code of the status you are using is equal or higher than 100, your error message will be the value of key 'error' ( { error => "Not Larry" } ) - otherwise it's just a verbatim. <strike>Of course it's expected that since you're working with REST, you're serialising your return values.</strike></p>

<p><strong>Some nitpicks:</strong><br />
<ul><br />
	<li>"get" should be called "read" for CRUD (create read update delete)</li><br />
        <li>The POD is incorrect.</li><br />
</ul></p>

<p>I earlier issued a pull request of a fork where I update the POD problem and renamed "get" to "read" as well as swapping the meaning of POST and PUT. I believed PUT should be CREATE, and POST update, even though this later proved to be incorrect. I hope the changes to POD will however be added. It's trivial, but correct.</p>

<p><strong>Closing words</strong><br />
This is one of those nifty little modules that makes writing a RESTful webapp just that little bit easier and makes your code more organised. I can recommend it!</p>]]>
        
    </content>
</entry>

<entry>
    <title>Switching to Dist::Zilla - a usage report</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/job_van_achterberg/2010/08/switching-to-distzilla---a-usage-report.html" />
    <id>tag:blogs.perl.org,2010:/users/job_van_achterberg//465.906</id>

    <published>2010-08-16T17:52:54Z</published>
    <updated>2010-08-16T19:46:40Z</updated>

    <summary>For a while there has been a problem in one of my modules - the tests for Postscript::TextDecode make use of Test::Most which it turned out most CPAN testers don&apos;t use by default. That&apos;s fair. It was on my list...</summary>
    <author>
        <name>Job van Achterberg</name>
        
    </author>
    
    <category term="cpandistzillapostscripttextdecode" label="cpan dist::zilla postscript::textdecode" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/job_van_achterberg/">
        <![CDATA[<p>For a while there has been a problem in one of my modules - the tests for Postscript::TextDecode make use of Test::Most which it turned out most CPAN testers don't use by default. That's fair. It was on my list of things to fix, but never with high priority.</p>

<p>Shortly after YAPC::EU::2010 I received a RT request from Andreas Koenig alerting me to the issue. At YAPC I had heard about this utility called Dist::Zilla which was supposed to make the managing of distributions a lot easier.</p>

<p>Off to CPAN. D::Z took a while to install but the install itself had no problems. I started reading the CPAN page and read Dist::Zilla::Tutorial. Since this was however limited, I directed my attention to the tutorial on dzil.org.</p>

<p>This tutorial has the style of a 'make your own adventure' children's book which was amusing. I found out that I could either start anew or switch my current distrubution over.</p>

<p>I decided to start anew and ran </p>

<p><strong><em>$ dzil setup</em> </strong></p>

<p>to configure dzil (the Dist::Zilla::App commandline utility) - it creates ~/dzil.ini.<br />
followed by </p>

<p><strong><em>$ dzil new Postscript-TextDecode</em> </strong></p>

<p>which created the Postscript-TextDecode directory for me, with in it dzil.ini and lib/Postscript/TextDecode.pm.</p>

<p>After that I pasted my existing code into TextDecode.pm and created t/Postscript-TextDecode.t. I could remove $VERSION since I now define that in dist.ini.</p>

<p>After some fiddling, <strong><em>$ dzil test</em></strong> did the testing and <strong><em>$ dzil release</em></strong> uploaded a gzipped tarball onto the PAUSE server.</p>

<p>In between all this, I encountered the following hurdles:</p>

<ul>
	<li><em>dzil test</em> and <em>dzil build</em> won't work without <em>[@Classic]</em> in the dist.ini. I do not know why.</li>
        <li>the documentation on dzil.org seems...incomplete, or at least appears to assume the reader has in-depth knowledge of the distribution creation process, while I am relatively new to this
        </li>
</ul>

<p>Still, it did not cost me huge amounts of time and in the long run this utility should really simplify the creation and maintenance of new modules. Not bad at all. And from what I've seen on CPAN, it's very easy to extend.</p>

<p>If I've missed obvious things, please direct me so I may learn.<br />
</p>]]>
        
    </content>
</entry>

<entry>
    <title>4 days at Eth0 Summer 2010</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/job_van_achterberg/2010/08/4-days-at-eth0-summer-2010.html" />
    <id>tag:blogs.perl.org,2010:/users/job_van_achterberg//465.889</id>

    <published>2010-08-12T12:20:48Z</published>
    <updated>2010-08-12T12:26:00Z</updated>

    <summary>Currently I&apos;m located at the Dutch Eth0 Summer 2010 event, which is a camp-with-tents-and-attend-talks-and-workshops event. My younger brother who studies IT went with a bunch of classmates, and I decided to tag along. So far it has been fun -...</summary>
    <author>
        <name>Job van Achterberg</name>
        
    </author>
    
    <category term="eth0perlfud" label="eth0 perl fud" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/job_van_achterberg/">
        <![CDATA[<p>Currently I'm located at the Dutch Eth0 Summer 2010 event, which is a camp-with-tents-and-attend-talks-and-workshops event. My younger brother who studies IT went with a bunch of classmates, and I decided to tag along.</p>

<p>So far it has been fun - I've done some Perl evangelising and handed out Round Tuits to random people (thanks for those Tuits, Wendy).</p>

<p>The overall view of Perl is the same ol' "Perl is line noise and the language hasn't seen changes in 10 years lol". While a rebuttal is easy, it's somewhat disheartening but not unexpected.</p>

<p>Other than that, not a bad tech festival.</p>]]>
        
    </content>
</entry>

<entry>
    <title>PerlTidy for gEdit</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/job_van_achterberg/2010/08/perltidy-for-gedit.html" />
    <id>tag:blogs.perl.org,2010:/users/job_van_achterberg//465.859</id>

    <published>2010-08-09T07:46:07Z</published>
    <updated>2010-08-09T07:50:59Z</updated>

    <summary>For any gEdit users out there: A while ago I&apos;ve written a perlTidy plugin for this editor. It&apos;s written in Python. I know, I know. But it was either that or C... For those of you interested, check it out...</summary>
    <author>
        <name>Job van Achterberg</name>
        
    </author>
    
    <category term="gedit" label="gedit" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="perltidy" label="perltidy" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/job_van_achterberg/">
        <![CDATA[<p>For any gEdit users out there: A while ago I've written a perlTidy plugin for this editor.<br />
It's written in Python. I know, I know. But it was either that or C...</p>

<p>For those of you interested, check it out at <a href="http://github.com/jkva/gedit-perltidy-plugin">GitHub</a></p>]]>
        
    </content>
</entry>

<entry>
    <title>YAPC::EU::2010, 3 great days</title>
    <link rel="alternate" type="text/html" href="http://blogs.perl.org/users/job_van_achterberg/2010/08/yapceu2010-3-great-days.html" />
    <id>tag:blogs.perl.org,2010:/users/job_van_achterberg//465.855</id>

    <published>2010-08-08T09:28:34Z</published>
    <updated>2010-08-08T10:46:11Z</updated>

    <summary>This year&apos;s YAPC::EU in Pisa was nothing short of amazing. While I am not sure if it will outdo my experiences in 2008 and 2009, it was everything I&apos;ve come to expect of YAPCs. While the flight was delayed, the...</summary>
    <author>
        <name>Job van Achterberg</name>
        
    </author>
    
    <category term="firstpost" label="firstpost" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="yapc" label="yapc" scheme="http://www.sixapart.com/ns/types#tag" />
    <category term="yapceu2010" label="yapceu2010" scheme="http://www.sixapart.com/ns/types#tag" />
    
    <content type="html" xml:lang="en" xml:base="http://blogs.perl.org/users/job_van_achterberg/">
        <![CDATA[<p>This year's YAPC::EU in Pisa was nothing short of amazing. While I am not sure if it will outdo my experiences in 2008 and 2009, it was everything I've come to expect of YAPCs.</p>

<p>While the flight was delayed, the hotel room had air conditioning (that's a + compared to Lisbon... ) and we went for some nice food in a restaurant near the river. </p>

<p>On the first day we walked a couple of meters to get to the YAPC buses (seriously, what a great arrangement) and met osfameron and some other attendees. We were at the hotel in 10 minutes and I just remember meeting a lot of people and attending talks, of which the keynote talk was the most surreal.<br />
By the time we went to the evening dinner I felt like I'd been there for a week already.</p>

<p>Thursday was more of that same goodness, meeting interesting people, meatspace and non-meatspace friends, and feeling that sense of belonging to an enthusiastic community. The evening before I had decided to do a lightning talk on Postscript::TextDecode and to my surprise (and horror!) it got accepted. But it went very well on Thursday evening, nerves aside.</p>

<p>Friday went by fast, and after it was all over everyone seemed to have the same good idea of going into town to socialize with beer. At about 3am I got back to the hotel. </p>

<p>Good times, I'm looking forward to Latvia in 2011.</p>

<p>Oh, and first post.</p>]]>
        
    </content>
</entry>

</feed>
