<?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>ideas.each &#38;:post &#187; gems</title>
	<atom:link href="http://blog.tobiascrawley.net/tag/gems/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.tobiascrawley.net</link>
	<description>Another not so cleverly named blog mostly about software.</description>
	<lastBuildDate>Fri, 28 May 2010 13:56:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>open_exception gem: now with better emacs support!</title>
		<link>http://blog.tobiascrawley.net/2010/05/28/open_exception-gem-now-with-better-emacs-support/</link>
		<comments>http://blog.tobiascrawley.net/2010/05/28/open_exception-gem-now-with-better-emacs-support/#comments</comments>
		<pubDate>Fri, 28 May 2010 13:56:51 +0000</pubDate>
		<dc:creator>Tobias</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.tobiascrawley.net/?p=325</guid>
		<description><![CDATA[I just released v0.3.1 of the open_exception gem. This release does a better job of handling exceptions that have been munged by Rails, and now provides a tempfile containing the full stack trace to the open command. If you are using emacs, you can use the :emacs_with_trace open command, and get the stack trace as [...]]]></description>
			<content:encoded><![CDATA[<p>I just released <a href="http://rubygems.org/gems/open_exception">v0.3.1</a> of the <a href="http://blog.tobiascrawley.net/2010/04/26/open_exception-gem-auto-open-exceptions-in-your-editor/">open_exception gem</a>. This release does a better job of handling exceptions that have been munged by Rails, and now provides a tempfile containing the full stack trace to the open command. </p>

<p>If you are using emacs, you can use the <code>:emacs_with_trace</code> open command, and get the stack trace as a navigable compilation buffer (next to || below) the source file in a split frame. For this to work, you&#8217;ll need to add the following function to your emacs init:</p>

<script src="http://gist.github.com/417151.js?file=gistfile1.el"></script>

<p>See github for the <a href="http://github.com/tobias/open_exception">code</a> and <a href="http://github.com/tobias/open_exception/blob/master/README.md"><span class="caps">README</span></a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.tobiascrawley.net/2010/05/28/open_exception-gem-now-with-better-emacs-support/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>open_exception gem: auto open exceptions in your editor</title>
		<link>http://blog.tobiascrawley.net/2010/04/26/open_exception-gem-auto-open-exceptions-in-your-editor/</link>
		<comments>http://blog.tobiascrawley.net/2010/04/26/open_exception-gem-auto-open-exceptions-in-your-editor/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 21:58:13 +0000</pubDate>
		<dc:creator>Tobias</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.tobiascrawley.net/?p=318</guid>
		<description><![CDATA[open_exception opens an exception in your favorite editor when developing locally. It works by parsing the backtrace, and opening the offending file at the offending line in your favorite editor (assuming your favorite editor supports remote open commands). You can add filters that allow you to ignore some exceptions, and filters that allow you to [...]]]></description>
			<content:encoded><![CDATA[<p>open_exception opens an exception in your favorite editor when developing locally. It works by parsing the backtrace, and opening the offending file at the offending line in your favorite editor (assuming your favorite editor supports remote open commands).</p>

<p>You can add filters that allow you to ignore some exceptions, and filters that allow you to scope the backtrace search. The backtrace scoping is useful for opening the last call in your application code when the exception occurs in a framework or lib.</p>

<p>If you are on MacOSX and have the <a href="http://rubygems.org/gems/growl">growl gem</a> installed, you will get a growl notification with the exception message when the file is opened.</p>

<h3>Editors</h3>

<p>Out if the box, the gem supports three editors (with the following open commands):</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">    <span style="color:#ff3333; font-weight:bold;">:emacs</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'/usr/bin/emacsclient -n +{line} {file}'</span>,
    <span style="color:#ff3333; font-weight:bold;">:textmate</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'/usr/local/bin/mate -a -d -l {line} {file}'</span>,
    <span style="color:#ff3333; font-weight:bold;">:macvim</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'/usr/local/bin/mvim +{line} {file}'</span></pre></div></div>




<p>Note: if using emacs, you will need to be running <code>emacsserver</code>. To start the server: <code>M-x server-start</code><br />
or add <code>(server-start)</code> to your init.</p>

<h3>Configuration</h3>

<p>To configure, pass a block to the configure method:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">    OpenException.<span style="color:#9900CC;">configure</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>oe<span style="color:#006600; font-weight:bold;">|</span>
      <span style="color:#008000; font-style:italic;"># open_with can be one of the built in editors (:emacs, :macvim, :textmate)</span>
      <span style="color:#008000; font-style:italic;"># or a command to execute to open the file, where {file} and {line} will be replaced</span>
      <span style="color:#008000; font-style:italic;"># with the file path and line number, respectively. See 'Editors' above for an example.</span>
      <span style="color:#008000; font-style:italic;"># The default editor is :emacs.</span>
&nbsp;
      oe.<span style="color:#9900CC;">open_with</span> = <span style="color:#ff3333; font-weight:bold;">:emacs</span>
&nbsp;
      <span style="color:#008000; font-style:italic;"># you can add exclusion filters to ignore exceptions. A filter can be an exception class to </span>
      <span style="color:#008000; font-style:italic;"># ignore, or a proc that is passed the exception, and should evaluate to true if the exception </span>
      <span style="color:#008000; font-style:italic;"># should be ignored. Be careful with using a class - it uses is_a?, so any subclasses of the</span>
      <span style="color:#008000; font-style:italic;"># passed class will be ignored as well. The list of filters is [] by default.</span>
&nbsp;
      oe.<span style="color:#9900CC;">exclusion_filters</span> <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> SomeErrorClass
      oe.<span style="color:#9900CC;">exclusion_filters</span> <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#CC0066; font-weight:bold;">lambda</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>exception<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#0000FF; font-weight:bold;">true</span> <span style="color:#9966CC; font-weight:bold;">if</span> exception_should_be_excluded <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
      <span style="color:#008000; font-style:italic;"># you can scope the search for the file:line to open with a filter as well. A filter can be a </span>
      <span style="color:#008000; font-style:italic;"># regular expression that is matched against the line, or a proc that is passed the line and </span>
      <span style="color:#008000; font-style:italic;"># should evaluate to true if the line should be used. The first line that any filter passes for </span>
      <span style="color:#008000; font-style:italic;"># will be the file:line that is opened. This is useful for opening the point in the stack just</span>
      <span style="color:#008000; font-style:italic;"># before control passes out of your app code when the exception occurs in an external </span>
      <span style="color:#008000; font-style:italic;"># lib/framework. The list of filters is [] by default. </span>
&nbsp;
      oe.<span style="color:#9900CC;">backtrace_line_filters</span> <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#006600; font-weight:bold;">%</span>r<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">/</span>app<span style="color:#006600; font-weight:bold;">/</span>root<span style="color:#006600; font-weight:bold;">/</span><span style="color:#006600; font-weight:bold;">&#40;</span>app<span style="color:#006600; font-weight:bold;">|</span>lib<span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#125;</span> 
      oe.<span style="color:#9900CC;">backtrace_line_filters</span> <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> <span style="color:#CC0066; font-weight:bold;">lambda</span> <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#006600; font-weight:bold;">|</span>backtrace_line<span style="color:#006600; font-weight:bold;">|</span> <span style="color:#0000FF; font-weight:bold;">true</span> <span style="color:#9966CC; font-weight:bold;">if</span> line_should_be_used <span style="color:#006600; font-weight:bold;">&#125;</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>




<h3>Rails Integration</h3>

<p>The gem also alias chains in to rails&#8217; <code>ActionController#rescue_action_locally</code> method to automatically open exceptions in development mode. The gem also adds the following filter to the <code>:backtrace_line_filters</code> to scope the opened files to the app:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">    @<span style="color:#006600; font-weight:bold;">%</span>r<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#008000; font-style:italic;">#{Rails.root}/(app|lib)}@</span></pre></div></div>




<p>To replace or remove this filter, you will need to reset the <code>:backtrace_line_filters</code> in your configure block:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">    OpenException.<span style="color:#9900CC;">configure</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#006600; font-weight:bold;">|</span>oe<span style="color:#006600; font-weight:bold;">|</span>
      oe.<span style="color:#9900CC;">backtrace_line_filters</span> = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span>
      oe.<span style="color:#9900CC;">backtrace_line_filters</span> <span style="color:#006600; font-weight:bold;">&lt;&lt;</span> my_new_filter
    <span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>




<p>This has been tested with rails v2.3.5, but should work fine with 2.1 &lt;= rails &lt; 3. It may work with rails 3 as well, I just haven&#8217;t yet looked at rails 3.</p>

<h3>Standalone/Other Frameworks</h3>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">    <span style="color:#008000; font-style:italic;"># To manually open an exception, or wire it up in another framework, you call:</span>
    OpenException.<span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span>exception<span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
    <span style="color:#008000; font-style:italic;"># You can override the default (or configured) options by passing a hash as the second arg:</span>
    OpenException.<span style="color:#CC0066; font-weight:bold;">open</span><span style="color:#006600; font-weight:bold;">&#40;</span>exception, <span style="color:#006600; font-weight:bold;">&#123;</span>:open_with <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:textmate</span>, <span style="color:#ff3333; font-weight:bold;">:backtrace_line_filters</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006600; font-weight:bold;">&#91;</span>filter, another_filter<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>




<p>The source is on <a href="http://github.com/tobias/open_exception">github</a>, and the gem is on <a href="http://rubygems.org/gems/open_exception">rubygems</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.tobiascrawley.net/2010/04/26/open_exception-gem-auto-open-exceptions-in-your-editor/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Refreshing an individual gemspec</title>
		<link>http://blog.tobiascrawley.net/2009/12/08/refreshing-an-individual-gemspec/</link>
		<comments>http://blog.tobiascrawley.net/2009/12/08/refreshing-an-individual-gemspec/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 22:34:48 +0000</pubDate>
		<dc:creator>Tobias</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[why am I not using bundler?]]></category>

		<guid isPermaLink="false">http://blog.tobiascrawley.net/?p=288</guid>
		<description><![CDATA[I&#8217;m in the process of upgrading a rails app from 2.1 to 2.3, and 2.3 wants me to refresh some of the gemspecs for my vendored gems. Unfortunately, when I run rake gems:refresh_specs I get the dreaded: rake aborted! can't activate , already activated json-1.1.9 I was able to refresh the spec in question outside [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m in the process of upgrading a rails app from 2.1 to 2.3, and 2.3 wants me to refresh some of the gemspecs for my vendored gems. Unfortunately, when I run <code>rake gems:refresh_specs</code> I get the dreaded:</p>



<pre>
rake aborted!
can't activate , already activated json-1.1.9
</pre>



<p>I was able to refresh the spec in question outside of rake with (in the console):</p>



<pre>
&gt;&gt; Rails::GemDependency.from_directory_name('vendor/gems/gem_name-0.1.0', false).refresh
</pre>



<p>Hopefully that helps someone else out.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.tobiascrawley.net/2009/12/08/refreshing-an-individual-gemspec/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>zendesk_remote_auth gem makes Zendesk SSO easy!</title>
		<link>http://blog.tobiascrawley.net/2009/09/19/zendesk_remote_auth-gem-makes-zendesk-sso-easy/</link>
		<comments>http://blog.tobiascrawley.net/2009/09/19/zendesk_remote_auth-gem-makes-zendesk-sso-easy/#comments</comments>
		<pubDate>Sat, 19 Sep 2009 04:25:58 +0000</pubDate>
		<dc:creator>Tobias</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[zendesk]]></category>

		<guid isPermaLink="false">http://blog.tobiascrawley.net/?p=217</guid>
		<description><![CDATA[I extracted how we are doing Zendesk remote authentication from an app at Dealer Ignition, and stuck it in a small gem for your enjoyment. You can find it on GitHub. Installation and Setup Install: gem install tobias-zendesk_remote_auth Setup: You will need to give the gem your token and authentication url, perhaps in an initializer: [...]]]></description>
			<content:encoded><![CDATA[<p>I extracted how we are doing <a href="http://www.zendesk.com/api/remote_authentication">Zendesk remote authentication</a> from an app at <a href="http://dealerignition.com">Dealer Ignition</a>, and stuck it in a small gem for your enjoyment. You can find it on <a href="http://github.com/tobias/zendesk_remote_auth">GitHub</a>.</p>

<h3>Installation and Setup</h3>

<p>Install:</p>


<pre>gem install tobias-zendesk_remote_auth</pre>


<p>Setup:</p>

<p>You will need to give the gem your token and authentication url, perhaps in an initializer:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">  <span style="color:#6666ff; font-weight:bold;">Zendesk::RemoteAuth</span>.<span style="color:#9900CC;">token</span> = <span style="color:#996600;">'YOUR-TOKEN'</span>
  <span style="color:#6666ff; font-weight:bold;">Zendesk::RemoteAuth</span>.<span style="color:#9900CC;">auth_url</span> = <span style="color:#996600;">'https://yourcompany.zendesk.com/access/remote/'</span></pre></div></div>




<p>and config the gem in environment.rb (if using rails):</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">config.<span style="color:#9900CC;">gem</span> <span style="color:#996600;">'tobias-zendesk_remote_auth'</span>, <span style="color:#ff3333; font-weight:bold;">:lib</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'zendesk_remote_auth'</span>, <span style="color:#ff3333; font-weight:bold;">:source</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> http:<span style="color:#006600; font-weight:bold;">//</span>gems.<span style="color:#9900CC;">github</span>.<span style="color:#9900CC;">com</span><span style="color:#996600;">'</span></pre></div></div>




<h3>Usage</h3>

<p>Mixin the Zendesk::RemoteAuthHelper module wherever needed, then call:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">  zendesk_remote_auth_url<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#ff3333; font-weight:bold;">:name</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'user name'</span>,
                          <span style="color:#ff3333; font-weight:bold;">:email</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">'user email'</span>,
                          <span style="color:#006600; font-weight:bold;">&lt;</span>optional params<span style="color:#006600; font-weight:bold;">&gt;</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>




<p>This will return a url you can redirect the user to to log them in to your zendesk account. </p>

<p>As a convenience, you can pass a user object to zendesk_remote_auth_url:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">  zendesk_remote_auth_url<span style="color:#006600; font-weight:bold;">&#40;</span>user<span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>




<p>This user must <code>respond_to?</code> <code>:name</code> and <code>:email</code>, and its <code>:id</code> will be used as the <code>:external_id</code> (making it useless with user objects that return an ephemeral object_id, but works well with ActiveRecord and the like). If the user object responds to <code>:zendesk_organization</code>, that will be used as the <code> <img src='http://blog.tobiascrawley.net/wp-includes/images/smilies/icon_surprised.gif' alt=':o' class='wp-smiley' /> rganization</code> for the call.</p>

<p>This method will generate and include the hash of the parameters for you if necessary. </p>

<h3>Example Auth Controller</h3>

<p>Here is an example controller that handles login and logout for zendesk:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">  <span style="color:#008000; font-style:italic;"># Uses restful-authentication style auth. </span>
  <span style="color:#008000; font-style:italic;"># </span>
  <span style="color:#008000; font-style:italic;"># Define the following in routes.rb:</span>
  <span style="color:#008000; font-style:italic;"># map.with_options :controller =&gt; 'zendesk_auth' do |zd|</span>
  <span style="color:#008000; font-style:italic;">#   zd.connect '/zendesk/authorize', :action =&gt; 'authorize'</span>
  <span style="color:#008000; font-style:italic;">#   zd.connect '/zendesk/logout', :action =&gt; 'logout'</span>
  <span style="color:#008000; font-style:italic;"># end</span>
  <span style="color:#9966CC; font-weight:bold;">class</span> ZendeskAuthController <span style="color:#006600; font-weight:bold;">&lt;</span> ApplicationController
    <span style="color:#9966CC; font-weight:bold;">include</span> <span style="color:#6666ff; font-weight:bold;">Zendesk::RemoteAuthHelper</span>
&nbsp;
    skip_before_filter <span style="color:#ff3333; font-weight:bold;">:login_required</span>, <span style="color:#ff3333; font-weight:bold;">:only</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:logout</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> authorize
      redirect_to zendesk_remote_auth_url<span style="color:#006600; font-weight:bold;">&#40;</span>current_user<span style="color:#006600; font-weight:bold;">&#41;</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    <span style="color:#9966CC; font-weight:bold;">def</span> logout
      redirect_to logout_url
    <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
    protected
    <span style="color:#9966CC; font-weight:bold;">def</span> login_required
      <span style="color:#9966CC; font-weight:bold;">if</span> !logged_in?
        flash<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:notice</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">'You must log in to access the support site.'</span>
        store_location
        redirect_to login_path
      <span style="color:#9966CC; font-weight:bold;">end</span>
    <span style="color:#9966CC; font-weight:bold;">end</span>
  <span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.tobiascrawley.net/2009/09/19/zendesk_remote_auth-gem-makes-zendesk-sso-easy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>server_remote gem</title>
		<link>http://blog.tobiascrawley.net/2009/03/31/server_remote-gem/</link>
		<comments>http://blog.tobiascrawley.net/2009/03/31/server_remote-gem/#comments</comments>
		<pubDate>Tue, 31 Mar 2009 18:47:47 +0000</pubDate>
		<dc:creator>Tobias</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[deployment]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[simplecli]]></category>

		<guid isPermaLink="false">http://blog.tobiascrawley.net/?p=187</guid>
		<description><![CDATA[I just re-released my server_remote plugin as a gem server_remote on github. I converted it to a gem to make it easier to use in multiple apps, and to make it easier to update (see here for the blog entry on the (now obselete) plugin). It is a gem that provides support for running commands [...]]]></description>
			<content:encoded><![CDATA[<p>I just re-released my server_remote plugin as a gem <a href="http://github.com/tobias/server_remote">server_remote</a> on github. I converted it to a gem to make it easier to use in multiple apps, and to make it easier to update (see <a href="http://blog.tobiascrawley.net/2009/01/10/server_remote-a-rails-plugin-for-easily-accessing-servers/">here</a> for the blog entry on the (now obselete) plugin). </p>

It is a gem that provides support for running commands on remote server. Once set up, it provides commands via <code>script/remote</code>:<br />
<ul>
  <li><code>remote shell</code> &#8211; same as ssh&#8217;ing to the server (this is the default command, so it can be called with just <code>remote</code>)</li>
  <li><code>remote console</code> &#8211; executes a <code>script/console</code> on the server</li>
  <li><code>remote logtail</code> &#8211; executes <code>tail -f log/&lt;environment&gt;.log</code> on the server</li>
  <li><code>remote cmd &lt;some command&gt;</code> executes command on the server, displaying the result. It <code>cd</code>&#8216;s to the remote app root first.</li>
  <li><code>remote scp &lt;local_file&gt; :&lt;remote_file&gt;</code> provides scp. Prefix remote files with &#8216;:&#8217;</li></ul>Configuration is in <code>config/server_remote.yml</code>, and is grouped into <em>profiles</em>. 

<p>Here is the output of <code>remote usage</code>:</p>


<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">Executes commands on a remote server over ssh. Configuration is in:
/Users/tobias/customers/DealerIgnition/dealer_ignition/script/../config/server_remote.yml
&nbsp;
You can override the profile used with -p profile. The default profile is: app
&nbsp;
Learn more in the readme:
/opt/local/lib/ruby/gems/1.8/gems/tobias-server_remote-0.2.0/lib/server_remote/../../README.textile
&nbsp;
remote commands are:
&nbsp;
    DEFAULT COMMAND   shell
&nbsp;
    cmd               executes an arbitrary command on the server after a cd to the app path
    commands          List all 'remote' commands
    console           executes remote console
    help              Provide help documentation for a command
    logtail           executes remote tail -f on the log
    scp               copies files over scp (prefix remote files with ':')
    shell             executes remote shell
    usage             prints usage message
&nbsp;
For help on a particular command, use 'remote help COMMAND'.</pre></div></div>




<p>It uses <a href="http://remi.org">remi&#8217;s</a> <a href="http://github.com/remi/simplecli">simplecli</a> gem. </p>

<p>I plan to add other commands as needed, or you can open up <code>Remote::Commands</code> and add your own. </p>

<h3>Installation</h3>

<p>You will need to install the gem (only once), then setup any apps where you want to use it.</p>



<pre>
  sudo gem install tobias-server_remote --source http://gems.github.com/
  server_remotify path_to_app
</pre>]]></content:encoded>
			<wfw:commentRss>http://blog.tobiascrawley.net/2009/03/31/server_remote-gem/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>credit_card_validator gem</title>
		<link>http://blog.tobiascrawley.net/2009/03/19/credit_card_validator-gem/</link>
		<comments>http://blog.tobiascrawley.net/2009/03/19/credit_card_validator-gem/#comments</comments>
		<pubDate>Fri, 20 Mar 2009 01:21:32 +0000</pubDate>
		<dc:creator>Tobias</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.tobiascrawley.net/?p=169</guid>
		<description><![CDATA[I recently published a gem that provides credit card validation. It is basically a ruby port of the javascript credit card validator by Thomas Fuchs (madrobby). Usage: CreditCardValidator::Validator.valid?&#40;'1111 2222 3333 4444'&#41; &#160; # allow test numbers to be valid (for development) CreditCardValidator::Validator.options&#91;:test_numbers_are_valid&#93; = true CreditCardValidator::Validator.valid?&#40;'1111 2222 3333 4444'&#41; &#160; # limit the card types you [...]]]></description>
			<content:encoded><![CDATA[<p>I recently published a gem that provides credit card validation. It is basically a ruby port of the <a href="http://github.com/madrobby/creditcard_js">javascript credit card validator</a> by <a href="http://mir.aculo.us/">Thomas Fuchs</a> (<a href="http://github.com/madrobby">madrobby</a>).</p>

<p>Usage:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">  <span style="color:#6666ff; font-weight:bold;">CreditCardValidator::Validator</span>.<span style="color:#9900CC;">valid</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'1111 2222 3333 4444'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># allow test numbers to be valid (for development) </span>
  <span style="color:#6666ff; font-weight:bold;">CreditCardValidator::Validator</span>.<span style="color:#9900CC;">options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:test_numbers_are_valid</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#0000FF; font-weight:bold;">true</span>
  <span style="color:#6666ff; font-weight:bold;">CreditCardValidator::Validator</span>.<span style="color:#9900CC;">valid</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'1111 2222 3333 4444'</span><span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># limit the card types you allow</span>
  <span style="color:#6666ff; font-weight:bold;">CreditCardValidator::Validator</span>.<span style="color:#9900CC;">options</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:allowed_card_types</span><span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#ff3333; font-weight:bold;">:visa</span>, <span style="color:#ff3333; font-weight:bold;">:mastercard</span><span style="color:#006600; font-weight:bold;">&#93;</span>
  <span style="color:#6666ff; font-weight:bold;">CreditCardValidator::Validator</span>.<span style="color:#9900CC;">valid</span>?<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">'1111 2222 3333 4444'</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>




<p>Supported card types:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">  <span style="color:#ff3333; font-weight:bold;">:amex</span>, <span style="color:#ff3333; font-weight:bold;">:discover</span>, <span style="color:#ff3333; font-weight:bold;">:diners_club</span>, <span style="color:#ff3333; font-weight:bold;">:master_card</span>, <span style="color:#ff3333; font-weight:bold;">:visa</span></pre></div></div>




<p>Whitespace is stripped from the number automatically.</p>

<p>The following things are tested:</p>

<p>1. does the luhn validation code add up? (see <a href="http://en.wikipedia.org/wiki/Luhn_algorithm">http://en.wikipedia.org/wiki/Luhn_algorithm</a>)<br />
2. does the number range and length seem right? (see <a href="http://en.wikipedia.org/wiki/Bank_card_number">http://en.wikipedia.org/wiki/Bank_card_number</a>)<br />
3. is it one of several well-known test numbers?</p>

<p>Note: this only validates that the number is of a valid format, it does not check if it is an actual credit card number. You will need to talk to your payment gateway to learn that.</p>

<p>You can also use the validator to learn about the type of the card:</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">  <span style="color:#008000; font-style:italic;"># gives the type back as a string (visa, master_card, etc)</span>
  <span style="color:#6666ff; font-weight:bold;">CreditCardValidator::Validator</span>.<span style="color:#9900CC;">card_type</span><span style="color:#006600; font-weight:bold;">&#40;</span>number<span style="color:#006600; font-weight:bold;">&#41;</span>
&nbsp;
  <span style="color:#6666ff; font-weight:bold;">CreditCardValidator::Validator</span>.<span style="color:#9900CC;">is_visa</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>number<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#6666ff; font-weight:bold;">CreditCardValidator::Validator</span>.<span style="color:#9900CC;">is_master_card</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>number<span style="color:#006600; font-weight:bold;">&#41;</span>
  <span style="color:#008000; font-style:italic;"># etc. - works for all of the supported card types</span>
&nbsp;
  <span style="color:#6666ff; font-weight:bold;">CreditCardValidator::Validator</span>.<span style="color:#9900CC;">is_allowed_card_type</span>?<span style="color:#006600; font-weight:bold;">&#40;</span>number<span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>




<p>To Install:</p>



<pre>
  gem install tobias-credit_card_validator --source http://gems.github.com
</pre>




<p>The source is available on <a href="http://github.com/tobias/credit_card_validator">github</a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.tobiascrawley.net/2009/03/19/credit_card_validator-gem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>script_finder gem</title>
		<link>http://blog.tobiascrawley.net/2009/03/13/script_finder-gem/</link>
		<comments>http://blog.tobiascrawley.net/2009/03/13/script_finder-gem/#comments</comments>
		<pubDate>Fri, 13 Mar 2009 17:17:39 +0000</pubDate>
		<dc:creator>Tobias</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.tobiascrawley.net/?p=163</guid>
		<description><![CDATA[I recently published a ruby gem on github that simplifies running scripts from a script/ dir from anywhere in your project (rails or otherwise). script_finder provides a script (called s@) in your path that searches in and up from the current dir for a folder (default: @script/) containing an executable file uniquely identified by the [...]]]></description>
			<content:encoded><![CDATA[<p>I recently published a ruby gem on <a href="http://github.com/tobias/script_finder">github</a> that simplifies running scripts from a <code>script/</code> dir from anywhere in your project (rails or otherwise). </p>

<p>script_finder provides a script (called <code>s@) in your path that searches in and up from the current dir for a folder (default: @script/</code>) containing an executable file uniquely identified by the a prefix given as the first argument. It then calls that executable, passing the rest of the arguments to the called executable. If the given prefix is ambiguous, the script suggests unique prefixes.</p>

<p>Examples (in a rails app):</p>


<pre>
  ~/rails_app/app/views$ s c
  --&gt; calling '/Users/tobias/rails_app/script/console'
  Loading development environment (Rails 2.1.0)
  RowsLogger plugin enables mysql
  &gt;&gt; exit
  ~/rails_app/app/views$ s r 'some ruby'
  's r' was too ambiguous. Try:
    's ru' for 'script/runner'
    's re' for 'script/remote'
  ~/rails_app/app/views$ s ru 'some ruby'
  --&gt; calling '/Users/tobias/rails_app/script/runner some ruby'
  ...
</pre>



<p>The gem is not rails specific &#8211; out of the box it will work with any project that has a <code>script/</code> directory. If you want to make your own version of the <code>s@ script that looks for executables in a different dir (I would save this one as @c</code>):</p>


<div class="wp_syntax"><div class="code"><pre class="ruby" style="font-family:monospace;">  <span style="color:#008000; font-style:italic;">#!/usr/bin/env ruby</span>
&nbsp;
  <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'script_finder'</span>
&nbsp;
  <span style="color:#008000; font-style:italic;"># looks for executables in a commands/ dir instead of script/.</span>
  ScriptFinder.<span style="color:#9900CC;">find_and_execute</span><span style="color:#006600; font-weight:bold;">&#40;</span>ARGV, <span style="color:#996600;">'commands'</span><span style="color:#006600; font-weight:bold;">&#41;</span></pre></div></div>




<p>Let me know if you have any problems/questions.</p>]]></content:encoded>
			<wfw:commentRss>http://blog.tobiascrawley.net/2009/03/13/script_finder-gem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
