Escape-Houdini
view release on metacpan or search on metacpan
contrib/benchmark.pl view on Meta::CPAN
</li>
<li value="3" title="MetaCPAN">
<a href="http://babyl.ca/techblog/tag/MetaCPAN">MetaCPAN</a>
</li>
<li value="3" title="perl">
<a href="http://babyl.ca/techblog/tag/perl">perl</a>
</li>
<li value="153" title="Perl">
<a href="http://babyl.ca/techblog/tag/Perl">Perl</a>
</li>
<li value="3" title="Template::Caribou">
<a href="http://babyl.ca/techblog/tag/Template::Caribou">Template::Caribou</a>
</li>
</ul>
<div style="text-align:right;">
<a href="http://babyl.ca/techblog/tags">all tags</a>
</div>
</div>
<script type="text/javascript">$(function(){
$('#recent_tags').tagcloud({
type: "list",
colormin: "AB0404",
colormax: "AB0404"
}).find('li').css('padding-right', '3px' );
});
</script>
<div class="widget" style="text-align:center;">
<a href="http://github.com/yanick/galuga">
<img src="http://babyl.ca/techblog/static/galuga_button.png?v=0.6.0" style="border:0;"
alt="Powered by a Gamboling Beluga"/>
</a></div>
</div>
<div class="middle_column">
<div class="blog_entry">
<h2><a href="http://babyl.ca/techblog/entry/metacpan-js">MetaCPAN JavaScript API</a></h2>
<div class="entry_info">
<div style="float: right">
created: Sun, Apr 14 2013</div>
</div>
<div><p>Sometimes, it's humongous revolutions. Most of the time, it's itsy bitsy
evolution steps. Today's hack definitively sits in the second category,
but I have the feeling it's a little dab of abstraction that is going to
provide a lot of itch relief.</p>
<p>You see, <a href="https://metacpan.org">MetaCPAN</a> does not only have a pretty face,
but also has a <a href="https://github.com/CPAN-API/cpan-api/wiki/Beta-API-docs">smashing backend</a>
that can be used <a href="http://explorer.metacpan.org/">straight-up</a> for fun and
profit.</p>
<p>Accessing REST endpoints is not hard, but it's a little bit of a low-level
chore. In Perl space, there is already <a href='http://search.cpan.org/dist/MetaCPAN-API'>MetaCPAN::API</a> to
abstract</p>
<pre class="brush: perl">my $ua = LWP::UserAgent;
my $me = decode_json(
$ua->get( 'https://api.metacpan.org/author/YANICK'
)->content;
</pre>
<p>into</p>
<pre class="brush: perl">my $mcpan = MetaCPAN::API;
my $me = $mcpan->author('YANICK');
</pre>
<p>In JavaScript-land? Well, there was jQuery, of course:</p>
<pre><code>$.get('https://api.metacpan.org/author/YANICK').success( function(data) {
alert( 'hi there ' + data.name );
});
</code></pre>
<p>But now there is also <a href="https://github.com/yanick/metacpan.js">metacpan.js</a>: </p>
<pre><code>$.metacpan().author('YANICK').success( function(data) {
alert( 'hi there ' + data.name );
});
</code></pre>
<p>The plugin is still very simple and only implements <code>author()</code>, <code>module()</code>,
<code>release()</code> and <code>file()</code>. And each of those methods is nothing but a glorified
wrapper around the underlying <code>$.ajax()</code> calls. But, then again, isn't the road to
heaven paved with glorified wrappers? (which could be more of an indication of
the terrible littering habits of angels than anything else, mind you) </p>
<p>Enjoy (and/or fork, depending on how much the current code is already
scratching your own itch)!</p>
</div>
<script type="text/javascript">
SyntaxHighlighter.all();
</script>
<div class="tags">
<b>tags: </b>
<a href='http://babyl.ca/techblog/tag/MetaCPAN'>MetaCPAN</a>, <a href='http://babyl.ca/techblog/tag/Perl'>Perl</a></div>
<div id="disqus_thread"></div>
<script type="text/javascript">
/**
* var disqus_identifier; [Optional but recommended: Define a unique identifier (e.g. post id or slug) for this thread]
*/
var disqus_identifier = 'metacpan-js';
( run in 0.834 second using v1.01-cache-2.11-cpan-524268b4103 )