<?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/"
	>

<channel>
	<title>RAILS PRESS</title>
	<atom:link href="http://railspress.matake.jp/feed" rel="self" type="application/rss+xml" />
	<link>http://railspress.matake.jp</link>
	<description>RUBY on RAILS, it’s DRY and COOL ...</description>
	<pubDate>Sat, 27 Dec 2008 06:05:48 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>ruby-oauth で Yahoo! OAuth を使う方法</title>
		<link>http://railspress.matake.jp/yahoo-oauth-with-ruby-oauth</link>
		<comments>http://railspress.matake.jp/yahoo-oauth-with-ruby-oauth#comments</comments>
		<pubDate>Sat, 27 Dec 2008 06:04:27 +0000</pubDate>
		<dc:creator>NOV</dc:creator>
		
		<category><![CDATA[OAuth]]></category>

		<category><![CDATA[Yahoo]]></category>

		<category><![CDATA[ノウハウ]]></category>

		<guid isPermaLink="false">http://railspress.matake.jp/?p=169</guid>
		<description><![CDATA[ruby-oauth で Yahoo! OAuth を使おうとしてだいぶはまったので、対応方法をメモ。
まずは oauth_parameter のうち、値が空のものは送らないようにしないと行けないようです。これは Yahoo! 側の問題かな？この問題を解決するには、OAuth::Client::Helper をオーバーライドします。
PLAIN TEXT
LANG : RUBY




# Yahoo! Hacks (for OAuth2.1)


class OAuth::Client::Helper


&#160; def oauth_parameters


&#160; &#160; &#123; 'oauth_consumer_key'&#160; &#160; &#160;=&#62; options&#91;:consumer&#93;.key,


&#160; &#160; &#160; 'oauth_token'&#160; &#160; &#160; &#160; &#160; &#160; =&#62; options&#91;:token&#93; ? options&#91;:token&#93;.token : '',


&#160; &#160; &#160; 'oauth_signature_method' =&#62; options&#91;:signature_method&#93;,


&#160; &#160; &#160; 'oauth_session_handle'&#160; &#160;=&#62; options&#91;:oauth_session_handle&#93; ? options&#91;:oauth_session_handle&#93; : '',


&#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>ruby-oauth で Yahoo! OAuth を使おうとしてだいぶはまったので、対応方法をメモ。</p>
<p>まずは oauth_parameter のうち、値が空のものは送らないようにしないと行けないようです。これは Yahoo! 側の問題かな？この問題を解決するには、OAuth::Client::Helper をオーバーライドします。</p>
<div class="igBar"><span id="lruby-3"><a href="#" onclick="javascript:showPlainTxt('ruby-3'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : RUBY</span>
<div id="ruby-3">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;"># Yahoo! Hacks (for OAuth2.1)</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">class</span> OAuth::Client::Helper</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> oauth_parameters</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span> 'oauth_consumer_key'&nbsp; &nbsp; &nbsp;=&gt; options<span style="color:#006600; font-weight:bold;">&#91;</span>:consumer<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">key</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; 'oauth_token'&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =&gt; options<span style="color:#006600; font-weight:bold;">&#91;</span>:token<span style="color:#006600; font-weight:bold;">&#93;</span> ? options<span style="color:#006600; font-weight:bold;">&#91;</span>:token<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">token</span> : '',</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; 'oauth_signature_method' =&gt; options<span style="color:#006600; font-weight:bold;">&#91;</span>:signature_method<span style="color:#006600; font-weight:bold;">&#93;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; 'oauth_session_handle'&nbsp; &nbsp;=&gt; options<span style="color:#006600; font-weight:bold;">&#91;</span>:oauth_session_handle<span style="color:#006600; font-weight:bold;">&#93;</span> ? options<span style="color:#006600; font-weight:bold;">&#91;</span>:oauth_session_handle<span style="color:#006600; font-weight:bold;">&#93;</span> : '',</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; 'oauth_timestamp'&nbsp; &nbsp; &nbsp; &nbsp; =&gt; timestamp,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; 'oauth_nonce'&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =&gt; nonce,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; 'oauth_version'&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =&gt; '<span style="color:#006666;color:#800000;">1</span>.<span style="color:#006666;color:#800000;">0</span>' <span style="color:#006600; font-weight:bold;">&#125;</span>.<span style="color:#9900CC;">reject</span> <span style="color:#006600; font-weight:bold;">&#123;</span> |k,v| v == <span style="color:#996600;">""</span> <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>次に、Yahoo! OAuth では１時間ごとに token を再発行したり、その際に session_handle を使ったりするので、ruby-oauth の OAuth::AccessToken と OAuth::RequestToken をこれらの属性に対応させる必要があります。</p>
<p><span id="more-169"></span></p>
<p>今はとりあえず Yahoo 用に AccessToken と RequestToken クラスを用意してやってます。多分そのうち ruby-oauth 側が対応するはずなので、それまではこれで。</p>
<div class="igBar"><span id="lruby-4"><a href="#" onclick="javascript:showPlainTxt('ruby-4'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : RUBY</span>
<div id="ruby-4">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">class</span> OAuth::AccessToken::Yahoo &lt;OAuth::AccessToken</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; attr_accessor :session_handle, :expires_in, :authorization_expires_in</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> initialize<span style="color:#006600; font-weight:bold;">&#40;</span>consumer, token, secret, options = <span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">super</span><span style="color:#006600; font-weight:bold;">&#40;</span>consumer, token, secret<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @session_handle&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= options<span style="color:#006600; font-weight:bold;">&#91;</span>:session_handle<span style="color:#006600; font-weight:bold;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @expires_in&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= options<span style="color:#006600; font-weight:bold;">&#91;</span>:expires_in<span style="color:#006600; font-weight:bold;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; @authorization_expires_in = options<span style="color:#006600; font-weight:bold;">&#91;</span>:authorization_expires_in<span style="color:#006600; font-weight:bold;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">class</span> OAuth::RequestToken::Yahoo &lt;OAuth::RequestToken</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> get_access_token<span style="color:#006600; font-weight:bold;">&#40;</span>options=<span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; response = consumer.<span style="color:#9900CC;">token_request</span><span style="color:#006600; font-weight:bold;">&#40;</span>consumer.<span style="color:#9900CC;">http_method</span>, consumer.<span style="color:#9900CC;">access_token_path</span>, <span style="color:#0000FF; font-weight:bold;">self</span>, options<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; access_token = OAuth::AccessToken::Yahoo.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; consumer,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; response<span style="color:#006600; font-weight:bold;">&#91;</span>:oauth_token<span style="color:#006600; font-weight:bold;">&#93;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; response<span style="color:#006600; font-weight:bold;">&#91;</span>:oauth_token_secret<span style="color:#006600; font-weight:bold;">&#93;</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#123;</span> :session_handle&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=&gt; response<span style="color:#006600; font-weight:bold;">&#91;</span>:oauth_session_handle<span style="color:#006600; font-weight:bold;">&#93;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; :expires_in&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;=&gt; response<span style="color:#006600; font-weight:bold;">&#91;</span>:oauth_expires_in<span style="color:#006600; font-weight:bold;">&#93;</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; :authorization_expires_in =&gt; response<span style="color:#006600; font-weight:bold;">&#91;</span>:oauth_authorization_expires_in<span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>あとはtoken の長さが 255 文字を超える（常に670文字？）のと、:session_handle, :expires_in, :authorization_expires_in の３つの属性が追加されるので、DB にそれらを反映させるのを忘れずに。</p>
]]></content:encoded>
			<wfw:commentRss>http://railspress.matake.jp/yahoo-oauth-with-ruby-oauth/feed</wfw:commentRss>
		</item>
		<item>
		<title>iKnow! gem 0.2.2</title>
		<link>http://railspress.matake.jp/iknow-gem-version-0-2-2</link>
		<comments>http://railspress.matake.jp/iknow-gem-version-0-2-2#comments</comments>
		<pubDate>Tue, 23 Dec 2008 07:09:56 +0000</pubDate>
		<dc:creator>NOV</dc:creator>
		
		<category><![CDATA[API]]></category>

		<category><![CDATA[Gem]]></category>

		<category><![CDATA[OAuth]]></category>

		<category><![CDATA[iKnow!]]></category>

		<category><![CDATA[リリース]]></category>

		<guid isPermaLink="false">http://railspress.matake.jp/?p=155</guid>
		<description><![CDATA[version 0.4.0 - version 0.1.1 までの更新履歴はこちら。
iKnow! gem version 0.1.1 - 京の路
iKnow! gem version up - OAuth &#038; Basic認証 - 京の路
version 0.2.2 となり、ようやくこちらのブログでも発表できるレベルになりました。version 0.2.2 では、OAuth / Basic 認証のサポート、すべての要認証 API Call のサポートが追加されています。
OAuth / Basic 認証は同じインタフェースで使えます。Iknow::Auth に username と password を指定すれば Basic 認証、token と secret を指定すれば OAuth を使います。
PLAIN TEXT
LANG : RUBY




iknow_auth = case auth_mode


&#160; when :oauth


&#160; &#160; Iknow::Auth.new&#40;


&#160; [...]]]></description>
			<content:encoded><![CDATA[<p>version 0.4.0 - version 0.1.1 までの更新履歴はこちら。<br />
<a href="http://blog.matake.jp/archives/iknow_gem_version_011.html" title="iKnow! gem version 0.1.1 - 京の路" target="_blank">iKnow! gem version 0.1.1 - 京の路</a><br />
<a href="http://blog.matake.jp/archives/iknow_gem_version_up_oauth_and_basic_auth.html" title="iKnow! gem version up - OAuth &#038; Basic認証 - 京の路" target="_blank">iKnow! gem version up - OAuth &#038; Basic認証 - 京の路</a></p>
<p>version 0.2.2 となり、ようやくこちらのブログでも発表できるレベルになりました。version 0.2.2 では、OAuth / Basic 認証のサポート、すべての要認証 API Call のサポートが追加されています。</p>
<p>OAuth / Basic 認証は同じインタフェースで使えます。Iknow::Auth に username と password を指定すれば Basic 認証、token と secret を指定すれば OAuth を使います。</p>
<div class="igBar"><span id="lruby-8"><a href="#" onclick="javascript:showPlainTxt('ruby-8'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : RUBY</span>
<div id="ruby-8">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">iknow_auth = <span style="color:#9966CC; font-weight:bold;">case</span> auth_mode</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">when</span> :oauth</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Iknow::Auth.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; :token =&gt; OAUTH_ACCESS_TOKEN,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; :secret =&gt; OAUTH_ACCESS_TOKEN_SECRET</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">when</span> :basic_auth</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; Iknow::Auth.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; :username =&gt; IKNOW_USERNAME,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; :password =&gt; IKNOW_PASSWORD</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>あとは、要認証 API Call の第一引数に Iknow::Auth のインスタンスを渡してください。（※ 12月23日現在、OAuth の DELETE 系 Call がエラーになりますが、これは iKnow! API 側の問題です）</p>
<p><span id="more-155"></span></p>
<div class="igBar"><span id="lruby-9"><a href="#" onclick="javascript:showPlainTxt('ruby-9'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : RUBY</span>
<div id="ruby-9">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;">## List API</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">"# List API"</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@list = Iknow::List.<span style="color:#9900CC;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; iknow_auth,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; :title =&gt; 'iKnow! gem <span style="color:#CC0066; font-weight:bold;">test</span>',</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; :description =&gt; 'A list <span style="color:#9966CC; font-weight:bold;">for</span> iKnow! gem <span style="color:#CC0066; font-weight:bold;">test</span>'</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@list.<span style="color:#9900CC;">add_item</span><span style="color:#006600; font-weight:bold;">&#40;</span>iknow_auth, Iknow::Item.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;color:#800000;">437525</span><span style="color:#006600; font-weight:bold;">&#41;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@list.<span style="color:#9900CC;">delete_item</span><span style="color:#006600; font-weight:bold;">&#40;</span>iknow_auth, @list.<span style="color:#9900CC;">items</span>.<span style="color:#9900CC;">first</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@list.<span style="color:#9900CC;">delete</span><span style="color:#006600; font-weight:bold;">&#40;</span>iknow_auth<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;">## Item API</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">"# Item API"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@item = Iknow::Item.<span style="color:#9900CC;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; iknow_auth,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; :cue =&gt; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; :text =&gt; 'hello world!',</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; :language =&gt; 'en',</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; :part_of_speech =&gt; 'E'</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; :response =&gt; <span style="color:#006600; font-weight:bold;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; :text =&gt; 'ハローワールド！',</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; :language =&gt; 'ja'</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@item.<span style="color:#9900CC;">add_image</span><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; iknow_auth,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; 'http://farm4.<span style="color:#9900CC;">static</span>.<span style="color:#9900CC;">flickr</span>.<span style="color:#9900CC;">com</span>/<span style="color:#006666;color:#800000;">3276</span>/<span style="color:#006666;color:#800000;">3102381796</span>_a33c1ffdf1.<span style="color:#9900CC;">jpg</span>'</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@item.<span style="color:#9900CC;">add_sound</span><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; iknow_auth,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; 'http://matake.<span style="color:#9900CC;">jp</span>/download/hello_world.<span style="color:#9900CC;">mp3</span>'</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@item.<span style="color:#9900CC;">add_tags</span><span style="color:#006600; font-weight:bold;">&#40;</span>iknow_auth, 'sample', 'programming'<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;">## Sentence API</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">"# Sentence API"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@sentence = Iknow::Sentence.<span style="color:#9900CC;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; iknow_auth,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; :text =&gt; 'Hello World!',</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; :item =&gt; Iknow::Item.<span style="color:#9900CC;">matching</span><span style="color:#006600; font-weight:bold;">&#40;</span>'hello world'<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">first</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@sentence.<span style="color:#9900CC;">add_image</span><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; iknow_auth,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; 'http://farm4.<span style="color:#9900CC;">static</span>.<span style="color:#9900CC;">flickr</span>.<span style="color:#9900CC;">com</span>/<span style="color:#006666;color:#800000;">3276</span>/<span style="color:#006666;color:#800000;">3102381796</span>_a33c1ffdf1.<span style="color:#9900CC;">jpg</span>'</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@sentence.<span style="color:#9900CC;">add_sound</span><span style="color:#006600; font-weight:bold;">&#40;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; iknow_auth,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; 'http://matake.<span style="color:#9900CC;">jp</span>/download/hello_world.<span style="color:#9900CC;">mp3</span>'</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>インストールは以下のコマンドで。</p>
<div class="igBar"><span id="lcode-10"><a href="#" onclick="javascript:showPlainTxt('code-10'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : shell etc.</span>
<div id="code-10">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">gem install iknow </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://railspress.matake.jp/iknow-gem-version-0-2-2/feed</wfw:commentRss>
<enclosure url="http://matake.jp/download/hello_world.mp3" length="9404" type="audio/mpeg" />
		</item>
		<item>
		<title>iKnow! gem をアップデートしました version 0.0.4</title>
		<link>http://railspress.matake.jp/iknow-gem-version-0-0-4</link>
		<comments>http://railspress.matake.jp/iknow-gem-version-0-0-4#comments</comments>
		<pubDate>Fri, 28 Nov 2008 17:51:05 +0000</pubDate>
		<dc:creator>NOV</dc:creator>
		
		<category><![CDATA[Gem]]></category>

		<category><![CDATA[GitHub]]></category>

		<category><![CDATA[iKnow!]]></category>

		<guid isPermaLink="false">http://railspress.matake.jp/?p=147</guid>
		<description><![CDATA[新規 Call の反映と、各 Call で追加された Attributes の反映が主な変更点です。Item creation API は Basic 認証で実装してしまおうかと思ってます。いつやるかは未定（ｱｾｱｾ
相変わらずドキュメントはサンプルコードですが、List / Item / Sentence の find や、User#study.total_summary などが新しく追加されています。また :include_sentences と :include_items は新しく追加されたパラメータです。
PLAIN TEXT
LANG : RUBY




## User API


@user = Iknow::User.find&#40;'kirk'&#41;


@user.items&#40;:include_sentences =&#62; true&#41;


@user.lists


@user.friends


@user.study.results


@user.study.total_summary


@matched_users = Iknow::User.matching&#40;'matake'&#41;


&#160;


## List API


@recent_lists = Iknow::List.recent


@list = Iknow::List.find&#40;31509, :include_sentences =&#62; true, :include_items =&#62; true&#41;


@list.items


@list.sentences


@matched_lists = Iknow::List.matching&#40;"イタリア語であいさつ"&#41;


&#160;


# puts Iknow::List.find(31509, :include_sentences =&#62; true, :include_items [...]]]></description>
			<content:encoded><![CDATA[<p>新規 Call の反映と、各 Call で追加された Attributes の反映が主な変更点です。Item creation API は Basic 認証で実装してしまおうかと思ってます。いつやるかは未定（ｱｾｱｾ</p>
<p>相変わらずドキュメントはサンプルコードですが、List / Item / Sentence の find や、User#study.total_summary などが新しく追加されています。また :include_sentences と :include_items は新しく追加されたパラメータです。</p>
<div class="igBar"><span id="lruby-12"><a href="#" onclick="javascript:showPlainTxt('ruby-12'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : RUBY</span>
<div id="ruby-12">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;">## User API</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@user = Iknow::User.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>'kirk'<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@user.<span style="color:#9900CC;">items</span><span style="color:#006600; font-weight:bold;">&#40;</span>:include_sentences =&gt; <span style="color:#0000FF; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@user.<span style="color:#9900CC;">lists</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@user.<span style="color:#9900CC;">friends</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@user.<span style="color:#9900CC;">study</span>.<span style="color:#9900CC;">results</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@user.<span style="color:#9900CC;">study</span>.<span style="color:#9900CC;">total_summary</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@matched_users = Iknow::User.<span style="color:#9900CC;">matching</span><span style="color:#006600; font-weight:bold;">&#40;</span>'matake'<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;">## List API</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@recent_lists = Iknow::List.<span style="color:#9900CC;">recent</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@list = Iknow::List.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;color:#800000;">31509</span>, :include_sentences =&gt; <span style="color:#0000FF; font-weight:bold;">true</span>, :include_items =&gt; <span style="color:#0000FF; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@list.<span style="color:#9900CC;">items</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@list.<span style="color:#9900CC;">sentences</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@matched_lists = Iknow::List.<span style="color:#9900CC;">matching</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">"イタリア語であいさつ"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;"># puts Iknow::List.find(31509, :include_sentences =&gt; true, :include_items =&gt; true).inspect</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;">## Item API</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@recent_items = Iknow::Item.<span style="color:#9900CC;">recent</span><span style="color:#006600; font-weight:bold;">&#40;</span>:include_sentences =&gt; <span style="color:#0000FF; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@item = Iknow::Item.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;color:#800000;">437525</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@matched_items = Iknow::Item.<span style="color:#9900CC;">matching</span><span style="color:#006600; font-weight:bold;">&#40;</span>'record', :include_sentences =&gt; <span style="color:#0000FF; font-weight:bold;">true</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@items = Iknow::Item.<span style="color:#9900CC;">extract</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">"sometimes, often, electrical"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@items.<span style="color:#9900CC;">first</span>.<span style="color:#9900CC;">sentences</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;">## Sentence API</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@recent_sentences = Iknow::Sentence.<span style="color:#9900CC;">recent</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@sentence = Iknow::Sentence.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006666;color:#800000;">312271</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@matched_sentences = Iknow::Sentence.<span style="color:#9900CC;">matching</span><span style="color:#006600; font-weight:bold;">&#40;</span>'record'<span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p> </p>
<p><span id="more-147"></span></p>
<p>ps.<br />
毎回 gem をいじってると細かいバグとか、微妙に使いづらい点とかに気がつくので、そういった点は API 自体の方にまた反映させていきます。「特定の Call でしか使えないオプションとかすごい分かりづらいので、なるべく全部の Call で使えるものはそうしたい」とか、そういうの。</p>
]]></content:encoded>
			<wfw:commentRss>http://railspress.matake.jp/iknow-gem-version-0-0-4/feed</wfw:commentRss>
		</item>
		<item>
		<title>iKnow! の OpenID で XRI をサポート &amp; ruby-openid を日本語 XRI 対応に</title>
		<link>http://railspress.matake.jp/ruby-openid-patches-for-multibyte-xr</link>
		<comments>http://railspress.matake.jp/ruby-openid-patches-for-multibyte-xr#comments</comments>
		<pubDate>Wed, 26 Nov 2008 04:48:25 +0000</pubDate>
		<dc:creator>NOV</dc:creator>
		
		<category><![CDATA[Gem]]></category>

		<category><![CDATA[OpenID]]></category>

		<category><![CDATA[iKnow!]]></category>

		<category><![CDATA[ノウハウ]]></category>

		<guid isPermaLink="false">http://railspress.matake.jp/?p=139</guid>
		<description><![CDATA[昨日 OpenID Foundation Japan で NRI の崎村さんに「iKnow! の OpenID は XRI をサポートしてないですね」ってなことを言われたらしいので、iKnow! の OpenID を XRI に対応させました。
OpenID Authentication Plugin の XRI 対応は RailsのOpenID Authentication PluginをXRI対応にする方法 に書きましたが、OpenID::Yadis::XRI.identifier_scheme というメソッドが既にあったので、今回はそれを使いました。
PLAIN TEXT
LANG : RUBY




module OpenIdAuthentication


&#160; # XRI support


&#160; def self.normalize_url_with_xri&#40;identifier&#41;


&#160; &#160; case OpenID::Yadis::XRI.identifier_scheme&#40;identifier&#41;


&#160; &#160; when :xri : identifier


&#160; &#160; when :uri : normalize_url_without_xri&#40;identifier&#41;


&#160; &#160; end


&#160; end


&#160; class &#60;&#60;self


&#160; &#160; [...]]]></description>
			<content:encoded><![CDATA[<p>昨日 OpenID Foundation Japan で NRI の<a href="http://www.sakimura.org/">崎村さん</a>に「iKnow! の OpenID は XRI をサポートしてないですね」ってなことを言われたらしいので、iKnow! の OpenID を XRI に対応させました。</p>
<p>OpenID Authentication Plugin の XRI 対応は <a href="http://railspress.matake.jp/use-xri-identity-with-openid-authentication-plugin">RailsのOpenID Authentication PluginをXRI対応にする方法</a> に書きましたが、OpenID::Yadis::XRI.identifier_scheme というメソッドが既にあったので、今回はそれを使いました。</p>
<div class="igBar"><span id="lruby-16"><a href="#" onclick="javascript:showPlainTxt('ruby-16'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : RUBY</span>
<div id="ruby-16">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">module</span> OpenIdAuthentication</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#008000; font-style:italic;"># XRI support</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">normalize_url_with_xri</span><span style="color:#006600; font-weight:bold;">&#40;</span>identifier<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">case</span> OpenID::Yadis::XRI.<span style="color:#9900CC;">identifier_scheme</span><span style="color:#006600; font-weight:bold;">&#40;</span>identifier<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">when</span> :xri : identifier</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">when</span> :uri : normalize_url_without_xri<span style="color:#006600; font-weight:bold;">&#40;</span>identifier<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">class</span> &lt;&lt;self</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; alias_method :normalize_url_without_xri, :normalize_url</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; alias_method :normalize_url, :normalize_url_with_xri</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>で、久しぶりに <a href="http://www.freexri.com/" target="_blank">@freexri</a> に行ってみたら、「=名前*nov」とかとれるようになってました。いつのまにか XRI って日本語も使えるようになってるんですね。日本語 XRI は微妙だけど、一応対応しておきました。</p>
<p>ruby-openid が日本語 XRI に対応してなかったので、OpenID::Yadis::XRI.escape_for_iri_with_multibyte をちょっと変更する必要があります。</p>
<div class="igBar"><span id="lruby-17"><a href="#" onclick="javascript:showPlainTxt('ruby-17'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : RUBY</span>
<div id="ruby-17">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">module</span> OpenID::Yadis::XRI</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">escape_for_iri_with_multibyte</span><span style="color:#006600; font-weight:bold;">&#40;</span>xri<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; esc = escape_for_iri_without_multibyte<span style="color:#006600; font-weight:bold;">&#40;</span>xri<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; esc.<span style="color:#CC0066; font-weight:bold;">gsub</span>!<span style="color:#006600; font-weight:bold;">&#40;</span>/<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span>\xC0-\xDF<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>\x80-\xBF<span style="color:#006600; font-weight:bold;">&#93;</span>|<span style="color:#006600; font-weight:bold;">&#91;</span>\xE0-\xEF<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>\x80-\xBF<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006666;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#125;</span>|<span style="color:#006600; font-weight:bold;">&#91;</span>\xF0-\xF7<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#91;</span>\x80-\xBF<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#123;</span><span style="color:#006666;color:#800000;">3</span><span style="color:#006600; font-weight:bold;">&#125;</span><span style="color:#006600; font-weight:bold;">&#41;</span>/e<span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#006600; font-weight:bold;">&#123;</span> |char_match|</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; CGI::escape<span style="color:#006600; font-weight:bold;">&#40;</span>char_match<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#0000FF; font-weight:bold;">return</span> esc</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">class</span> &lt;&lt;self</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; alias_method :escape_for_iri_without_multibyte, :escape_for_iri</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; alias_method :escape_for_iri, :escape_for_iri_with_multibyte</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>これで OK なはずですが...</p>
<p><span id="more-139"></span></p>
<p>そもそも「=名前*nov」の Yadis が動いてないみたい...意味ねー（涙</p>
<p>...「@id*またけ」はちゃんと動いてるから、まぁ良しとしよう。</p>
<p>fuckin <a href="http://www.freexri.com/" target="_blank">@freexri</a> !!</p>
<p>ps.<br />
ruby-openid は XRI のエラー処理が不十分なので、以下のパッチも当てておくと良いかと思います。</p>
<div class="igBar"><span id="lruby-18"><a href="#" onclick="javascript:showPlainTxt('ruby-18'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : RUBY</span>
<div id="ruby-18">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">module</span> OpenID</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#008000; font-style:italic;"># XRI Error handling</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">discover_xri_with_error_handling</span><span style="color:#006600; font-weight:bold;">&#40;</span>xri<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; discover_xri_without_error_handling<span style="color:#006600; font-weight:bold;">&#40;</span>xri<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">rescue</span> OpenID::Yadis::XRI::XRIHTTPError =&gt; e</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">raise</span> DiscoveryFailure.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">"XRI is not valid: #{e.message}"</span>, <span style="color:#0000FF; font-weight:bold;">nil</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">class</span> &lt;&lt;self</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; alias_method :discover_xri_without_error_handling, :discover_xri</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; alias_method :discover_xri, :discover_xri_with_error_handling</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://railspress.matake.jp/ruby-openid-patches-for-multibyte-xr/feed</wfw:commentRss>
		</item>
		<item>
		<title>iKnow! Developers Conference が終了しました</title>
		<link>http://railspress.matake.jp/iknow-developers-conference-%e3%81%8c%e7%b5%82%e4%ba%86%e3%81%97%e3%81%be%e3%81%97%e3%81%9f</link>
		<comments>http://railspress.matake.jp/iknow-developers-conference-%e3%81%8c%e7%b5%82%e4%ba%86%e3%81%97%e3%81%be%e3%81%97%e3%81%9f#comments</comments>
		<pubDate>Fri, 14 Nov 2008 01:25:27 +0000</pubDate>
		<dc:creator>NOV</dc:creator>
		
		<category><![CDATA[API]]></category>

		<category><![CDATA[Gem]]></category>

		<category><![CDATA[iKnow!]]></category>

		<guid isPermaLink="false">http://railspress.matake.jp/?p=137</guid>
		<description><![CDATA[iKnow! API の今後の方向性や、ライトニングトーク、ユーザのみなさまからのご要望など、非常に有意義なイベントになって良かったです。
飲み会も盛り上がってよかった！
僕のライトニングトークの時のプレゼン資料はこちらです。
280 slides っていう Keynote 風のサービスを使って作りました。280 slides が日本語使えない（コピーペーストすれば使える）ので、基本英語で簡単な資料ですが、よかったらどうぞ。
a_rubygem_for_iknow_api
View SlideShare presentation or Upload your own. (tags: 280slides)

しかし、通訳するにはあと３ヶ月くらいは英語勉強せんといかんな。特に日本語 => 英語をリアルタイムで訳すのはきっつい。
]]></description>
			<content:encoded><![CDATA[<p>iKnow! API の今後の方向性や、ライトニングトーク、ユーザのみなさまからのご要望など、非常に有意義なイベントになって良かったです。</p>
<p>飲み会も盛り上がってよかった！</p>
<p>僕のライトニングトークの時のプレゼン資料はこちらです。</p>
<p><a href="http://280slides.com/" target="_blank">280 slides</a> っていう Keynote 風のサービスを使って作りました。280 slides が日本語使えない（コピーペーストすれば使える）ので、基本英語で簡単な資料ですが、よかったらどうぞ。</p>
<div style="width:425px;text-align:left" id="__ss_751406"><a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/matake/arubygemforiknowapi?type=powerpoint" title="a_rubygem_for_iknow_api">a_rubygem_for_iknow_api</a><object style="margin:0px" width="425" height="355"><param name="movie" value="http://static.slideshare.net/swf/ssplayer2.swf?doc=arubygemforiknowapi1199&#038;rel=0&#038;stripped_title=arubygemforiknowapi" /><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always"/><embed src="http://static.slideshare.net/swf/ssplayer2.swf?doc=arubygemforiknowapi1199&#038;rel=0&#038;stripped_title=arubygemforiknowapi" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"></embed></object>
<div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;">View SlideShare <a style="text-decoration:underline;" href="http://www.slideshare.net/matake/arubygemforiknowapi?type=powerpoint" title="View a_rubygem_for_iknow_api on SlideShare">presentation</a> or <a style="text-decoration:underline;" href="http://www.slideshare.net/upload?type=powerpoint">Upload</a> your own. (tags: <a style="text-decoration:underline;" href="http://slideshare.net/tag/280slides">280slides</a>)</div>
</div>
<p>しかし、通訳するにはあと３ヶ月くらいは英語勉強せんといかんな。特に日本語 => 英語をリアルタイムで訳すのはきっつい。</p>
]]></content:encoded>
			<wfw:commentRss>http://railspress.matake.jp/iknow-developers-conference-%e3%81%8c%e7%b5%82%e4%ba%86%e3%81%97%e3%81%be%e3%81%97%e3%81%9f/feed</wfw:commentRss>
		</item>
		<item>
		<title>Functional Test でリクエスト発行時（GET/POST/PUT/DELETE）に before_filter/after_filter をかける方法</title>
		<link>http://railspress.matake.jp/before-and-after-filters-on-each-request-in-functional-tests</link>
		<comments>http://railspress.matake.jp/before-and-after-filters-on-each-request-in-functional-tests#comments</comments>
		<pubDate>Tue, 28 Oct 2008 11:46:24 +0000</pubDate>
		<dc:creator>NOV</dc:creator>
		
		<category><![CDATA[ActionController]]></category>

		<category><![CDATA[filters]]></category>

		<category><![CDATA[テスト]]></category>

		<category><![CDATA[ノウハウ]]></category>

		<guid isPermaLink="false">http://railspress.matake.jp/?p=133</guid>
		<description><![CDATA[Functional Test ですべての @response.body と @response.headers の内容をチェックしたくて、リクエスト発行時に after_filter 的なことをしたので、方法をメモ。
以下の記事が非常に参考になりました。
 functional test をめぐる冒険 - Rails で行こう！
やってることは、単純に get とか post とかの内部で呼ばれてる process というメソッドを、RAILS_ROOT/test/test_helper 内で書き換えているだけ。
PLAIN TEXT
LANG : RUBY




def process_with_assert_no_wapi&#40;action, parameters = nil, session = nil, flash = nil&#41;


&#160; process_without_assert_no_wapi&#40;action, parameters, session, flash&#41;


&#160; assert_no_wapi


end


alias_method :process_without_assert_no_wapi, :process 


alias_method :process, :process_with_assert_no_wapi 






以下のような functional test があった場合、get(:index) と get(:show, ...) の前後で自動的にフィルタをかけています。

PLAIN TEXT
LANG : [...]]]></description>
			<content:encoded><![CDATA[<p>Functional Test ですべての @response.body と @response.headers の内容をチェックしたくて、リクエスト発行時に after_filter 的なことをしたので、方法をメモ。</p>
<p>以下の記事が非常に参考になりました。</p>
<p><a href="http://d.hatena.ne.jp/elm200/20070724/1185282738" title=" functional test をめぐる冒険 - Rails で行こう！" target="_blank"> functional test をめぐる冒険 - Rails で行こう！</a></p>
<p>やってることは、単純に get とか post とかの内部で呼ばれてる process というメソッドを、RAILS_ROOT/test/test_helper 内で書き換えているだけ。</p>
<div class="igBar"><span id="lruby-21"><a href="#" onclick="javascript:showPlainTxt('ruby-21'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : RUBY</span>
<div id="ruby-21">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">def</span> process_with_assert_no_wapi<span style="color:#006600; font-weight:bold;">&#40;</span>action, parameters = <span style="color:#0000FF; font-weight:bold;">nil</span>, session = <span style="color:#0000FF; font-weight:bold;">nil</span>, flash = <span style="color:#0000FF; font-weight:bold;">nil</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; process_without_assert_no_wapi<span style="color:#006600; font-weight:bold;">&#40;</span>action, parameters, session, flash<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; assert_no_wapi</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">alias_method :process_without_assert_no_wapi, :process </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">alias_method :process, :process_with_assert_no_wapi </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>以下のような functional test があった場合、get(:index) と get(:show, ...) の前後で自動的にフィルタをかけています。</p>
<p><span id="more-133"></span></p>
<div class="igBar"><span id="lruby-22"><a href="#" onclick="javascript:showPlainTxt('ruby-22'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : RUBY</span>
<div id="ruby-22">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0066; font-weight:bold;">require</span> File.<span style="color:#9900CC;">dirname</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#0000FF; font-weight:bold;">__FILE__</span><span style="color:#006600; font-weight:bold;">&#41;</span> + '/../test_helper'</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">class</span> UsersControllerTest &lt;ActionController::TestCase</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; fixtures :users</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> test_index</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; get<span style="color:#006600; font-weight:bold;">&#40;</span>:index<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> test_show</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; get<span style="color:#006600; font-weight:bold;">&#40;</span>:index, :user_id =&gt; 'nov'<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>でも本当は、こんなテスト書かなくていいような設計が一番いいと思うんだけどねぇ。。。</p>
]]></content:encoded>
			<wfw:commentRss>http://railspress.matake.jp/before-and-after-filters-on-each-request-in-functional-tests/feed</wfw:commentRss>
		</item>
		<item>
		<title>GitHub に自作の RubyGems を登録する方法</title>
		<link>http://railspress.matake.jp/how-to-release-rubygems-on-githu</link>
		<comments>http://railspress.matake.jp/how-to-release-rubygems-on-githu#comments</comments>
		<pubDate>Fri, 17 Oct 2008 16:38:42 +0000</pubDate>
		<dc:creator>NOV</dc:creator>
		
		<category><![CDATA[Gem]]></category>

		<category><![CDATA[GitHub]]></category>

		<category><![CDATA[ノウハウ]]></category>

		<category><![CDATA[リリース]]></category>

		<guid isPermaLink="false">http://railspress.matake.jp/?p=109</guid>
		<description><![CDATA[iKnow! API gem を GitHub に公開したときのフローをメモしておきます。

GitHub に Signup
ログイン後のホーム右サイドーから「Your Repositories (create a new one)」をクリック
Project Name / Description / Homepage URL を登録
ヘッダー右側の「account」から SSH 公開鍵を登録
作成したレポジトリに rubygem を push（詳細なやり方はレポジトリトップに載っています）
レポジトリのをクリック
「RubyGem」のチェックボックスにチェックする

これで10分〜20分くらい待っていれば、GitHub RubyGems List のページに登録した gem が掲載されるはずです。GitHub が勝手に gem を build してくれるので、Developer がやるのはチェックボックスにチェックを入れるだけ！超簡単。build に成功すれば、gem search であなたの gem が見つかります。

PLAIN TEXT
LANG : shell etc.




gem search -r $YOUR_GEM_NAME 






注意）GitHub を gem レポジトリに登録していない場合は、以下のコマンドで登録が必要です。
PLAIN TEXT
LANG : shell [...]]]></description>
			<content:encoded><![CDATA[<p>iKnow! API gem を GitHub に公開したときのフローをメモしておきます。</p>
<ol>
<li><a href="http://github.com/plans" target="_blank">GitHub に Signup</a></li>
<li><a href="https://github.com" target="_blank">ログイン後のホーム</a>右サイドーから「Your Repositories <a href="http://github.com/repositories/new">(create a new one)</a>」をクリック<br /><img src="http://railspress.matake.jp/wp-content/uploads/screenshot_31-300x46.jpg" alt="" title="create a new one" /></li>
<li>Project Name / Description / Homepage URL を登録</li>
<li>ヘッダー右側の「<a href="https://github.com/account" target="_blank">account</a>」から SSH 公開鍵を登録</li>
<li>作成したレポジトリに rubygem を push（詳細なやり方はレポジトリトップに載っています）</li>
<li>レポジトリの<img src="http://railspress.matake.jp/wp-content/uploads/screenshot_2.jpg" alt="" title="GitHub Repository Edit" />をクリック</li>
<li>「RubyGem」のチェックボックスにチェックする<br /><img src="http://railspress.matake.jp/wp-content/uploads/screenshot_1.jpg" alt="" title="RubyGem checkbox" /></li>
</ol>
<p>これで10分〜20分くらい待っていれば、<a href="http://gems.github.com/list.html" target="_blank">GitHub RubyGems List</a> のページに登録した gem が掲載されるはずです。GitHub が勝手に gem を build してくれるので、Developer がやるのはチェックボックスにチェックを入れるだけ！超簡単。build に成功すれば、gem search であなたの gem が見つかります。</p>
<p><span id="more-109"></span></p>
<div class="igBar"><span id="lcode-25"><a href="#" onclick="javascript:showPlainTxt('code-25'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : shell etc.</span>
<div id="code-25">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">gem search -r $YOUR_GEM_NAME </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>注意）GitHub を gem レポジトリに登録していない場合は、以下のコマンドで登録が必要です。</p>
<div class="igBar"><span id="lcode-26"><a href="#" onclick="javascript:showPlainTxt('code-26'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : shell etc.</span>
<div id="code-26">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sudo gem source -a http:<span style="color:#FF9933; font-style:italic;">//gems.github.com </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>1時間以上まって掲載されていなければ、GitHub 上での gem の build が失敗しているので、<a href="http://gems.github.com/">GitHub RubyGems</a> の一番下にある Troubleshooting を参考に、問題箇所を修正してください。iknow gem をリリースしたときは、最初 build に失敗していたのだけど、GitHub 側からは何の連絡もこなかったので最初ハマった。</p>
<p>なを、エラーを修正しても、gemspec ファイルが更新されていなければ GitHub は gem の再 build を行わないので、version をあげるなり、gemspec をちょこっと編集するなりして、gemspec を更新してください。ここもまた僕がハマったところ。。</p>
]]></content:encoded>
			<wfw:commentRss>http://railspress.matake.jp/how-to-release-rubygems-on-githu/feed</wfw:commentRss>
		</item>
		<item>
		<title>3分で iKnow! API アプリを作る方法 - iknow gem</title>
		<link>http://railspress.matake.jp/iknow-gem-released</link>
		<comments>http://railspress.matake.jp/iknow-gem-released#comments</comments>
		<pubDate>Fri, 17 Oct 2008 07:45:52 +0000</pubDate>
		<dc:creator>NOV</dc:creator>
		
		<category><![CDATA[API]]></category>

		<category><![CDATA[Gem]]></category>

		<category><![CDATA[OAuth]]></category>

		<category><![CDATA[iKnow!]]></category>

		<category><![CDATA[お知らせ]]></category>

		<category><![CDATA[インストール／設定]]></category>

		<category><![CDATA[サンプルアプリ]]></category>

		<category><![CDATA[リリース]]></category>

		<guid isPermaLink="false">http://railspress.matake.jp/?p=104</guid>
		<description><![CDATA[前のエントリーでご紹介した iKnow! API 用の rubygem の使い方について。
Install iKnow! gem
レポジトリはこちら ⇒ nov-iknow@github
インストールは github を gem のソースに追加して（既に追加した人はもう追加しないように）
PLAIN TEXT
LANG : shell etc.




sudo gem source -a http://gems.github.com 






普通に gem install
PLAIN TEXT
LANG : shell etc.




sudo gem install nov-iknow 






これで、iKnow! API 経由のアクセスを、通常のモデルと同じ感じで使えるようになります。

サンプルアプリの紹介
既にレポジトリの examples の中に、pure-ruby 版と rails 版のサンプルアプリを置いてあります。
ここでは rails 版のサンプルアプリを作る流れを紹介します。
まずはセットアップ。
PLAIN TEXT
LANG : shell etc.




rails iknow_on_rails


cd iknow_on_rails


./script/generate iknow_oauth


rake db:create


rake db:migrate 






これで必要なクラスやらライブラリやらが生成されます。
次に API Key などの設定を、conf/environment.rb [...]]]></description>
			<content:encoded><![CDATA[<p>前のエントリーでご紹介した iKnow! API 用の rubygem の使い方について。</p>
<h3>Install iKnow! gem</h3>
<p>レポジトリはこちら ⇒ <a href="http://github.com/nov/iknow" target="_blank">nov-iknow@github</a></p>
<p>インストールは github を gem のソースに追加して（既に追加した人はもう追加しないように）</p>
<div class="igBar"><span id="lcode-36"><a href="#" onclick="javascript:showPlainTxt('code-36'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : shell etc.</span>
<div id="code-36">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sudo gem source -a http:<span style="color:#FF9933; font-style:italic;">//gems.github.com </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>普通に gem install</p>
<div class="igBar"><span id="lcode-37"><a href="#" onclick="javascript:showPlainTxt('code-37'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : shell etc.</span>
<div id="code-37">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">sudo gem install nov-iknow </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>これで、iKnow! API 経由のアクセスを、通常のモデルと同じ感じで使えるようになります。</p>
<p><span id="more-104"></span></p>
<h3>サンプルアプリの紹介</h3>
<p>既にレポジトリの examples の中に、pure-ruby 版と rails 版のサンプルアプリを置いてあります。<br />
ここでは rails 版のサンプルアプリを作る流れを紹介します。</p>
<p>まずはセットアップ。</p>
<div class="igBar"><span id="lcode-38"><a href="#" onclick="javascript:showPlainTxt('code-38'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : shell etc.</span>
<div id="code-38">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">rails iknow_on_rails</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">cd iknow_on_rails</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">./script/generate iknow_oauth</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">rake db:create</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">rake db:migrate </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>これで必要なクラスやらライブラリやらが生成されます。</p>
<p>次に API Key などの設定を、conf/environment.rb あたりに記述します。API Key の取得方法は、<a href="http://developer.iknow.co.jp/docs/API">iKnow! API 日本語ガイド</a>の一番下の方にキャプチャ画像つきでまとめてあるので、そちらを参考にしてください。</p>
<div class="igBar"><span id="lruby-39"><a href="#" onclick="javascript:showPlainTxt('ruby-39'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : RUBY</span>
<div id="ruby-39">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0066; font-weight:bold;">require</span> 'nov-iknow'</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Iknow::Config.<span style="color:#9900CC;">init</span> <span style="color:#9966CC; font-weight:bold;">do</span> |conf|</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; conf.<span style="color:#9900CC;">api_key</span>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;= 'SET_YOUR_API_KEY_HERE'</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; conf.<span style="color:#9900CC;">oauth_consumer_key</span>&nbsp; &nbsp; = ''</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; conf.<span style="color:#9900CC;">oauth_consumer_secret</span> = ''</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>サンプルアプリでは、この後簡単なユーザ検索機能だけを実装しています。<br />
アクションは１つ。たった４行のコードです。</p>
<div class="igBar"><span id="lcode-40"><a href="#" onclick="javascript:showPlainTxt('code-40'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : shell etc.</span>
<div id="code-40">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">./script/generate controller users index </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<div class="igBar"><span id="lruby-41"><a href="#" onclick="javascript:showPlainTxt('ruby-41'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : RUBY</span>
<div id="ruby-41">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">class</span> UsersController &lt;ApplicationController</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> index</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">unless</span> params<span style="color:#006600; font-weight:bold;">&#91;</span>:iknow_username<span style="color:#006600; font-weight:bold;">&#93;</span>.<span style="color:#9900CC;">blank</span>?</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; @user = Iknow::User.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>params<span style="color:#006600; font-weight:bold;">&#91;</span>:iknow_username<span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; flash<span style="color:#006600; font-weight:bold;">&#91;</span>:notice<span style="color:#006600; font-weight:bold;">&#93;</span> = <span style="color:#996600;">"404 User Not Found"</span> <span style="color:#9966CC; font-weight:bold;">unless</span> @user</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>View 内で @user.friends とか @user.items とかやってるとこでは、それぞれ個別に API にアクセスが飛びます。</p>
<div class="igBar"><span id="lruby-42"><a href="#" onclick="javascript:showPlainTxt('ruby-42'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : RUBY</span>
<div id="ruby-42">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;% form_tag <span style="color:#9966CC; font-weight:bold;">do</span> %&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;div id=<span style="color:#996600;">"iknow_user_search"</span>&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &lt;div <span style="color:#9966CC; font-weight:bold;">class</span>=<span style="color:#996600;">"label"</span>&gt;&lt;label <span style="color:#9966CC; font-weight:bold;">for</span>=<span style="color:#996600;">"iknow_username"</span>&gt;iKnow! Username&lt;/label&gt;&lt;/div&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &lt;div <span style="color:#9966CC; font-weight:bold;">class</span>=<span style="color:#996600;">"input"</span>&gt;&lt;%= text_field_tag <span style="color:#996600;">"iknow_username"</span> %&gt;&lt;/div&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/div&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;% <span style="color:#9966CC; font-weight:bold;">end</span> %&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;% <span style="color:#9966CC; font-weight:bold;">unless</span> @user.<span style="color:#0000FF; font-weight:bold;">nil</span>? %&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;dl&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;% @user.<span style="color:#9900CC;">profile</span>.<span style="color:#9900CC;">attributes</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> |key| %&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &lt;dt&gt;&lt;%= key %&gt;&lt;/dt&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &lt;dd&gt;&lt;%= @user.<span style="color:#9900CC;">profile</span>.<span style="color:#9900CC;">send</span><span style="color:#006600; font-weight:bold;">&#40;</span>key<span style="color:#006600; font-weight:bold;">&#41;</span> || <span style="color:#996600;">"--NOTHING TO DISPLAY--"</span> %&gt;&lt;/dd&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;% <span style="color:#9966CC; font-weight:bold;">end</span> %&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &lt;dt&gt;Lists&lt;/dt&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &lt;dd&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;ul&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &lt;% @user.<span style="color:#9900CC;">lists</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> |list| %&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &lt;li&gt;&lt;%= link_to list.<span style="color:#9900CC;">title</span>, list.<span style="color:#9900CC;">link</span> %&gt;&lt;br /&gt;&lt;%= list.<span style="color:#9900CC;">description</span> %&gt;&lt;/li&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &lt;% <span style="color:#9966CC; font-weight:bold;">end</span> %&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/ul&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &lt;/dd&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &lt;dt&gt;Items&lt;/dt&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &lt;dd&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;ul&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &lt;% @user.<span style="color:#9900CC;">items</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> |item| %&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &lt;li&gt;&lt;%= item.<span style="color:#9900CC;">cue</span>.<span style="color:#9900CC;">text</span> %&gt;&lt;% <span style="color:#9966CC; font-weight:bold;">if</span> item.<span style="color:#9900CC;">response</span> %&gt; &lt;=&gt; &lt;%= item.<span style="color:#9900CC;">response</span>.<span style="color:#9900CC;">text</span> %&gt;&lt;% <span style="color:#9966CC; font-weight:bold;">end</span> %&gt;&lt;/li&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &lt;% <span style="color:#9966CC; font-weight:bold;">end</span> %&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/ul&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &lt;/dd&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &lt;dt&gt;Study Results <span style="color:#006600; font-weight:bold;">&#40;</span>min<span style="color:#006600; font-weight:bold;">&#41;</span>&lt;/dt&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &lt;dd&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;%= @user.<span style="color:#9900CC;">study</span>.<span style="color:#9900CC;">today</span> %&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;ul&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &lt;% @user.<span style="color:#9900CC;">study</span>.<span style="color:#9900CC;">results</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> |result| %&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &lt;li&gt;&lt;%= result.<span style="color:#9900CC;">date</span> %&gt; :: &lt;%= <span style="color:#CC0066; font-weight:bold;">sprintf</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">"%.1f"</span>, result.<span style="color:#9900CC;">seconds</span>.<span style="color:#9900CC;">to_f</span>/<span style="color:#006666;color:#800000;">60</span>.<span style="color:#006666;color:#800000;">0</span><span style="color:#006600; font-weight:bold;">&#41;</span> %&gt;&lt;/li&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &lt;% <span style="color:#9966CC; font-weight:bold;">end</span> %&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/ul&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &lt;/dd&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &lt;dt&gt;Friends&lt;/dt&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &lt;dd&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;ul&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &lt;% @user.<span style="color:#9900CC;">friends</span>.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> |friend| %&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &lt;li&gt;&lt;%= link_to friend.<span style="color:#9900CC;">profile</span>.<span style="color:#9900CC;">name</span>, friend.<span style="color:#9900CC;">profile</span>.<span style="color:#9900CC;">profile_url</span> %&gt;&lt;/li&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &lt;% <span style="color:#9966CC; font-weight:bold;">end</span> %&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &lt;/ul&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &lt;/dd&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;/dl&gt;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;% <span style="color:#9966CC; font-weight:bold;">end</span> %&gt;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&lt;%= flash<span style="color:#006600; font-weight:bold;">&#91;</span>:notice<span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#9966CC; font-weight:bold;">rescue</span> <span style="color:#0000FF; font-weight:bold;">nil</span> %&gt; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>これだけ。<br />
本当はデザインをちょっとかっこ良くしたいのだけど、まぁサンプルですから。</p>
<h3>iKnow! gem でできること</h3>
<p>API でできることは pure-ruby 版のサンプルを見ればすぐ分かりますが、ざっとこんな感じ。<br />
matching はキーワード検索、extract は単語に分けて item リスト（訳と例文つき）を返す API です。</p>
<div class="igBar"><span id="lruby-43"><a href="#" onclick="javascript:showPlainTxt('ruby-43'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : RUBY</span>
<div id="ruby-43">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;">## User API</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@user = Iknow::User.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>'matake'<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@user.<span style="color:#9900CC;">items</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@user.<span style="color:#9900CC;">lists</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@user.<span style="color:#9900CC;">friends</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@user.<span style="color:#9900CC;">study_results</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@matchied_users = Iknow::User.<span style="color:#9900CC;">matching</span><span style="color:#006600; font-weight:bold;">&#40;</span>'matake'<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;"># ## List API</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@recent_lists = Iknow::List.<span style="color:#9900CC;">recent</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@matchied_lists = Iknow::List.<span style="color:#9900CC;">matching</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">"遺伝的アルゴリズム"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@ga_list.<span style="color:#9900CC;">first</span>.<span style="color:#9900CC;">items</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@ga_list.<span style="color:#9900CC;">first</span>.<span style="color:#9900CC;">sentences</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;"># ## Item API</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@recent_items = Iknow::Item.<span style="color:#9900CC;">recent</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@matchied_items = Iknow::Item.<span style="color:#9900CC;">matching</span><span style="color:#006600; font-weight:bold;">&#40;</span>'record'<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@items = Iknow::Item.<span style="color:#9900CC;">extract</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">"sometimes, often, electrical"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@items.<span style="color:#9900CC;">first</span>.<span style="color:#9900CC;">sentences</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;">## Sentence API</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@recent_sentences = Iknow::Sentence.<span style="color:#9900CC;">recent</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@matchied_sentences = Iknow::Sentence.<span style="color:#9900CC;">matching</span><span style="color:#006600; font-weight:bold;">&#40;</span>'record'<span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>あと、パラメータを追加するときは、以下のように指定します。</p>
<div class="igBar"><span id="lruby-44"><a href="#" onclick="javascript:showPlainTxt('ruby-44'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : RUBY</span>
<div id="ruby-44">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">Iknow::User.<span style="color:#9900CC;">matching</span><span style="color:#006600; font-weight:bold;">&#40;</span>'matake', :age_from =&gt; <span style="color:#006666;color:#800000;">10</span>, :age_to =&gt; <span style="color:#006666;color:#800000;">30</span>, :gender =&gt; 'male'<span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>各呼び出しに指定できるパラメータは、<a href="http://developer.iknow.co.jp/docs" target="_blank">iKnow! Developer</a> をご覧ください。</p>
<h3>今後の予定</h3>
<p>テストはまだ１行も書いてません（汗<br />
これは公開されている gem としてはよろしくないので、近日中に追加します。<br />
あと、iKnow! の OAuth はまだ正式にスタートできてないので、そこの周りの機能も後日追加します。</p>
]]></content:encoded>
			<wfw:commentRss>http://railspress.matake.jp/iknow-gem-released/feed</wfw:commentRss>
		</item>
		<item>
		<title>iKnow! API をリリースしました</title>
		<link>http://railspress.matake.jp/iknow-api-released</link>
		<comments>http://railspress.matake.jp/iknow-api-released#comments</comments>
		<pubDate>Fri, 17 Oct 2008 04:10:27 +0000</pubDate>
		<dc:creator>NOV</dc:creator>
		
		<category><![CDATA[API]]></category>

		<category><![CDATA[iKnow!]]></category>

		<category><![CDATA[お知らせ]]></category>

		<category><![CDATA[リリース]]></category>

		<guid isPermaLink="false">http://railspress.matake.jp/?p=98</guid>
		<description><![CDATA[iKnow! に来てまだ２週間ですが、僕の iKnow! での初仕事、iKnow! API がリリースされました！
僕はそれほど多くの部分を実装した訳ではないですが。（1割弱くらいは実装した、のかな？実はまだ API の全貌を把握しきれていない...汗）
API リリースとともに、API を利用したアプリケーションのコンテスト「iKnow! API KICK OFF!」も開催しています。そちらは主に日本人向けのイベントなので、主に僕が技術面での窓口になっています。



iKnow! API KICK OFF!
コンテストは 2008/10/15-12/15 の2ヶ月にわたって行われていて、優勝賞金は 20 万円になっています。ドリコムの Award on Rails 程高くはないですが、きっと優勝アプリは iKnow! ユーザ全体に告知されるはずなので、優勝したとたんに結構なアクセスがくるはず！
また API は、OAuth や OpenSearch や microformat など、なるべく Web 標準にそった形で実装されている（今後そうなっていく部分もあり）ので、iKnow! API と Google やその他の API との連携も、比較的簡単に行えるのではないかと思います。
ぜひこの機会に iKnow! API を利用してみてくださいね☆

また API リリースに会わせて、iKnow! API 用の Rubygem も用意しました。こちらに関しては、僕が仕事とプライベートを混同しながら実装しています。
なので、すべてのバグは僕のせいです...あはw
インストール方法とか使い方とかは、次の記事にまとめます。
]]></description>
			<content:encoded><![CDATA[<p>iKnow! に来てまだ２週間ですが、僕の iKnow! での初仕事、<strong>iKnow! API</strong> がリリースされました！</p>
<p>僕はそれほど多くの部分を実装した訳ではないですが。（1割弱くらいは実装した、のかな？実はまだ API の全貌を把握しきれていない...汗）</p>
<p>API リリースとともに、API を利用したアプリケーションのコンテスト「<a href="http://www.iknow.co.jp/landing/api" title="iKnow! API KICK OFF!" target="_blank">iKnow! API KICK OFF!</a>」も開催しています。そちらは主に日本人向けのイベントなので、主に僕が技術面での窓口になっています。</p>
<div class="clearfix">
<a href="http://www.iknow.co.jp/landing/api" title="iKnow! API KICK OFF!" target="_blank"><span class="shadow"><img src="http://webpix.drecom.jp/image/large/http://www.iknow.co.jp/landing/api" alt="iKnow! - iKnow!" /></span></a>
</div>
<p><a href="http://www.iknow.co.jp/landing/api" title="iKnow! API KICK OFF!" target="_blank">iKnow! API KICK OFF!</a></p>
<p>コンテストは 2008/10/15-12/15 の2ヶ月にわたって行われていて、優勝賞金は 20 万円になっています。ドリコムの Award on Rails 程高くはないですが、きっと優勝アプリは iKnow! ユーザ全体に告知されるはずなので、優勝したとたんに結構なアクセスがくるはず！</p>
<p>また API は、OAuth や OpenSearch や microformat など、なるべく Web 標準にそった形で実装されている（今後そうなっていく部分もあり）ので、iKnow! API と Google やその他の API との連携も、比較的簡単に行えるのではないかと思います。</p>
<p>ぜひこの機会に iKnow! API を利用してみてくださいね☆</p>
<p><span id="more-98"></span></p>
<p>また API リリースに会わせて、<a href="http://github.com/nov/iknow" target="_blank">iKnow! API 用の Rubygem</a> も用意しました。こちらに関しては、僕が仕事とプライベートを混同しながら実装しています。<br />
なので、すべてのバグは僕のせいです...あはw</p>
<p>インストール方法とか使い方とかは、次の記事にまとめます。</p>
]]></content:encoded>
			<wfw:commentRss>http://railspress.matake.jp/iknow-api-released/feed</wfw:commentRss>
		</item>
		<item>
		<title>Ubuntu 上で走る autotest の結果を MacBook の Growl に表示させる方法</title>
		<link>http://railspress.matake.jp/notify-autotest-result-from-ubuntu-to-macbook</link>
		<comments>http://railspress.matake.jp/notify-autotest-result-from-ubuntu-to-macbook#comments</comments>
		<pubDate>Thu, 09 Oct 2008 13:07:33 +0000</pubDate>
		<dc:creator>NOV</dc:creator>
		
		<category><![CDATA[iKnow!]]></category>

		<category><![CDATA[ubuntu]]></category>

		<category><![CDATA[テスト]]></category>

		<guid isPermaLink="false">http://railspress.matake.jp/?p=91</guid>
		<description><![CDATA[こちらのブログでは遅ればせながら、先月末でドリコムを退職し、今月からiKnow! (Cerego Japan) で働いています。
iKnow! でも開発マシンは MacBook のままですが、開発用サーバマシンとして ubuntu を支給されたので、ubuntu から MacBook の開発ディレクトリをマウントして、DB やら mongrel やらは ubuntu 上で動かしています。
ubuntu には（てか apt には？）Mumbles という Mac の Growl に似た notification ツールがあって、そいつから LAN 上の Growl に notification を送れます。
PLAIN TEXT
LANG : shell etc.




~/.autotest 






に、以下のように記述しておけば OK
PLAIN TEXT
LANG : RUBY




require 'autotest/redgreen'


&#160;


module Autotest::Mumbles


&#160;


&#160; def self.mumbles title, msg, successed 


&#160; &#160; system "mumbles-send -g bianca.cerego.co.jp [...]]]></description>
			<content:encoded><![CDATA[<p>こちらのブログでは遅ればせながら、先月末で<a href="http://blog.matake.jp/archives/the-last-day-and-the-first.html" target="_blank">ドリコムを退職</a>し、今月から<a href="http://blog.matake.jp/archives/iknowcerego_japan.html" target="_blank">iKnow! (Cerego Japan) で働いて</a>います。</p>
<p>iKnow! でも開発マシンは MacBook のままですが、開発用サーバマシンとして ubuntu を支給されたので、ubuntu から MacBook の開発ディレクトリをマウントして、DB やら mongrel やらは ubuntu 上で動かしています。</p>
<p>ubuntu には（てか apt には？）<a href="http://www.mumbles-project.org/" target="_blank">Mumbles</a> という Mac の Growl に似た notification ツールがあって、そいつから LAN 上の Growl に notification を送れます。</p>
<div class="igBar"><span id="lcode-47"><a href="#" onclick="javascript:showPlainTxt('code-47'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : shell etc.</span>
<div id="code-47">
<div class="code">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">~/.<span style="">autotest</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>に、以下のように記述しておけば OK</p>
<div class="igBar"><span id="lruby-48"><a href="#" onclick="javascript:showPlainTxt('ruby-48'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : RUBY</span>
<div id="ruby-48">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0066; font-weight:bold;">require</span> 'autotest/redgreen'</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">module</span> Autotest::Mumbles</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">mumbles</span> title, msg, successed </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">system</span> <span style="color:#996600;">"mumbles-send -g bianca.cerego.co.jp <span style="color:#000099;">\"</span>#{title}<span style="color:#000099;">\"</span> <span style="color:#000099;">\"</span>#{msg}<span style="color:#000099;">\"</span>"</span> <span style="color:#9966CC; font-weight:bold;">unless</span> successed</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#CC0066; font-weight:bold;">system</span> <span style="color:#996600;">"mumbles-send <span style="color:#000099;">\"</span>#{title}<span style="color:#000099;">\"</span> <span style="color:#000099;">\"</span>#{msg}<span style="color:#000099;">\"</span>"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; Autotest.<span style="color:#9900CC;">add_hook</span> :red <span style="color:#9966CC; font-weight:bold;">do</span> |at|</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; errors = at.<span style="color:#9900CC;">results</span>.<span style="color:#9900CC;">slice</span><span style="color:#006600; font-weight:bold;">&#40;</span>/<span style="color:#006600; font-weight:bold;">&#40;</span>\d+<span style="color:#006600; font-weight:bold;">&#41;</span>\s+tests,\s*<span style="color:#006600; font-weight:bold;">&#40;</span>\d+<span style="color:#006600; font-weight:bold;">&#41;</span>\s+assertions,\s*<span style="color:#006600; font-weight:bold;">&#40;</span>\d+<span style="color:#006600; font-weight:bold;">&#41;</span>\s+failures,\s*<span style="color:#006600; font-weight:bold;">&#40;</span>\d+<span style="color:#006600; font-weight:bold;">&#41;</span>\s+errors/<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; mumbles <span style="color:#996600;">"TESTS FAILED"</span>, errors, <span style="color:#0000FF; font-weight:bold;">false</span> </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; Autotest.<span style="color:#9900CC;">add_hook</span> :green <span style="color:#9966CC; font-weight:bold;">do</span> |at|</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#008000; font-style:italic;">#res = at.results[/\d+ tests.*$/]</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; res = at.<span style="color:#9900CC;">results</span>.<span style="color:#9900CC;">scan</span><span style="color:#006600; font-weight:bold;">&#40;</span>/Finished.*failures/m<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">to_s</span>.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span>/\e\<span style="color:#006600; font-weight:bold;">&#91;</span>32m/,''<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; mumbles <span style="color:#996600;">"TESTS PASSED"</span>, res, <span style="color:#0000FF; font-weight:bold;">true</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>これで開発マシンと開発サーバが別のマシンでも、快適な autotest 環境を構築できますね。MacBook で autotest を走らせると、開発の手が止まる程遅くなるからな...</p>
<p>ちなみに Growl では notification に緊急度のようなのを付与できて、MacBook ではそれを元に成功と失敗で色分けしたりしてましたが、Mumbles から Growl には title と description しか送れないようです。</p>
<p>上記の設定では、テスト失敗時にだけ Growl に通知して、Growl 側の設定で Mumbles からの通知の緊急度を上げています。</p>
]]></content:encoded>
			<wfw:commentRss>http://railspress.matake.jp/notify-autotest-result-from-ubuntu-to-macbook/feed</wfw:commentRss>
		</item>
		<item>
		<title>「Rubyでどう書く？」に答えてみます。Part.1</title>
		<link>http://railspress.matake.jp/how_to_implement_in_ruby_part1</link>
		<comments>http://railspress.matake.jp/how_to_implement_in_ruby_part1#comments</comments>
		<pubDate>Sun, 21 Sep 2008 11:12:57 +0000</pubDate>
		<dc:creator>NOV</dc:creator>
		
		<category><![CDATA[Builder]]></category>

		<category><![CDATA[連載]]></category>

		<guid isPermaLink="false">http://railspress.matake.jp/?p=85</guid>
		<description><![CDATA[Rubyでどう書く？：連続した数列を範囲形式にまとめたい - builder by ZDNet Japanの課題に答えてみました。課題の内容はZDNetの記事を見てください。
他の人の回答はすごい短いんだけど、なんかよく読みづらかったので、僕は Array のメソッドとして separate_to_range というのを用意して、内部的に Range を使うようにして実装してみました。返ってくる値も Range を含んだ Array なので、扱いやすいはず。
ただ、ちょっと長過ぎるかなぁ？
PLAIN TEXT
LANG : RUBY




class Array


&#160; def range_or_fixnum&#40;first,last&#41;


&#160; &#160; first &#60;last ? Range.new&#40;first,last&#41; : first


&#160; end


&#160; 


&#160; def separate_to_range


&#160; &#160; tmp_arr = &#91;&#93;


&#160; &#160; inject&#40;&#91;&#93;&#41; do &#124;result, value&#124;


&#160; &#160; &#160; tmp_arr &#60;&#60;value


&#160; &#160; &#160; if tmp_arr.last - tmp_arr.first&#62; tmp_arr.size - 1


&#160; [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://builder.japan.zdnet.com/sp/ruby-doukaku-panel/story/0,3800086254,20369264,00.htm" title="Rubyでどう書く？：連続した数列を範囲形式にまとめたい - builder by ZDNet Japan" target="_blank">Rubyでどう書く？：連続した数列を範囲形式にまとめたい - builder by ZDNet Japan</a>の課題に答えてみました。課題の内容はZDNetの記事を見てください。</p>
<p>他の人の回答はすごい短いんだけど、なんかよく読みづらかったので、僕は Array のメソッドとして separate_to_range というのを用意して、内部的に Range を使うようにして実装してみました。返ってくる値も Range を含んだ Array なので、扱いやすいはず。</p>
<p>ただ、ちょっと長過ぎるかなぁ？</p>
<div class="igBar"><span id="lruby-51"><a href="#" onclick="javascript:showPlainTxt('ruby-51'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : RUBY</span>
<div id="ruby-51">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">class</span> <span style="color:#CC0066; font-weight:bold;">Array</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> range_or_fixnum<span style="color:#006600; font-weight:bold;">&#40;</span>first,last<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; first &lt;last ? Range.<span style="color:#9900CC;">new</span><span style="color:#006600; font-weight:bold;">&#40;</span>first,last<span style="color:#006600; font-weight:bold;">&#41;</span> : first</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; </div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> separate_to_range</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; tmp_arr = <span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; inject<span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span><span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">do</span> |result, value|</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; tmp_arr &lt;&lt;value</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">if</span> tmp_arr.<span style="color:#9900CC;">last</span> - tmp_arr.<span style="color:#9900CC;">first</span>&gt; tmp_arr.<span style="color:#9900CC;">size</span> - <span style="color:#006666;color:#800000;">1</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; result &lt;&lt;range_or_fixnum<span style="color:#006600; font-weight:bold;">&#40;</span> tmp_arr.<span style="color:#9900CC;">first</span>, tmp_arr<span style="color:#006600; font-weight:bold;">&#91;</span>tmp_arr.<span style="color:#9900CC;">size</span>-<span style="color:#006666;color:#800000;">2</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; tmp_arr = <span style="color:#006600; font-weight:bold;">&#91;</span>value<span style="color:#006600; font-weight:bold;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; result &lt;&lt;range_or_fixnum<span style="color:#006600; font-weight:bold;">&#40;</span> tmp_arr.<span style="color:#9900CC;">first</span>, tmp_arr.<span style="color:#9900CC;">last</span> <span style="color:#006600; font-weight:bold;">&#41;</span> <span style="color:#9966CC; font-weight:bold;">if</span> value == last</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; result</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>使うときはこんな感じです。</p>
<div class="igBar"><span id="lruby-52"><a href="#" onclick="javascript:showPlainTxt('ruby-52'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : RUBY</span>
<div id="ruby-52">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">arr = <span style="color:#996600;">"0 1 2 5 6 10"</span>.<span style="color:#CC0066; font-weight:bold;">split</span><span style="color:#006600; font-weight:bold;">&#40;</span>/\s+/<span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#9900CC;">map</span><span style="color:#006600; font-weight:bold;">&#123;</span>|i| i.<span style="color:#9900CC;">to_i</span><span style="color:#006600; font-weight:bold;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0066; font-weight:bold;">puts</span> arr.<span style="color:#9900CC;">separate_to_range</span>.<span style="color:#9900CC;">join</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">", "</span><span style="color:#006600; font-weight:bold;">&#41;</span>.<span style="color:#CC0066; font-weight:bold;">gsub</span><span style="color:#006600; font-weight:bold;">&#40;</span><span style="color:#996600;">".."</span>, <span style="color:#996600;">"-"</span><span style="color:#006600; font-weight:bold;">&#41;</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://railspress.matake.jp/how_to_implement_in_ruby_part1/feed</wfw:commentRss>
		</item>
		<item>
		<title>Rails2.1.1リリース、Rails2.2(beta)もそろそろ！</title>
		<link>http://railspress.matake.jp/rails211_released_rails22_beta_is_quite_close</link>
		<comments>http://railspress.matake.jp/rails211_released_rails22_beta_is_quite_close#comments</comments>
		<pubDate>Sat, 06 Sep 2008 18:32:26 +0000</pubDate>
		<dc:creator>NOV</dc:creator>
		
		<category><![CDATA[Rails2.1]]></category>

		<category><![CDATA[Rails2.2]]></category>

		<category><![CDATA[リリース]]></category>

		<guid isPermaLink="false">http://railspress.matake.jp/?p=83</guid>
		<description><![CDATA[滝内さんのブログ経由で知りましたが、Rails 2.1.1がリリースされたんですね。
ChangeLogを見る限り、2.1.0で動いてたアプリは問題なく動く感じだったので、MacBookのRailsをバージョンアップしてみました。
Resumyの開発版は、問題なく動作しました。
次のリリースであるRails 2.2 betaも、もうそろそろらしいです。
Rails2.2では、スレッドセーフになったりLocalizationがしやすくなったりするらしいです。
楽しみ！
Rails 2.1.1 参考記事：
Rails-2.1.1にアップデートしました - Hello, world! - s21g
Riding Rails: Rails 2.1.1: Lots of bug fixes
Rails 2.2 参考記事：
Simple Localization in Rails 2.2 -  almost effortless
スレッドセーフRuby on Railsが意味することは、Rails 2.2でスレッドセーフ &#124; エンタープライズ &#124; マイコミジャーナル
]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.s21g.com/takiuchi" target="_blank">滝内さんのブログ</a>経由で知りましたが、Rails 2.1.1がリリースされたんですね。</p>
<p>ChangeLogを見る限り、2.1.0で動いてたアプリは問題なく動く感じだったので、MacBookのRailsをバージョンアップしてみました。</p>
<p>Resumyの開発版は、問題なく動作しました。</p>
<p>次のリリースであるRails 2.2 betaも、もうそろそろらしいです。<br />
Rails2.2では、スレッドセーフになったりLocalizationがしやすくなったりするらしいです。</p>
<p>楽しみ！</p>
<p>Rails 2.1.1 参考記事：<br />
<a href="http://blog.s21g.com/articles/865" title="Rails-2.1.1にアップデートしました - Hello, world! - s21g" target="_blank">Rails-2.1.1にアップデートしました - Hello, world! - s21g</a><br />
<a href="http://weblog.rubyonrails.org/2008/9/5/rails-2-1-1-lots-of-bug-fixes" title="Riding Rails: Rails 2.1.1: Lots of bug fixes" target="_blank">Riding Rails: Rails 2.1.1: Lots of bug fixes</a></p>
<p>Rails 2.2 参考記事：<br />
<a href="http://almosteffortless.com/2008/07/21/simple-localization-in-rails-22/" title="Simple Localization in Rails 2.2 -  almost effortless" target="_blank">Simple Localization in Rails 2.2 -  almost effortless</a><br />
<a href="http://journal.mycom.co.jp/news/2008/08/18/019/index.html" title="スレッドセーフRuby on Railsが意味することは、Rails 2.2でスレッドセーフ | エンタープライズ | マイコミジャーナル" target="_blank">スレッドセーフRuby on Railsが意味することは、Rails 2.2でスレッドセーフ | エンタープライズ | マイコミジャーナル</a></p>
]]></content:encoded>
			<wfw:commentRss>http://railspress.matake.jp/rails211_released_rails22_beta_is_quite_close/feed</wfw:commentRss>
		</item>
		<item>
		<title>外部HTMLをAjaxで読みこんで表示するAjaxViewer</title>
		<link>http://railspress.matake.jp/ajax_viewer</link>
		<comments>http://railspress.matake.jp/ajax_viewer#comments</comments>
		<pubDate>Sat, 06 Sep 2008 12:18:24 +0000</pubDate>
		<dc:creator>NOV</dc:creator>
		
		<category><![CDATA[Ajax]]></category>

		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://railspress.matake.jp/?p=82</guid>
		<description><![CDATA[最近ようやくJavaScriptの勉強を始めました。
いままではJavaScriptのオブジェクト指向的な部分が全く分かっていなかったのですが、ようやく少し分かり始めた気がします。
今日はJavaScriptの勉強を兼ねて、外部のHTMLを非同期に読み込んで指定されたDOM要素の中に吐き出すスクリプトを書いてみました。元々「京の路（MovableType）」のサイドバー再構築の負荷を軽減するため、別ファイルに書き出したサイドバーをAjaxで読み込んでいたのですが、今回書いたスクリプトはそこで使っていたスクリプトをオブジェクト指向的に書き直したものです。
「こういう風に書くともっとスマートだよ」とか、アドバイスや感想などいただけるとうれしいです！
PLAIN TEXT
LANG : JAVASCRIPT




var AjaxViewer = function&#40; id &#41; &#123;


&#160; this.initialize&#40; id &#41;;


&#125;;


&#160;


AjaxViewer.prototype = &#123;


&#160; /* デフォルトでは ajax_viewer_id を書き換える */


&#160; id : 'ajax_viewer_id',


&#160; 


&#160; initialize : function&#40; id &#41; &#123;


&#160; &#160; /* 引数で id が与えられたら this.id を変更 */


&#160; &#160; if &#40; id &#41; this.id = id;


&#160; &#160; 


&#160; &#160; /* XMLHttpRequest を生成 */


&#160; &#160; if [...]]]></description>
			<content:encoded><![CDATA[<p>最近ようやくJavaScriptの勉強を始めました。<br />
いままではJavaScriptのオブジェクト指向的な部分が全く分かっていなかったのですが、ようやく少し分かり始めた気がします。</p>
<p>今日はJavaScriptの勉強を兼ねて、外部のHTMLを非同期に読み込んで指定されたDOM要素の中に吐き出すスクリプトを書いてみました。元々「<a href="http://blog.matake.jp">京の路</a>（MovableType）」のサイドバー再構築の負荷を軽減するため、別ファイルに書き出したサイドバーをAjaxで読み込んでいたのですが、今回書いたスクリプトはそこで使っていたスクリプトをオブジェクト指向的に書き直したものです。</p>
<p>「こういう風に書くともっとスマートだよ」とか、アドバイスや感想などいただけるとうれしいです！</p>
<div class="igBar"><span id="ljavascript-55"><a href="#" onclick="javascript:showPlainTxt('javascript-55'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : JAVASCRIPT</span>
<div id="javascript-55">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> AjaxViewer = <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span> id <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">initialize</span><span style="color: #66cc66;">&#40;</span> id <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">AjaxViewer.<span style="color: #006600;">prototype</span> = <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #009900; font-style: italic;">/* デフォルトでは ajax_viewer_id を書き換える */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; id : <span style="color: #3366CC;">'ajax_viewer_id'</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; initialize : <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span> id <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">/* 引数で id が与えられたら this.id を変更 */</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span> id <span style="color: #66cc66;">&#41;</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">id</span> = id;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">/* XMLHttpRequest を生成 */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span> window.<span style="color: #006600;">XMLHttpRequest</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// Firefox, Safari, IE7</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">request</span> = <span style="color: #003366; font-weight: bold;">new</span> XMLHttpRequest<span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// IE 6.0 以上</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">request</span> = <span style="color: #003366; font-weight: bold;">new</span> ActiveXObject<span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">'Msxml2.XMLHTTP'</span> <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #000066; font-weight: bold;">catch</span><span style="color: #66cc66;">&#40;</span> e <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900; font-style: italic;">// IE 5.5 以下</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">request</span> = <span style="color: #003366; font-weight: bold;">new</span> ActiveXObject<span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">'Microsoft.XMLHTTP'</span> <span style="color: #66cc66;">&#41;</span>; </div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #000066; font-weight: bold;">catch</span><span style="color: #66cc66;">&#40;</span> e <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">request</span> = <span style="color: #003366; font-weight: bold;">null</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#125;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; escape_for_safari : <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span> low_text <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">/**</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">&nbsp; &nbsp; &nbsp;* Safari の文字化対応</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">&nbsp; &nbsp; &nbsp;* （参考：http://kawa.at.webry.info/200511/article_9.html）</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">&nbsp; &nbsp; &nbsp;*/</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span> navigator.<span style="color: #006600;">appVersion</span>.<span style="color: #006600;">indexOf</span><span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">'KHTML'</span> <span style="color: #66cc66;">&#41;</span>&gt; -<span style="color: #CC0000;color:#800000;">1</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> escaped_text = escape<span style="color: #66cc66;">&#40;</span> low_text <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span> escaped_text.<span style="color: #006600;">indexOf</span><span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">'%u'</span> <span style="color: #66cc66;">&#41;</span> &lt;<span style="color: #CC0000;color:#800000;">0</span> &amp;&amp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;escaped_text.<span style="color: #006600;">indexOf</span><span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">'%'</span>&nbsp; <span style="color: #66cc66;">&#41;</span>&gt; -<span style="color: #CC0000;color:#800000;">1</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> decodeURIComponent<span style="color: #66cc66;">&#40;</span> escaped_text <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> low_text;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#125;</span>,</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; callback : <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span> self <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> area = document.<span style="color: #006600;">getElementById</span><span style="color: #66cc66;">&#40;</span> self.<span style="color: #006600;">id</span> <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; area.<span style="color: #006600;">innerHTML</span> = self.<span style="color: #006600;">escape_for_safari</span><span style="color: #66cc66;">&#40;</span> self.<span style="color: #006600;">request</span>.<span style="color: #006600;">responseText</span> <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#125;</span>,</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; load : <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span> url <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span> !<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">request</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">request</span>.<span style="color: #000066;">open</span><span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">'GET'</span>, url, <span style="color: #003366; font-weight: bold;">true</span> <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #009900; font-style: italic;">/**</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">&nbsp; &nbsp; &nbsp;* 内部で定義された function() では this にアクセスできないので</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">&nbsp; &nbsp; &nbsp;* this の代わりに self という変数を用意する</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">&nbsp; &nbsp; &nbsp;* （参考：http://d.hatena.ne.jp/cloned/20070301）</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">&nbsp; &nbsp; &nbsp;*/</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> self = <span style="color: #000066; font-weight: bold;">this</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">request</span>.<span style="color: #006600;">onreadystatechange</span> = <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #66cc66;">&#40;</span> self.<span style="color: #006600;">request</span>.<span style="color: #006600;">readyState</span> == <span style="color: #CC0000;color:#800000;">4</span> &amp;&amp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;self.<span style="color: #006600;">request</span>.<span style="color: #000066;">status</span>&nbsp; &nbsp; &nbsp;== <span style="color: #CC0000;color:#800000;">200</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; self.<span style="color: #006600;">callback</span><span style="color: #66cc66;">&#40;</span> self <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">request</span>.<span style="color: #006600;">send</span><span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">''</span> <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color: #66cc66;">&#125;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #66cc66;">&#125;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>使い方は以下の通り。<br />
あらかじめ外部HTMLを吐き出すために、指定したid要素（ここでは'menu'）を持つdivを用意しておいてください。</p>
<div class="igBar"><span id="ljavascript-56"><a href="#" onclick="javascript:showPlainTxt('javascript-56'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : JAVASCRIPT</span>
<div id="javascript-56">
<div class="javascript">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">/* idを引数で渡す */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #003366; font-weight: bold;">var</span> menu = <span style="color: #003366; font-weight: bold;">new</span> AjaxViewer<span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">'menu'</span> <span style="color: #66cc66;">&#41;</span>;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color: #009900; font-style: italic;">/* urlを引数で渡す */</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">menu.<span style="color: #006600;">load</span><span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">'http://blog.matake.jp/menu.html'</span> <span style="color: #66cc66;">&#41;</span>; </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://railspress.matake.jp/ajax_viewer/feed</wfw:commentRss>
		</item>
		<item>
		<title>acts_as_bits PluginとRails 2.1のDirty tracking &amp; Partial Updatesの相性が最悪</title>
		<link>http://railspress.matake.jp/acts_as_bits_vs_rails21partial_updates</link>
		<comments>http://railspress.matake.jp/acts_as_bits_vs_rails21partial_updates#comments</comments>
		<pubDate>Thu, 19 Jun 2008 17:46:05 +0000</pubDate>
		<dc:creator>NOV</dc:creator>
		
		<category><![CDATA[ActiveRecord]]></category>

		<category><![CDATA[ActsAsBits]]></category>

		<category><![CDATA[ActsAsSearchable]]></category>

		<category><![CDATA[Plugin]]></category>

		<category><![CDATA[Rails2.1]]></category>

		<category><![CDATA[バグ]]></category>

		<guid isPermaLink="false">http://railspress.matake.jp/?p=78</guid>
		<description><![CDATA[Rails 2.1系ではいくつか新機能が加わっていますが、「Partial Updates」もその一つです。
「Partial Updates」では、「Dirty tracking（Dirty Object）」というActiveRecordのモデルのattributesが変更されたかどうかをチェックする機能を使って、「変更された値のみをSQLに含める」ことを実現しています。
つまり、以下のようなコードを書いていても、実際に@personに変更が無ければ更新しないし、変更があった時でも変更点のみをSQLにしてくれるのです。
すばらしい！！
PLAIN TEXT
LANG : RUBY




def edit


&#160; @person = params&#91;:person&#93;


&#160; @person.save!


end 






ところで、こいつは普通に使ってる分には本当に便利なのですが、どうも acts_as_bits と一緒には使えないっぽいです。
いま acts_as_bits を使った以下のようなモデルがあるとすると、
PLAIN TEXT
LANG : RUBY




class Setting


&#160; acts_as_bits :operations =&#62; &#91;:s1, :s2, :s3&#93;


end 






こいつの変更が Dirty tracking で把握できていないようです。

PLAIN TEXT
LANG : RUBY




@setting = Setting.find&#40;:first&#41;


puts @setting.operations # =&#62; 111


&#160;


@setting.s1 = false


puts @setting.operations # =&#62; 011


&#160;


@setting.changed? # =&#62; false


@setting.save! # =&#62; changed? が [...]]]></description>
			<content:encoded><![CDATA[<p>Rails 2.1系ではいくつか新機能が加わっていますが、「Partial Updates」もその一つです。</p>
<p>「Partial Updates」では、「Dirty tracking（Dirty Object）」というActiveRecordのモデルのattributesが変更されたかどうかをチェックする機能を使って、「変更された値のみをSQLに含める」ことを実現しています。</p>
<p>つまり、以下のようなコードを書いていても、実際に@personに変更が無ければ更新しないし、変更があった時でも変更点のみをSQLにしてくれるのです。</p>
<p>すばらしい！！</p>
<div class="igBar"><span id="lruby-62"><a href="#" onclick="javascript:showPlainTxt('ruby-62'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : RUBY</span>
<div id="ruby-62">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">def</span> edit</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; @person = params<span style="color:#006600; font-weight:bold;">&#91;</span>:person<span style="color:#006600; font-weight:bold;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; @person.<span style="color:#9900CC;">save</span>!</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>ところで、こいつは普通に使ってる分には本当に便利なのですが、どうも acts_as_bits と一緒には使えないっぽいです。</p>
<p>いま acts_as_bits を使った以下のようなモデルがあるとすると、</p>
<div class="igBar"><span id="lruby-63"><a href="#" onclick="javascript:showPlainTxt('ruby-63'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : RUBY</span>
<div id="ruby-63">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">class</span> Setting</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; acts_as_bits :operations =&gt; <span style="color:#006600; font-weight:bold;">&#91;</span>:s1, :s2, :s3<span style="color:#006600; font-weight:bold;">&#93;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>こいつの変更が Dirty tracking で把握できていないようです。</p>
<p><span id="more-78"></span></p>
<div class="igBar"><span id="lruby-64"><a href="#" onclick="javascript:showPlainTxt('ruby-64'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : RUBY</span>
<div id="ruby-64">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@setting = Setting.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>:first<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0066; font-weight:bold;">puts</span> @setting.<span style="color:#9900CC;">operations</span> <span style="color:#008000; font-style:italic;"># =&gt; 111</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@setting.<span style="color:#9900CC;">s1</span> = <span style="color:#0000FF; font-weight:bold;">false</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#CC0066; font-weight:bold;">puts</span> @setting.<span style="color:#9900CC;">operations</span> <span style="color:#008000; font-style:italic;"># =&gt; 011</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@setting.<span style="color:#9900CC;">changed</span>? <span style="color:#008000; font-style:italic;"># =&gt; false</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@setting.<span style="color:#9900CC;">save</span>! <span style="color:#008000; font-style:italic;"># =&gt; changed? が false なので Update は実行されない。 </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>ActiveRecord::Dirty#save_with_dirty および ActiveRecord::Dirty#save_with_dirty! との相性が悪いのかな？と思って、save_without_dirty とかしてみたけど、それもどうもダメっぽいです。</p>
<div class="igBar"><span id="lruby-65"><a href="#" onclick="javascript:showPlainTxt('ruby-65'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : RUBY</span>
<div id="ruby-65">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">@setting.<span style="color:#9900CC;">save_without_dirty</span> <span style="color:#008000; font-style:italic;"># =&gt; これもどうもうまく行かなかった。 </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>本当は acts_as_bits での更新でも changed? => true になるようにしたいですが、とりあえずの暫定処置として以下のように acts_as_bits を使うモデルだけ、Partial Updates をオフにしておきました。</p>
<p>とりあえずこれで changed? が false でも更新されます。<br />
ActiveRecordのモデルが更新されない！！なんて現象にはまったら、とりあえず self.partial_updates = false で対処はできます。（効率悪いけど）</p>
<div class="igBar"><span id="lruby-66"><a href="#" onclick="javascript:showPlainTxt('ruby-66'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : RUBY</span>
<div id="ruby-66">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">class</span> Setting</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">partial_updates</span> = <span style="color:#0000FF; font-weight:bold;">false</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; acts_as_bits :operations =&gt; <span style="color:#006600; font-weight:bold;">&#91;</span>:s1, :s2, :s3<span style="color:#006600; font-weight:bold;">&#93;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>それにしても、acts_as_searchable にしても acts_as_bits にしても、見事に Rails 2.1 の ActiveRecord まわりの変更にやられてますね。<br />
変更大きいし、Plugin 側もずいぶん更新されてないからなぁ...</p>
]]></content:encoded>
			<wfw:commentRss>http://railspress.matake.jp/acts_as_bits_vs_rails21partial_updates/feed</wfw:commentRss>
		</item>
		<item>
		<title>単一テーブル継承 (Single Table Inheritance) の上手な扱い方</title>
		<link>http://railspress.matake.jp/efficient_single_table_inheritance</link>
		<comments>http://railspress.matake.jp/efficient_single_table_inheritance#comments</comments>
		<pubDate>Sat, 14 Jun 2008 13:53:12 +0000</pubDate>
		<dc:creator>NOV</dc:creator>
		
		<category><![CDATA[ActiveRecord]]></category>

		<category><![CDATA[Single Table Inheritance]]></category>

		<category><![CDATA[ノウハウ]]></category>

		<guid isPermaLink="false">http://railspress.matake.jp/?p=77</guid>
		<description><![CDATA[Railsの単一テーブル継承 (Single Table Inheritance) を使うと、ActiveRecordではtypeカラムがnilでないオブジェクトのクラスはtypeを元に判定されます。
単一テーブル継承 (Single Table Inheritance) を使うには、テーブル定義時にtypeというカラムを定義します。
PLAIN TEXT
LANG : RUBY




class CreatePeople &#60;ActiveRecord::Migration


&#160; def self.up


&#160; &#160; create_table :people do &#124;t&#124;


&#160; &#160; &#160; t.column :name, :string


&#160; &#160; &#160; &#160; :


&#160; &#160; &#160; t.column :type, :string


&#160; &#160; end


&#160; end


&#160;


&#160; def self.down


&#160; &#160; drop_table :people


&#160; end


end 






ここでpeopleテーブルに対応したPersonというベースとなくクラスを以下のように定義したとします。
PLAIN TEXT
LANG : RUBY




class Person &#60;ActiveRecord::Base


&#160; # edit here


end 






こうするとPersonを継承したモデルは全てpeopleテーブルに保存され、typeカラムに各モデルのクラス名が入ります。
（単一テーブル継承の詳しい使い方はこちらをご覧ください：「Railsで単一テーブル継承（Single Table [...]]]></description>
			<content:encoded><![CDATA[<p>Railsの単一テーブル継承 (Single Table Inheritance) を使うと、ActiveRecordではtypeカラムがnilでないオブジェクトのクラスはtypeを元に判定されます。</p>
<p>単一テーブル継承 (Single Table Inheritance) を使うには、テーブル定義時にtypeというカラムを定義します。</p>
<div class="igBar"><span id="lruby-72"><a href="#" onclick="javascript:showPlainTxt('ruby-72'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : RUBY</span>
<div id="ruby-72">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">class</span> CreatePeople &lt;ActiveRecord::Migration</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">up</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; create_table :people <span style="color:#9966CC; font-weight:bold;">do</span> |t|</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; t.<span style="color:#9900CC;">column</span> :name, :<span style="color:#CC0066; font-weight:bold;">string</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; &nbsp; :</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; &nbsp; t.<span style="color:#9900CC;">column</span> :type, :<span style="color:#CC0066; font-weight:bold;">string</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> <span style="color:#0000FF; font-weight:bold;">self</span>.<span style="color:#9900CC;">down</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; drop_table :people</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>ここでpeopleテーブルに対応したPersonというベースとなくクラスを以下のように定義したとします。</p>
<div class="igBar"><span id="lruby-73"><a href="#" onclick="javascript:showPlainTxt('ruby-73'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : RUBY</span>
<div id="ruby-73">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">class</span> Person &lt;ActiveRecord::Base</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#008000; font-style:italic;"># edit here</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>こうするとPersonを継承したモデルは全てpeopleテーブルに保存され、typeカラムに各モデルのクラス名が入ります。</p>
<p>（単一テーブル継承の詳しい使い方はこちらをご覧ください：「<a href="http://blog.matake.jp/archives/railssingle_table_inherit.html" title="Railsで単一テーブル継承（Single Table Inheritance） | 京の路" target="_blank">Railsで単一テーブル継承（Single Table Inheritance） | 京の路</a>」）</p>
<p><span id="more-77"></span></p>
<p>ここで、実際には利用しない中間クラスを挟むと、Personのサブクラスへのアクセスをそのクラスに集中させることで、各サブクラスのクラスを意識することなく扱うことができるようになります。</p>
<p>例えばExtendedPersonクラスを中間クラスとして挟み、ExtendedPersonを継承したMale / Femaleというモデルを定義します。</p>
<div class="igBar"><span id="lruby-74"><a href="#" onclick="javascript:showPlainTxt('ruby-74'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : RUBY</span>
<div id="ruby-74">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">class</span> Student &lt;Person</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#008000; font-style:italic;"># edit here</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">class</span> MaleStudent &lt;Student</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> call_name</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#996600;">"#{name}くん"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">class</span> FemaleStudent &lt;Student</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">def</span> call_name</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; &nbsp; <span style="color:#996600;">"#{name}さん"</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; <span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>こうすると、以下のようにMale / Femaleを意識することなく、これらのインスタンスを扱えます。</p>
<div class="igBar"><span id="lruby-75"><a href="#" onclick="javascript:showPlainTxt('ruby-75'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : RUBY</span>
<div id="ruby-75">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">MaleStudent.<span style="color:#9900CC;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span>:name =&gt; <span style="color:#996600;">"タロウ"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">MaleStudent.<span style="color:#9900CC;">create</span><span style="color:#006600; font-weight:bold;">&#40;</span>:name =&gt; <span style="color:#996600;">"ハナコ"</span><span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">students = Student.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>:all<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">students.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> |student|</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; student.<span style="color:#9900CC;">call_name</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;"># =&gt;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;">#&nbsp; タロウくん</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#008000; font-style:italic;">#&nbsp; ハナコさん </span></div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>もうこんなことしなくていい。</p>
<div class="igBar"><span id="lruby-76"><a href="#" onclick="javascript:showPlainTxt('ruby-76'); return false;">PLAIN TEXT</a></span></div>
<div class="syntax_hilite"><span class="langName">LANG : RUBY</span>
<div id="ruby-76">
<div class="ruby">
<ol>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">male_students = MaleStudent.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>:all<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">female_students = FemaleStudent.<span style="color:#9900CC;">find</span><span style="color:#006600; font-weight:bold;">&#40;</span>:all<span style="color:#006600; font-weight:bold;">&#41;</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">male_students.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> |male_student|</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; male_student.<span style="color:#9900CC;">call_name</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span></div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp;</div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">female_students.<span style="color:#9900CC;">each</span> <span style="color:#9966CC; font-weight:bold;">do</span> |female_student|</div>
</li>
<li style="font-family: 'Courier New', Courier, monospace; color: black; font-weight: normal; font-style: normal;color:#3A6A8B;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;">&nbsp; female_student.<span style="color:#9900CC;">call_name</span></div>
</li>
<li style="font-weight: bold;color:#26536A;">
<div style="font-family: 'Courier New', Courier, monospace; font-weight: normal;"><span style="color:#9966CC; font-weight:bold;">end</span> </div>
</li>
</ol>
</div>
</div>
</div>
<p></p>
<p>単一テーブル継承で多数のクラスを１つのテーブルに集中させる場合は、これでソースがかなり奇麗になりますよ♪</p>
]]></content:encoded>
			<wfw:commentRss>http://railspress.matake.jp/efficient_single_table_inheritance/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
