<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Cory O&#039;Daniel - These are just words &#187; javascript</title>
	<atom:link href="http://coryodaniel.com/index.php/tag/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://coryodaniel.com</link>
	<description>Software development, thoughts, and randomness</description>
	<lastBuildDate>Thu, 17 Nov 2011 21:18:05 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>A ruby wrapper for Google AjaxLibs (jquery, jquery ui, mootools, prototype, swfobject, etc) [Lazy GoogleJsApi Wrapper]</title>
		<link>http://coryodaniel.com/index.php/2010/02/25/a-ruby-wrapper-for-google-ajaxlibs-jquery-jquery-ui-mootools-prototype-swfobject-etc/</link>
		<comments>http://coryodaniel.com/index.php/2010/02/25/a-ruby-wrapper-for-google-ajaxlibs-jquery-jquery-ui-mootools-prototype-swfobject-etc/#comments</comments>
		<pubDate>Thu, 25 Feb 2010 20:13:27 +0000</pubDate>
		<dc:creator>Cory O'Daniel</dc:creator>
				<category><![CDATA[RubyDevelopment]]></category>
		<category><![CDATA[ajax libs]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://coryodaniel.com/?p=489</guid>
		<description><![CDATA[I like using the Google AjaxLibs API. Its cool to not host files when I don't have to, especially ones I know a user has already probably cached from Google anyway (even though Google Page speed busts my balls about too many DNS lookups  ).
I do on the other hand hate watching in the [...]]]></description>
			<content:encoded><![CDATA[<p>I like using the Google AjaxLibs API. Its cool to not host files when I don't have to, especially ones I know a user has already probably cached from Google anyway (even though Google Page speed busts my balls about too many DNS lookups <img src='http://coryodaniel.com/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> ).</p>
<p>I do on the other hand hate watching in the bottom of my browser "Waiting for google.com" when using the standard Javascript API for loading the Libraries like so:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot; src=&quot;http://www.google.com/jsapi?key=INSERT-YOUR-KEY&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
 google.load(&quot;jquery&quot;, &quot;1.4.2&quot;);
&lt;/script&gt;</pre></td></tr></table></div>

<p>And you don't have to wait, you can totally do something like:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js&quot;&gt;&lt;/script&gt;</pre></td></tr></table></div>

<p>Which is why I wrote this little ruby wrapper. Its nothing special. It just encapsulates all the URLs for the libraries and their versions to allow you to not remember the URL and not have to go looking for the documentation when you start a new app or just need an additional library.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># Docs: http://code.google.com/apis/ajaxlibs/documentation/index.html</span>
<span style="color:#008000; font-style:italic;">#</span>
<span style="color:#9966CC; font-weight:bold;">class</span> GoogleJsApi
  BaseURL = <span style="color:#996600;">&quot;http://ajax.googleapis.com/ajax/libs&quot;</span>.<span style="color:#9900CC;">freeze</span>
&nbsp;
  Libraries = <span style="color:#006600; font-weight:bold;">&#123;</span> 
    <span style="color:#996600;">&quot;jquery&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
      <span style="color:#ff3333; font-weight:bold;">:versions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#40;</span>1.2.3 1.2.6 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2<span style="color:#006600; font-weight:bold;">&#41;</span>,
      <span style="color:#ff3333; font-weight:bold;">:compressed_url</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/jquery/%s/jquery.min.js&quot;</span>,
      <span style="color:#ff3333; font-weight:bold;">:uncompressed_url</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/jquery/%s/jquery.js&quot;</span>
    <span style="color:#006600; font-weight:bold;">&#125;</span>,
    <span style="color:#996600;">&quot;jqueryui&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
      <span style="color:#ff3333; font-weight:bold;">:versions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#40;</span>1.5.2 1.5.3 <span style="color:#006666;">1.6</span> 1.7.0 1.7.1 1.7.2<span style="color:#006600; font-weight:bold;">&#41;</span>,
      <span style="color:#ff3333; font-weight:bold;">:compressed_url</span>   <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/jqueryui/%s/jquery-ui.min.js&quot;</span>,
      <span style="color:#ff3333; font-weight:bold;">:uncompressed_url</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/jqueryui/%s/jquery-ui.js&quot;</span>
    <span style="color:#006600; font-weight:bold;">&#125;</span>,
    <span style="color:#996600;">&quot;prototype&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
      <span style="color:#ff3333; font-weight:bold;">:versions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#40;</span>1.6.0.2 1.6.0.3 1.6.1.0<span style="color:#006600; font-weight:bold;">&#41;</span>,
      <span style="color:#ff3333; font-weight:bold;">:compressed_url</span>   <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;&quot;</span>,
      <span style="color:#ff3333; font-weight:bold;">:uncompressed_url</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/prototype/%s/prototype.js&quot;</span>
    <span style="color:#006600; font-weight:bold;">&#125;</span>,
    <span style="color:#996600;">&quot;scriptaculous&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
      <span style="color:#ff3333; font-weight:bold;">:versions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#40;</span>1.8.1 1.8.2 1.8.3<span style="color:#006600; font-weight:bold;">&#41;</span>,
      <span style="color:#ff3333; font-weight:bold;">:compressed_url</span>   <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;&quot;</span>,
      <span style="color:#ff3333; font-weight:bold;">:uncompressed_url</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/scriptaculous/%s/scriptaculous.js&quot;</span>
    <span style="color:#006600; font-weight:bold;">&#125;</span>,
    <span style="color:#996600;">&quot;mootools&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
      <span style="color:#ff3333; font-weight:bold;">:versions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#40;</span>1.1.1 1.1.2 1.2.1 1.2.2 1.2.3 1.2.4<span style="color:#006600; font-weight:bold;">&#41;</span>,
      <span style="color:#ff3333; font-weight:bold;">:compressed_url</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/mootools/%s/mootools-yui-compressed.js&quot;</span>,
      <span style="color:#ff3333; font-weight:bold;">:uncompressed_url</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/mootools/%s/mootools.js&quot;</span>
    <span style="color:#006600; font-weight:bold;">&#125;</span>,
    <span style="color:#996600;">&quot;dojo&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
      <span style="color:#ff3333; font-weight:bold;">:versions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#40;</span>1.1.1 1.2.0 1.2.3 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1<span style="color:#006600; font-weight:bold;">&#41;</span>,
      <span style="color:#ff3333; font-weight:bold;">:compressed_url</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/dojo/%s/dojo/dojo.xd.js&quot;</span>,
      <span style="color:#ff3333; font-weight:bold;">:uncompressed_url</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/dojo/%s/dojo/dojo.xd.js.uncompressed.js&quot;</span>
    <span style="color:#006600; font-weight:bold;">&#125;</span>,
    <span style="color:#996600;">&quot;swfobject&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
      <span style="color:#ff3333; font-weight:bold;">:versions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;">2.1</span> <span style="color:#006666;">2.2</span><span style="color:#006600; font-weight:bold;">&#41;</span>,
      <span style="color:#ff3333; font-weight:bold;">:compressed_url</span>   <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/swfobject/%s/swfobject.js&quot;</span>,
      <span style="color:#ff3333; font-weight:bold;">:uncompressed_url</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/swfobject/%s/swfobject_src.js&quot;</span>
    <span style="color:#006600; font-weight:bold;">&#125;</span>,
    <span style="color:#996600;">&quot;yui&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
      <span style="color:#ff3333; font-weight:bold;">:versions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#40;</span>2.6.0 2.7.0 2.8.0r4<span style="color:#006600; font-weight:bold;">&#41;</span>,
      <span style="color:#ff3333; font-weight:bold;">:compressed_url</span>   <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/yui/%s/build/yuiloader/yuiloader-min.js&quot;</span>,
      <span style="color:#ff3333; font-weight:bold;">:uncompressed_url</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/yui/%s/build/yuiloader/yuiloader.js&quot;</span>
    <span style="color:#006600; font-weight:bold;">&#125;</span>,
    <span style="color:#996600;">&quot;ext-core&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
      <span style="color:#ff3333; font-weight:bold;">:versions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#40;</span>3.0.0 3.1.0<span style="color:#006600; font-weight:bold;">&#41;</span>,
      <span style="color:#ff3333; font-weight:bold;">:compressed_url</span>   <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/ext-core/%s/ext-core.js&quot;</span>,
      <span style="color:#ff3333; font-weight:bold;">:uncompressed_url</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/ext-core/%s/ext-core-debug.js&quot;</span>
    <span style="color:#006600; font-weight:bold;">&#125;</span>,
    <span style="color:#996600;">&quot;chrome-frame&quot;</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>
      <span style="color:#ff3333; font-weight:bold;">:versions</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">%</span>w<span style="color:#006600; font-weight:bold;">&#40;</span>1.0.0 1.0.1 1.0.2<span style="color:#006600; font-weight:bold;">&#41;</span>,
      <span style="color:#ff3333; font-weight:bold;">:compressed_url</span>   <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/chrome-frame/%s/CFInstall.min.js&quot;</span>,
      <span style="color:#ff3333; font-weight:bold;">:uncompressed_url</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;/chrome-frame/%s/CFInstall.js&quot;</span>
    <span style="color:#006600; font-weight:bold;">&#125;</span> 
  <span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">freeze</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#0000FF; font-weight:bold;">self</span>
    <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#9966CC; font-weight:bold;">include</span><span style="color:#006600; font-weight:bold;">&#40;</span>name, version=<span style="color:#0000FF; font-weight:bold;">nil</span>, compressed=<span style="color:#0000FF; font-weight:bold;">true</span>, validate_version=<span style="color:#0000FF; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span>
      name = name.<span style="color:#9900CC;">to_s</span>
      <span style="color:#9966CC; font-weight:bold;">if</span> lib = <span style="color:#6666ff; font-weight:bold;">GoogleJsApi::Libraries</span><span style="color:#006600; font-weight:bold;">&#91;</span>name<span style="color:#006600; font-weight:bold;">&#93;</span>
        version <span style="color:#006600; font-weight:bold;">||</span>= lib<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:versions</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">last</span>
&nbsp;
        <span style="color:#9966CC; font-weight:bold;">if</span> validate_version <span style="color:#006600; font-weight:bold;">&amp;&amp;</span> lib<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:versions</span><span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9966CC; font-weight:bold;">include</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>version<span style="color:#006600; font-weight:bold;">&#41;</span>
          GoogleJsApi.<span style="color:#9900CC;">url_for</span><span style="color:#006600; font-weight:bold;">&#40;</span>name, version, compressed<span style="color:#006600; font-weight:bold;">&#41;</span>
        <span style="color:#9966CC; font-weight:bold;">elsif</span> !validate_version
          GoogleJsApi.<span style="color:#9900CC;">url_for</span><span style="color:#006600; font-weight:bold;">&#40;</span>name, version, compressed<span style="color:#006600; font-weight:bold;">&#41;</span>
        <span style="color:#9966CC; font-weight:bold;">else</span>
          <span style="color:#CC0066; font-weight:bold;">raise</span> <span style="color:#CC00FF; font-weight:bold;">Exception</span>, <span style="color:#996600;">&quot;Invalid version (#{version}) for #{name}&quot;</span>
        <span style="color:#9966CC; font-weight:bold;">end</span>
      <span style="color:#9966CC; font-weight:bold;">else</span>
        <span style="color:#CC0066; font-weight:bold;">raise</span> <span style="color:#CC00FF; font-weight:bold;">Exception</span>, <span style="color:#996600;">&quot;Unknown Google Javascript Library&quot;</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> version_info
      tmp_version = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span>
      <span style="color:#6666ff; font-weight:bold;">GoogleJsApi::Libraries</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>k,v<span style="color:#006600; font-weight:bold;">|</span>
        tmp_version<span style="color:#006600; font-weight:bold;">&#91;</span> k <span style="color:#006600; font-weight:bold;">&#93;</span> = v<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:versions</span><span style="color:#006600; font-weight:bold;">&#93;</span>
      <span style="color:#9966CC; font-weight:bold;">end</span>
      tmp_version
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    protected
    <span style="color:#9966CC; font-weight:bold;">def</span> url_for<span style="color:#006600; font-weight:bold;">&#40;</span>name, version, compressed<span style="color:#006600; font-weight:bold;">&#41;</span>
      <span style="color:#6666ff; font-weight:bold;">GoogleJsApi::BaseURL</span> <span style="color:#006600; font-weight:bold;">+</span>
      <span style="color:#6666ff; font-weight:bold;">GoogleJsApi::Libraries</span><span style="color:#006600; font-weight:bold;">&#91;</span> name <span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span> compressed ? <span style="color:#ff3333; font-weight:bold;">:compressed_url</span> : <span style="color:#ff3333; font-weight:bold;">:uncompressed_url</span> <span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">%</span> version
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>Here are some tests for it if you are interested in how/if it works:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'pp'</span>
&nbsp;
pp GoogleJsApi.<span style="color:#9900CC;">version_info</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Include the newest version of a library</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> GoogleJsApi.<span style="color:#9966CC; font-weight:bold;">include</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'jquery'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Include a specific version of a library</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> GoogleJsApi.<span style="color:#9966CC; font-weight:bold;">include</span> <span style="color:#996600;">&quot;chrome-frame&quot;</span>, <span style="color:#996600;">&quot;1.0.0&quot;</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Include a specific version of a library uncompressed</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> GoogleJsApi.<span style="color:#9966CC; font-weight:bold;">include</span> <span style="color:#996600;">&quot;chrome-frame&quot;</span>, <span style="color:#996600;">&quot;1.0.0&quot;</span>, <span style="color:#0000FF; font-weight:bold;">false</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># Include a specific version of a library w/o validating the version; useful if this goes out of date :P</span>
<span style="color:#CC0066; font-weight:bold;">puts</span> GoogleJsApi.<span style="color:#9966CC; font-weight:bold;">include</span> <span style="color:#996600;">&quot;jquery&quot;</span>, <span style="color:#996600;">&quot;NOT_A_VERSION&quot;</span>, <span style="color:#0000FF; font-weight:bold;">false</span>, <span style="color:#0000FF; font-weight:bold;">false</span>
&nbsp;
<span style="color:#9966CC; font-weight:bold;">begin</span>
  <span style="color:#CC0066; font-weight:bold;">puts</span> GoogleJsApi.<span style="color:#9966CC; font-weight:bold;">include</span> <span style="color:#ff3333; font-weight:bold;">:jqueryui</span>, <span style="color:#996600;">&quot;1.0&quot;</span>
<span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#CC00FF; font-weight:bold;">Exception</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> e
  <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">&quot;This should blow up...&quot;</span>
  <span style="color:#CC0066; font-weight:bold;">puts</span> e.<span style="color:#9900CC;">message</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></td></tr></table></div>

<p>If you want to use it in your Rails or Merb app you can do:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># Rails</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'google_js_api'</span> <span style="color:#008000; font-style:italic;">#or whatever you named the file when you dropped it in lib</span>
&nbsp;
<span style="color:#008000; font-style:italic;"># In your application layout or whatever</span>
javascript_include_tag GoogleJsApi.<span style="color:#9966CC; font-weight:bold;">include</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:jquery</span>, <span style="color:#996600;">&quot;1.4.0&quot;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>


<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;"># Merb</span>
<span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'google_js_api'</span> <span style="color:#008000; font-style:italic;">#or whatever you named the file when you dropped it in lib</span>
&nbsp;
<span style="color:#008000; font-style:italic;">#in your application layout or where ever</span>
require_js GoogleJsApi.<span style="color:#9966CC; font-weight:bold;">include</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:swfobject</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></td></tr></table></div>

<p>Its simple, its lazy. I like it.</p>
<p align="left"><a class="tt" href="http://twitter.com/home/?status=A+ruby+wrapper+for+Google+AjaxLibs+%28jquery%2C+jquery+ui%2C+mootools%2C+prototype%2C+swfobject%2C+etc%29+%5BLazy+GoogleJsApi+Wrapper%5D+http://coryodaniel.com/?p=489" title="Post to Twitter"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-twitter-big2.png" alt="Post to Twitter" /></a> <a class="tt" href="http://digg.com/submit?url=http://coryodaniel.com/index.php/2010/02/25/a-ruby-wrapper-for-google-ajaxlibs-jquery-jquery-ui-mootools-prototype-swfobject-etc/&amp;title=A+ruby+wrapper+for+Google+AjaxLibs+%28jquery%2C+jquery+ui%2C+mootools%2C+prototype%2C+swfobject%2C+etc%29+%5BLazy+GoogleJsApi+Wrapper%5D" title="Post to Digg"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-digg-big2.png" alt="Post to Digg" /></a> <a class="tt" href="http://www.facebook.com/share.php?u=http://coryodaniel.com/index.php/2010/02/25/a-ruby-wrapper-for-google-ajaxlibs-jquery-jquery-ui-mootools-prototype-swfobject-etc/&amp;t=A+ruby+wrapper+for+Google+AjaxLibs+%28jquery%2C+jquery+ui%2C+mootools%2C+prototype%2C+swfobject%2C+etc%29+%5BLazy+GoogleJsApi+Wrapper%5D" title="Post to Facebook"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-facebook-big2.png" alt="Post to Facebook" /></a> <a class="tt" href="http://reddit.com/submit?url=http://coryodaniel.com/index.php/2010/02/25/a-ruby-wrapper-for-google-ajaxlibs-jquery-jquery-ui-mootools-prototype-swfobject-etc/&amp;title=A+ruby+wrapper+for+Google+AjaxLibs+%28jquery%2C+jquery+ui%2C+mootools%2C+prototype%2C+swfobject%2C+etc%29+%5BLazy+GoogleJsApi+Wrapper%5D" title="Post to Reddit"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-reddit-big2.png" alt="Post to Reddit" /></a> <a class="tt" href="http://stumbleupon.com/submit?url=http://coryodaniel.com/index.php/2010/02/25/a-ruby-wrapper-for-google-ajaxlibs-jquery-jquery-ui-mootools-prototype-swfobject-etc/&amp;title=A+ruby+wrapper+for+Google+AjaxLibs+%28jquery%2C+jquery+ui%2C+mootools%2C+prototype%2C+swfobject%2C+etc%29+%5BLazy+GoogleJsApi+Wrapper%5D" title="Post to StumbleUpon"><img class="nothumb" src="http://coryodaniel.com/wp-content/plugins/tweet-this/icons/tt-su-big2.png" alt="Post to StumbleUpon" /></a></p>]]></content:encoded>
			<wfw:commentRss>http://coryodaniel.com/index.php/2010/02/25/a-ruby-wrapper-for-google-ajaxlibs-jquery-jquery-ui-mootools-prototype-swfobject-etc/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

