<?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>Notes on ScopePort &#187; ruby</title>
	<atom:link href="http://blog.scopeport.org/tag/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.scopeport.org</link>
	<description>The ScopePort Blog</description>
	<lastBuildDate>Sun, 07 Feb 2010 01:08:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to use Rails SMTP configuration parameters from database</title>
		<link>http://blog.scopeport.org/ruby-on-rails/rails-smtp-configuration-parameters-database/</link>
		<comments>http://blog.scopeport.org/ruby-on-rails/rails-smtp-configuration-parameters-database/#comments</comments>
		<pubDate>Sun, 26 Jul 2009 01:08:34 +0000</pubDate>
		<dc:creator>Lennart</dc:creator>
				<category><![CDATA[Ruby On Rails]]></category>
		<category><![CDATA[actionmailer]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[settings]]></category>
		<category><![CDATA[smtp]]></category>

		<guid isPermaLink="false">http://blog.scopeport.org/?p=270</guid>
		<description><![CDATA[Usually the Rails SMTP configuration takes place in config/environment.rb like this:

ActionMailer::Base.smtp_settings = &#123;
  :address =&#62; &#34;smtp.gmail.com&#34;,
  :port =&#62; 587,
  :domain =&#62; &#34;domain.com&#34;,
  :user_name =&#62; &#34;user@domain.com&#34;,
  :password =&#62; &#34;password&#34;,
  :authentication =&#62; :plain
&#125;

ScopePort already has a Email settings part in the setup section where all the required SMTP settings are stored. [...]]]></description>
			<content:encoded><![CDATA[<p>Usually the Rails SMTP configuration takes place in <em>config/environment.rb</em> like this:</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#6666ff; font-weight:bold;">ActionMailer::Base</span>.<span style="color:#9900CC;">smtp_settings</span> = <span style="color:#006600; font-weight:bold;">&#123;</span>
  <span style="color:#ff3333; font-weight:bold;">:address</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;smtp.gmail.com&quot;</span>,
  <span style="color:#ff3333; font-weight:bold;">:port</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#006666;">587</span>,
  <span style="color:#ff3333; font-weight:bold;">:domain</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;domain.com&quot;</span>,
  <span style="color:#ff3333; font-weight:bold;">:user_name</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;user@domain.com&quot;</span>,
  <span style="color:#ff3333; font-weight:bold;">:password</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#996600;">&quot;password&quot;</span>,
  <span style="color:#ff3333; font-weight:bold;">:authentication</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:plain</span>
<span style="color:#006600; font-weight:bold;">&#125;</span></pre></div></div>

<p>ScopePort already has a <em>Email settings</em> part in the setup section where all the required SMTP settings are stored. I wanted to fetch the SMTP configuration from the database to avoid double configuration. I stumbled over this blog post after a while: <a href="http://broadcast.oreilly.com/2009/03/using-multiple-smtp-accounts-w.html" target="_blank">http://broadcast.oreilly.com/2009/03/using-multiple-smtp-accounts-w.html</a> Based on this I developed the following dynamic way to define the SMTP settings:</p>

<div class="wp_syntax"><div class="code"><pre class="rails" style="font-family:monospace;"><span style="color:#9966CC; font-weight:bold;">class</span> EmergencyMailer <span style="color:#006600; font-weight:bold;">&lt;</span> <span style="color:#6666ff; font-weight:bold;">ActionMailer::Base</span>   
  <span style="color:#9966CC; font-weight:bold;">def</span> load_settings
    @@smtp_settings = <span style="color:#006600; font-weight:bold;">&#123;</span>
      <span style="color:#ff3333; font-weight:bold;">:address</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> Setting.<span style="color:#5A0A0A; font-weight:bold;">first</span>.<span style="color:#9900CC;">mail_server</span>,
      <span style="color:#ff3333; font-weight:bold;">:port</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> Setting.<span style="color:#5A0A0A; font-weight:bold;">first</span>.<span style="color:#9900CC;">mail_port</span>,
      <span style="color:#ff3333; font-weight:bold;">:domain</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> Setting.<span style="color:#5A0A0A; font-weight:bold;">first</span>.<span style="color:#9900CC;">mail_hostname</span>,
      <span style="color:#ff3333; font-weight:bold;">:authentication</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> <span style="color:#ff3333; font-weight:bold;">:plain</span>,
      <span style="color:#ff3333; font-weight:bold;">:user_name</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> Setting.<span style="color:#5A0A0A; font-weight:bold;">first</span>.<span style="color:#9900CC;">mail_user</span>,
      <span style="color:#ff3333; font-weight:bold;">:password</span> <span style="color:#006600; font-weight:bold;">=&gt;</span>Setting.<span style="color:#5A0A0A; font-weight:bold;">first</span>.<span style="color:#9900CC;">mail_pass</span>
    <span style="color:#006600; font-weight:bold;">&#125;</span>
  <span style="color:#9966CC; font-weight:bold;">end</span>
&nbsp;
  <span style="color:#9966CC; font-weight:bold;">def</span> emergency_notification<span style="color:#006600; font-weight:bold;">&#40;</span>emergency, email<span style="color:#006600; font-weight:bold;">&#41;</span>
    load_settings
    recipients  email
    from        Setting.<span style="color:#5A0A0A; font-weight:bold;">first</span>.<span style="color:#9900CC;">mail_from</span>
    subject     <span style="color:#996600;">&quot;[ScopePort] An emergency has been declared!&quot;</span>
    sent_on     <span style="color:#CC00FF; font-weight:bold;">Time</span>.<span style="color:#9900CC;">now</span>
    body        <span style="color:#ff3333; font-weight:bold;">:emergency</span> <span style="color:#006600; font-weight:bold;">=&gt;</span> emergency
  <span style="color:#9966CC; font-weight:bold;">end</span>
<span style="color:#9966CC; font-weight:bold;">end</span></pre></div></div>

<p>The method <em>load_settings</em> gets called by the delivery method and fills the <em>smtp_settings</em> instance variable with parameters from the database.</p>
<p>Check out this Rails Guide if you want to learn more about ActionMailer: <a href="http://guides.rubyonrails.org/action_mailer_basics.html" target="_blank">http://guides.rubyonrails.org/action_mailer_basics.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.scopeport.org/ruby-on-rails/rails-smtp-configuration-parameters-database/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ScopePort client now available via Rubygems</title>
		<link>http://blog.scopeport.org/scopeport/scopeport-client-rubygems/</link>
		<comments>http://blog.scopeport.org/scopeport/scopeport-client-rubygems/#comments</comments>
		<pubDate>Mon, 15 Jun 2009 13:34:05 +0000</pubDate>
		<dc:creator>Lennart</dc:creator>
				<category><![CDATA[ScopePort]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[install]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[scopeport-client]]></category>

		<guid isPermaLink="false">http://blog.scopeport.org/?p=196</guid>
		<description><![CDATA[You can now install the latest version of the ScopePort client via Rubygems. The gem is hosted at GitHub so you have to add GitHub as a repository first:
root@sundaysister# gem sources -a http://gems.github.com
You can now install the ScopePort client:
root@sundaysister# gem install lennartkoopmann-scopeport-client-ruby
Just start the client with &#8220;scopeport-client&#8221; if the gem binaries are in your $PATH.
Note [...]]]></description>
			<content:encoded><![CDATA[<p>You can now install the latest version of the ScopePort client via Rubygems. The gem is hosted at GitHub so you have to add GitHub as a repository first:</p>
<pre>root@sundaysister# gem sources -a http://gems.github.com</pre>
<p>You can now install the ScopePort client:</p>
<pre>root@sundaysister# gem install lennartkoopmann-scopeport-client-ruby</pre>
<p>Just start the client with &#8220;scopeport-client&#8221; if the gem binaries are in your $PATH.</p>
<p>Note that the current client version can only connect to a ScopePort server. It does not send real sensor data yet.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.scopeport.org/scopeport/scopeport-client-rubygems/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ScopePort sample client written in Ruby</title>
		<link>http://blog.scopeport.org/scopeport/scopeport-sample-client-written-ruby/</link>
		<comments>http://blog.scopeport.org/scopeport/scopeport-sample-client-written-ruby/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 21:50:15 +0000</pubDate>
		<dc:creator>Lennart</dc:creator>
				<category><![CDATA[ScopePort]]></category>
		<category><![CDATA[client]]></category>
		<category><![CDATA[protocol]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[sample]]></category>

		<guid isPermaLink="false">http://blog.scopeport.org/?p=191</guid>
		<description><![CDATA[I just pushed a first ScopePort sample client to our repositories. It is written in Ruby, connects to a ScopePort server, logs in and sends a sample sensor data package.
See the source code here: http://github.com/lennartkoopmann/scopeport-client-ruby/blob/665e4d69a93c73fd8055511aae55e88afcfb42c2/scopeport-client.rb
The ScopePort protocol for logging in and sending sensor data is described here: http://scopeport.org/docs/host_communications
Hey, by the way: ScopePort is now on [...]]]></description>
			<content:encoded><![CDATA[<p>I just pushed a first ScopePort sample client to our repositories. It is written in Ruby, connects to a ScopePort server, logs in and sends a sample sensor data package.</p>
<p>See the source code here: <a href="http://github.com/lennartkoopmann/scopeport-client-ruby/blob/665e4d69a93c73fd8055511aae55e88afcfb42c2/scopeport-client.rb" target="_blank">http://github.com/lennartkoopmann/scopeport-client-ruby/blob/665e4d69a93c73fd8055511aae55e88afcfb42c2/scopeport-client.rb</a></p>
<p>The ScopePort protocol for logging in and sending sensor data is described here: <a href="http://scopeport.org/docs/host_communications" target="_blank">http://scopeport.org/docs/host_communications</a></p>
<p>Hey, by the way: <a href="http://www.twitter.com/ScopePort" target="_blank">ScopePort is now on Twitter</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.scopeport.org/scopeport/scopeport-sample-client-written-ruby/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>extconf.rb:1:in `require&#8217;: no such file to load</title>
		<link>http://blog.scopeport.org/uncategorized/extconfrb1in-require-file-load/</link>
		<comments>http://blog.scopeport.org/uncategorized/extconfrb1in-require-file-load/#comments</comments>
		<pubDate>Fri, 09 Jan 2009 20:28:02 +0000</pubDate>
		<dc:creator>Lennart</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[abort]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[installation]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[require]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.scopeport.org/?p=150</guid>
		<description><![CDATA[When a gem installation fails with something like &#8220;extconf.rb:1:in `require&#8217;: no such file to load&#8221; you are probably missing the ruby development packages.
On Ubuntu you can fix this by installing the ruby1.8-dev package. (sudo aptitude install ruby1.8-dev)
]]></description>
			<content:encoded><![CDATA[<p>When a gem installation fails with something like &#8220;extconf.rb:1:in `require&#8217;: no such file to load&#8221; you are probably missing the ruby development packages.</p>
<p>On Ubuntu you can fix this by installing the ruby1.8-dev package. (sudo aptitude install ruby1.8-dev)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.scopeport.org/uncategorized/extconfrb1in-require-file-load/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
