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

<channel>
	<title>Aerialarts &#187; ruby</title>
	<atom:link href="http://aerial.st/tags/ruby/feed" rel="self" type="application/rss+xml" />
	<link>http://aerial.st</link>
	<description></description>
	<lastBuildDate>Thu, 22 Jul 2010 13:00:53 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/tags/ruby/feed" />
		<item>
		<title>MeCabをrubyから使ってみる</title>
		<link>http://aerial.st/archive/2010/07/22/mecab-ruby</link>
		<comments>http://aerial.st/archive/2010/07/22/mecab-ruby#comments</comments>
		<pubDate>Wed, 21 Jul 2010 22:06:46 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[開発]]></category>
		<category><![CDATA[mecab]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=715</guid>
		<description><![CDATA[インストール まずMacPortsで本体と辞書を入れて読み込む辞書を設定する。 $ sudo port install mecab $ sudo port install mecab-ipadic-utf8 $ sudo vi /opt/local/etc/mecabrc # 編集内容は下記を参照 mecabrcは次のように書き換える。 dicdir = /opt/local/lib/mecab/dic/ipadic-utf8 次にrubyバインディングのmecab-rubyをインストールする。 ソースを SourceForge から落としてきて展開し、そのディレクトリで以下を実行。 $ ruby extract.rb $ vi Makefile # 編集内容は下記を参照 $ make $ ruby test.rb # これでエラーが出なければ問題無し $ sudo make install Makefileは次のように/opt/local/libを読むように修正を加える。 LIBS = -lstdc++ -ldl -lobjc -L/usr/local/lib -L/opt/local/lib -lmecab 参考： [...]]]></description>
		<wfw:commentRss>http://aerial.st/archive/2010/07/22/mecab-ruby/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2010/07/22/mecab-ruby" />
	</item>
		<item>
		<title>モジュールでnamed_scopeを追加</title>
		<link>http://aerial.st/archive/2010/07/07/named_scope_from_module</link>
		<comments>http://aerial.st/archive/2010/07/07/named_scope_from_module#comments</comments>
		<pubDate>Tue, 06 Jul 2010 15:38:38 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[開発]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=710</guid>
		<description><![CDATA[モデルの機能ごとにモジュールにまとめてあとからまとめてincludeしたいというときに、どうせならその機能のために用意したちょっと複雑なnamed_scopeも同じように外に出してしまいたい。 そんな場合にはincludedとclass_evalを使う。 class Message < ActiveRecord::Base include Extensions::Search end module Extensions module Search def self.included(mod) mod.class_eval do named_scope :name_like, lambda { &#124;arg&#124; { :conditions => ["name LIKE ?", "%%arg%%"] }} end end end end > Message.name_like("ob").first.name #=> "Bob" named_scopeも結局はクラスメソッド。この方法はnamed_scope以外にも利用できる。]]></description>
		<wfw:commentRss>http://aerial.st/archive/2010/07/07/named_scope_from_module/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2010/07/07/named_scope_from_module" />
	</item>
		<item>
		<title>テスト用oauth_callback</title>
		<link>http://aerial.st/archive/2010/06/19/oauth-callback-for-test</link>
		<comments>http://aerial.st/archive/2010/06/19/oauth-callback-for-test#comments</comments>
		<pubDate>Sat, 19 Jun 2010 06:42:10 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[開発]]></category>
		<category><![CDATA[oauth]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=708</guid>
		<description><![CDATA[oauth gem(0.4.0)のoauth_callbackでちょっとはまったのでメモ。 /rubyを参考に、Twitterに登録しているコールバックURLとは別にテスト用のURL（が使いたかったので、いろいろ試してみた結果、次で動いた。 test_callback = "http://example.org/login" request_token = consumer.get_request_token(:oauth_callback => test_callback) aurhorize_url = request_token.authorize_url(:oauth_callback => test_callback) なんで両方で指定しなければならないのかは謎。]]></description>
		<wfw:commentRss>http://aerial.st/archive/2010/06/19/oauth-callback-for-test/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2010/06/19/oauth-callback-for-test" />
	</item>
		<item>
		<title>コマンドラインからWEBrickを起動</title>
		<link>http://aerial.st/archive/2010/06/10/webrick-starter</link>
		<comments>http://aerial.st/archive/2010/06/10/webrick-starter#comments</comments>
		<pubDate>Thu, 10 Jun 2010 10:20:23 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[開発]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=699</guid>
		<description><![CDATA[一時的に任意のディレクトリをHTTPサーバに公開したくなったので、WEBrickを起動するスクリプトを組んでみた。既存のものがある気がしなくはないけど、OptionParserの勉強という意味も含めて。 #!/usr/bin/env ruby require 'optparse' require 'webrick' include WEBrick # WEBrickを起動する際のオプションのデフォルト値 WebrickOptions = { :Port => 8000, :DocumentRoot => Dir::pwd, } OptionParser.new do &#124;opt&#124; # パース方法を設定する # オプションが指定されていた場合にブロックが評価される opt.on('-p', '--Port N', Integer) { &#124;v&#124; WebrickOptions[:Port] = v } opt.on('-d', '--DocumentRoot PATH') { &#124;v&#124; WebrickOptions[:DocumentRoot] = v } # 実際にパースを行う opt.parse!(ARGV) end # WEBrickを起動する s = [...]]]></description>
		<wfw:commentRss>http://aerial.st/archive/2010/06/10/webrick-starter/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2010/06/10/webrick-starter" />
	</item>
		<item>
		<title>名前空間付き定数対応のObject.cost_set</title>
		<link>http://aerial.st/archive/2010/05/20/object-nested-const-set</link>
		<comments>http://aerial.st/archive/2010/05/20/object-nested-const-set#comments</comments>
		<pubDate>Thu, 20 May 2010 01:26:45 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[開発]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=692</guid>
		<description><![CDATA[Object.const_getをハックした話 を参考に、Object.const_setもモジュールによる名前空間付き定数に対応させてみた。車輪の再発明をした気がしなくはないけど、そこは気にしない。 class Object def self.nested_const_get(name) stack = (name.is_a?(Array)) ? name : name.split("::") klass = Object while const = stack.shift klass = klass.const_get(const) end return klass end def self.nested_const_set(args = {}) args.each do &#124;name, value&#124; stack = (name.is_a?(Array)) ? name : name.to_s.split("::") last_const = stack.pop klass = nested_const_get(stack) klass.const_set(last_const, value) end end end 使い方は、 Object.nested_const_set("Foo::Bar" [...]]]></description>
		<wfw:commentRss>http://aerial.st/archive/2010/05/20/object-nested-const-set/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2010/05/20/object-nested-const-set" />
	</item>
		<item>
		<title>非同期処理にはWorkling</title>
		<link>http://aerial.st/archive/2010/03/28/workling-isfor-asynchronous-actions</link>
		<comments>http://aerial.st/archive/2010/03/28/workling-isfor-asynchronous-actions#comments</comments>
		<pubDate>Sun, 28 Mar 2010 11:01:01 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[開発]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[asynchronous]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[workling]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=686</guid>
		<description><![CDATA[Ajaxで非同期に処理をキックして、一定間隔でその進捗を確認して…というのを書く必要があったのでBackgrounDRbを試してみたら、どうも使いにくかった。理由としては、 MetaWorkerのサブクラスでワーカを実装したのに、MiddleMan.workerで呼び出したときにはRailsWorkerProxyにすり替わっている キューイングはしないのに、キューイングのためのテーブルを作らないとエラーが出る 名前が好きじゃない 引数のハッシュに:workerが妙に出て来て冗長 RSpecでテストしづらい（できなくはない） APIがよくわからない 後半はなんだか個人的な理由だけど、とにかく調べるのに疲れたわりに、あまり実り多い感じではなかった。 で、その代わりに見つけたのがWorkling。これは非同期に処理を呼び出すためのプラグイン。サンプルは、githubのREADMEの通りなので特に書かない。 キューイングサーバが必要ならばStarlingと組み合わせる。これはTwitterでの利用実績もあるらしい。 ただ注意する必要があるのは、進捗を保存しておくサンプルでWorkling::Return::Store::MemoryReturnStoreが利用されてるけど、これはそのプロセス内でのみ有効という点（ただのハッシュに値を保存してるだけ）。なので、バックグランドで進行中のところをAjaxで見に行く場合などにはその値にはアクセスできない。別途memcacheなどに値を保存しておく必要がある。 もしかしたらWorkling::Return::Store::StarlingReturnStoreを使えばいいのかもしれないけど、Starlingはキューイングのサーバだしなぁと詳しく把握しきれていなかったので、とりあえずmemcacheに直でアクセスするものを自分で追加した。 追記1 調べてみたところ、StarlingReturnStoreはキューと関係なくただ単にmemcacheをラップしてるだけ（より正確には、StarlingReturnStoreはWorkling::Clients::MemcacheQueueClientをラップしていて、こいつはMemCacheを使ってconfig/workling.ymlで設定されたmemcacheサーバと接続してデータのやりとりをしてる）。 なのでStarlingReturnStoreを使うのが手軽で、接続先memcacheサーバの設定をworkling.ymlに外出しできるので絶対的に便利。]]></description>
		<wfw:commentRss>http://aerial.st/archive/2010/03/28/workling-isfor-asynchronous-actions/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2010/03/28/workling-isfor-asynchronous-actions" />
	</item>
		<item>
		<title>rvm</title>
		<link>http://aerial.st/archive/2010/03/15/rvm</link>
		<comments>http://aerial.st/archive/2010/03/15/rvm#comments</comments>
		<pubDate>Sun, 14 Mar 2010 16:37:03 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[開発]]></category>
		<category><![CDATA[jruby]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rvm]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=663</guid>
		<description><![CDATA[基本はasakusa.rbによる記事を見ればok。 デフォルトのバージョンを指定する useサブコマンドに&#8211;defaultオプションを付ける。 rvm use 1.8.7 --default gemsetを使う rvm use 1.8.7 rvm gemset create rails222 rvm use 1.8.7%rails222 gem install rails -v 2.2.2 gem list help rvm help]]></description>
		<wfw:commentRss>http://aerial.st/archive/2010/03/15/rvm/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2010/03/15/rvm" />
	</item>
		<item>
		<title>Machinist+DatasetでFixture代替</title>
		<link>http://aerial.st/archive/2010/02/20/fixture-replacement</link>
		<comments>http://aerial.st/archive/2010/02/20/fixture-replacement#comments</comments>
		<pubDate>Fri, 19 Feb 2010 16:53:45 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[開発]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[test]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=625</guid>
		<description><![CDATA[概要 Machinistは定義された条件下でテストデータを生成するプラグイン・gem。 DatasetはRubyのコードで記述したテストデータをDBに読み込むプラグイン・gem。 この2つを組み合わせることで（比較的）メンテナンスのしやすいfixtureの代替を構築することが可能になる。 流れとしては、Dataset上でMachinistを呼び出して複数のデータを生成して、それをDBに流し込むという感じ。 メリットは、 条件下でランダムなデータを生成してくれる（「特定のデータをfixture上に作って読み込む」というようなことも可能） リレーション先のデータも適宜生成してくれる（素敵！）。 デメリットは、 データがランダムなので、全条件を必ずカバーするのは苦手＆毎回同じデータが入ってくるとは限らない（回避できるかなぁ） fixtureに依存した書き方をしていると大幅な書き換えが必要かもしれない（レコード数によるテストなど。集計系では難しい…） 最終結果のコードをGithubにあげたので、そちらも参考に。 下準備 Machinist、Dataset、そして適当な文字列のデータを作ってくれるFakerをインストール・設定する。なおテストフレームワークにはRSpec on Railsを用いる。 YAMLに頼らないテストデータの作成を参考にさせていただきました。 Machinist $ cd RAILS_ROOT $ ruby script/plugin install git://github.com/notahat/machinist.git $ vi spec/blueprints.rb # 新規作成/下記参照 $ vi spec/spec_helper.rb # 下記参照 RAILS_ROOT/spec/blueprints.rbに追記： require 'machinist/active_record' require 'sham' RAILS_ROOT/spec/spec_helper.rbに追記： # 冒頭のほうに記述 require File.expand_path(File.dirname(__FILE__) + "/blueprints") # Spec::Runner.configureブロック内に以下を記述 # -> Shamで1度生成したデータはリスト形式でキャッシュされ、 # 以降はbeforeが呼ばれるたびにその先頭から順に取り出すようになる [...]]]></description>
		<wfw:commentRss>http://aerial.st/archive/2010/02/20/fixture-replacement/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2010/02/20/fixture-replacement" />
	</item>
		<item>
		<title>jrubyでrails</title>
		<link>http://aerial.st/archive/2010/02/09/jruby%e3%81%a7rails</link>
		<comments>http://aerial.st/archive/2010/02/09/jruby%e3%81%a7rails#comments</comments>
		<pubDate>Mon, 08 Feb 2010 15:04:40 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[開発]]></category>
		<category><![CDATA[jruby]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=615</guid>
		<description><![CDATA[jrubyでrailsを動かす際の、導入手順のメモ。DBはMySQL。 sudo port install jruby vi ~/.zshrc > export JRUBY_HOME=/opt/local/share/java/jruby source ~/.zshrc sudo jgem install rails # JDBC用のドライバをインストール # 詳しくは http://jruby-extras.rubyforge.org/activerecord-jdbc-adapter/ sudo jgem install activerecord-jdbc-adapter # 下のmysql用アダプタだけで大丈夫かも sudo jgem install activerecord-jdbcmysql-adapter sudo ln -s $JRUBY_HOME/bin/rails /opt/local/bin/jrails # 既存のものがあるかも jrails -d mysql app_name cd app_name jruby script/generate jdbc vi config/database.yml > development: > adapter: jdbcmysql # [...]]]></description>
		<wfw:commentRss>http://aerial.st/archive/2010/02/09/jruby%e3%81%a7rails/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2010/02/09/jruby%e3%81%a7rails" />
	</item>
		<item>
		<title>.irbrcでirbを便利に</title>
		<link>http://aerial.st/archive/2010/01/18/irbrc%e3%81%a7irb%e3%82%92%e4%be%bf%e5%88%a9%e3%81%ab</link>
		<comments>http://aerial.st/archive/2010/01/18/irbrc%e3%81%a7irb%e3%82%92%e4%be%bf%e5%88%a9%e3%81%ab#comments</comments>
		<pubDate>Mon, 18 Jan 2010 14:32:29 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[開発]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=602</guid>
		<description><![CDATA[~/.irbrcに、irbを起動したときに読み込むスクリプトを記述できる。さらにこの設定はRailsのscript/consoleでも有効になる。詳しくはirbとscript/consoleの超便利なTipsなどを参照。 というわけで、自分の今の設定をメモしておく。 require 'rubygems' require 'wirble' require 'pp' Wirble.init Wirble.colorize # Log to STDOUT if in Rails if ENV.include?('RAILS_ENV') &#038;&#038; !Object.const_defined?('RAILS_DEFAULT_LOGGER') require 'logger' RAILS_DEFAULT_LOGGER = Logger.new(STDOUT) end]]></description>
		<wfw:commentRss>http://aerial.st/archive/2010/01/18/irbrc%e3%81%a7irb%e3%82%92%e4%be%bf%e5%88%a9%e3%81%ab/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2010/01/18/irbrc%e3%81%a7irb%e3%82%92%e4%be%bf%e5%88%a9%e3%81%ab" />
	</item>
	</channel>
</rss>
