<?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>Tue, 15 May 2012 01:27:51 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.1</generator>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/tags/ruby/feed/" />
		<item>
		<title>Rack::Profilerを使う</title>
		<link>http://aerial.st/archive/2012/01/16/rack-profiler/</link>
		<comments>http://aerial.st/archive/2012/01/16/rack-profiler/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 09:55:06 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[rack]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=1207</guid>
		<description><![CDATA[Rack::Profilerを使うのに少し躓いたのでメモ。 Gemfile: gem "ruby-prof" gem "rack-contrib", :require =&#62; "rack/contrib" app.rbのconfigureブロックあたり: require "rack/contrib/profiler" Rack::RubyProf = RubyProf use Rack::Profiler Rack::RubyProf = RubyProfをしているのはエラーが出るから。 アクセスする際にURL末尾に ?profile=process_time を付けるとプロファイル結果がダウンロードできる。 あとはKCacheGrindとかQCacheGrindで解析する、らしい。 （qtのビルドで時間がかかってるのでまだできていない…） 参考 [/ruby]/ruby Railsアプリケーションをプロファイリングしよう]]></description>
		<wfw:commentRss>http://aerial.st/archive/2012/01/16/rack-profiler/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2012/01/16/rack-profiler/" />
	</item>
		<item>
		<title>RestClientの返り値はStringとちょっと違う</title>
		<link>http://aerial.st/archive/2011/12/27/rest-client-response-is-not-string/</link>
		<comments>http://aerial.st/archive/2011/12/27/rest-client-response-is-not-string/#comments</comments>
		<pubDate>Tue, 27 Dec 2011 02:43:37 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=1201</guid>
		<description><![CDATA[インターフェースが簡潔で使いやすいRestClientだけれども、各種HTTPメソッドの返り値をto_iするとステータスコードを返すみたいだ。 たとえば次のようなSinatraアプリが起動していたとする。 get '/' do "1" end このgetルーティングに対してRestClientでアクセスすると、次のような結果が得られる。 require "rest_client" res = RestClient.get("http://localhost:9292/") #=&#62; "1" # Stringなのにto_iはステータスコード200を返す res.class #=&#62; String res.to_i #=&#62; 200 # to_strしても変わらない str = res.to_str #=&#62; "1" str.to_i #=&#62; 200 res.class #=&#62; String # 期待される値はと言うと "1".to_i #=&#62; 1 内部でどうやっているかまでは確認できていないけど、 このようにRestClientの返り値のto_iはステータスコードを返す。 で、具体的にどんなときに不具合があるかというと、 Web APIからRestClientを使って取得した値をActiveRecord::Base.findに渡す 内部的にto_iしているのか、毎回id=200を探しに行く json gemによるエスケープ処理JSON.generate([val])が無限ループしてしまう ではどうやっていつものStringとして扱うのかというと、Stringで包みなおせばいい。 res = RestClient("http://localhost:9292") str = String.new(res) str.to_i #=&#62; 1 str.class #=&#62; String なんでこんな変な仕様になってるんだろう。 せめて返り値には別のクラスを使用して欲しかった。 そんな感じで、RestClientは変なところではまるので要注意。]]></description>
		<wfw:commentRss>http://aerial.st/archive/2011/12/27/rest-client-response-is-not-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2011/12/27/rest-client-response-is-not-string/" />
	</item>
		<item>
		<title>Object#presenceが便利</title>
		<link>http://aerial.st/archive/2011/11/16/object-presence/</link>
		<comments>http://aerial.st/archive/2011/11/16/object-presence/#comments</comments>
		<pubDate>Wed, 16 Nov 2011 09:18:02 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[activesupport]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=1181</guid>
		<description><![CDATA[ActiveSupport 2.3で導入されたObject#presenceが便利。 たとえば、 time = options[:timestamp].presence &#124;&#124; Time.now で初期値の代入に使えるし、 time = options[:timestamp].presence &#038;&#038; Time.at(options[:timestamp]) で値がある場合に限って加工に使える。 組み合わせれば、 time = (options[:timestamp].presence &#038;&#038; Time.at(options[:timestamp])) &#124;&#124; Time.now で値があれば加工して、なければ初期値を代入することができる。 でもこれはさすがにわかりづらいので、三項演算子を使って time = options[:timestamp].present? ? Time.at(options[:timestamp]) : Time.now としたほうがカッコが減ってわかりやすい。 ActiveSupportがないと生きていけないゆとりになってしまった…。]]></description>
		<wfw:commentRss>http://aerial.st/archive/2011/11/16/object-presence/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2011/11/16/object-presence/" />
	</item>
		<item>
		<title>Mongoid/MongoDBでauto increment</title>
		<link>http://aerial.st/archive/2011/10/20/mongoid-auto-increment/</link>
		<comments>http://aerial.st/archive/2011/10/20/mongoid-auto-increment/#comments</comments>
		<pubDate>Thu, 20 Oct 2011 14:03:17 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[mongodb]]></category>
		<category><![CDATA[mongoid]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=1171</guid>
		<description><![CDATA[Auto Increment with MongoDBより、Mongoid/MongoDBでMySQLのauto incrementみたいなことをする方法。 連番を保持するためのCollectionを用意して、新しくDocumentを作る際にそれをfind_and_modifyで1増加させるという方法をとる。 find_and_modifyを使うので、MongoDBは1.3.0以上、Mongoidは2.2.0以上が必要になる。 まずは連番を保持するためのCollectionを用意する。 class Seq include Mongoid::Document field :collection, type: String field :seq, type: Integer end auto increment的なことがしたいCollectionではbefore_validateのタイミングでSeqから採番する。 class User include Mongoid::Document field :name, type: String field :seq, type: Integer, default: 0 before_create :set_seq private def set_seq self.seq = Seq.collection.find_and_modify( query: { "collection" =&#62; "users" }, update: { "$inc" =&#62; { "seq" =&#62; 1 } }, new: true )["seq"] end end 連番Collection別に連番を保持するためのDocumentは事前に用意しておく必要があるので忘れずに。 Seq.create(collection: "users", seq: 0)]]></description>
		<wfw:commentRss>http://aerial.st/archive/2011/10/20/mongoid-auto-increment/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2011/10/20/mongoid-auto-increment/" />
	</item>
		<item>
		<title>yard-sinatraでSinatraのドキュメントにYARDを使う</title>
		<link>http://aerial.st/archive/2011/10/18/yard-sinatra/</link>
		<comments>http://aerial.st/archive/2011/10/18/yard-sinatra/#comments</comments>
		<pubDate>Tue, 18 Oct 2011 01:40:23 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[sinatra]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=1165</guid>
		<description><![CDATA[yardのプラグインであるyard-sinatraを使うとSinatraのアクションごとに記述されたyardocからHTMLドキュメントを生成できる。 インストールと設定 yard-sinatraをインストールすれば必要に応じてyardもインストールされる。 ただしyardはデフォルトではプラグインを読み込まないので、読み込むように設定してやる必要がある。 $ gem install yard-sinatra $ mkdir ~/.yardoc $ yard config load_plugins true ドキュメントの生成 $ cd /path/to/sinatra/project $ yardoc $ open doc/index.html # OSXでのみ有効 Class Listからアクションが実装されているClassを選択すると、HTTPメソッド順にアクションが並んでいる。]]></description>
		<wfw:commentRss>http://aerial.st/archive/2011/10/18/yard-sinatra/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2011/10/18/yard-sinatra/" />
	</item>
		<item>
		<title>µ-optparseを使って.rvmrcを生成</title>
		<link>http://aerial.st/archive/2011/09/11/generate-rvmr/</link>
		<comments>http://aerial.st/archive/2011/09/11/generate-rvmr/#comments</comments>
		<pubDate>Sun, 11 Sep 2011 13:42:59 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=1147</guid>
		<description><![CDATA[optparseのラッパーであるµ-optparseを使って.rvmrcを生成するスクリプトを書いてみた。 オプションは下記の通り。&#8211;helpでも見れるし、コードを読むだけでもわかりやすい。 -r, &#8211;ruby Rubyのバージョン。デフォルトはこのスクリプトを実行しているRuby -g, &#8211;gemset gemset名。デフォルトはカレントディレクトリ名 -f, &#8211;force 指定された場合、.rvmrcが存在しようがしまいが書きだす たとえば次のコマンドでは&#8221;rvm use 1.9.2@rails31&#8243;を.rvmrcに書きだす。 $ rvmrc -r 1.9.2 -g rails31 -f µ-optparseは宣言していない引数が指定された場合や、引数の値が条件（正規表現、特定の値、もしくは任意の判定条件を）にマッチしない場合にエラー文を出してくれたりと結構便利。&#8211;helpや&#8211;versionにも勝手に対応してくれるので、ちょこっとしたスクリプトを書くのに向いている。 まぁこんなコマンドを叩くぐらいなら直接echoした場合のほうが手軽だろうけど、どちらかというとオプション指定ナシで現在の環境の.rvmrcを吐くのが目的なので、実際問題オプションは必要なかったりする…かも]]></description>
		<wfw:commentRss>http://aerial.st/archive/2011/09/11/generate-rvmr/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2011/09/11/generate-rvmr/" />
	</item>
		<item>
		<title>RubyKaigi2011（二日目）に参加してきた</title>
		<link>http://aerial.st/archive/2011/07/18/rubykaigi2011-2nd-day/</link>
		<comments>http://aerial.st/archive/2011/07/18/rubykaigi2011-2nd-day/#comments</comments>
		<pubDate>Sun, 17 Jul 2011 17:40:19 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubyist]]></category>
		<category><![CDATA[rubykaigi]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=1121</guid>
		<description><![CDATA[今日も午後から参加してきた。@a_matsudaさん、@yharaさんの話が聞けなくて、寝坊してしまったことを激しく後悔している。 5 years know-how of RSpec driven Rails app. development. / @moro 最近のrspecやfixture-replacementを使ったテストの書き方のノウハウ。 fixture-replacementはFabricationを使ってるみたい。 寝坊して最後の5分しか見られなかったけど、早くもスライドやUstが公開されているのでそちらをチェックしよう。 shared_context fixtureはマスタ、fixture_replacementはリソース、beforeはイベントが向いてる 適宜使い分けるといい Rails3レシピブック買いました！ Efficient JavaScript integration testing with Ruby and V8 engine. / -Chris Kowalik V8エンジンをRubyから呼び出してJavascriptのIntegrational Testをしようという話。 肝心のMustangとMikeの位置関係が理解しきれなかった。CとC++の混在してるMustangじゃなくてC++で統一されたMikeを使おうよ、って話でいいのかな。あとで別の人のレポートを読もう。 selenium時間かかりすぎ selenium,watir,phantom 遅い phantomはただのwebkitラッパーで、遅いことにかわりない ヘッドレス HtmlUnit(Java) いち押し 設定が面倒くさい Zombie EnvJS 欲しいのは 速さ javascript support 使いやすいAPI ポータビリティ Mustang &#8211; V8 in Ruby nu7hatch/mustang もとはrubyracer スクラッチから設計・実装された パフォーマンス重視 V8素敵 世代GC メモリモデルが優れてる 暗黙クラス機能（？ インラインキャッシュ ネイティブコードの生成 Mike MustangはC/C/C++で書かれてる 全部C++で書けばいいのに https://github.com/nu7hatch/mike 複数ウィンドウのサポート フレームのサポート ユーザの操作のサポート クリック フォーム入力 Javascriptの実行 アラート・ポップアップ Q&#38;A V8のインスタンスはLinux上だと1個しか作れなかったと思うけど 1つのインスタンスに対して複数のコンテキストを持たせることができるので問題にはならない Advancing [...]]]></description>
		<wfw:commentRss>http://aerial.st/archive/2011/07/18/rubykaigi2011-2nd-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2011/07/18/rubykaigi2011-2nd-day/" />
	</item>
		<item>
		<title>RubyKaigi2011（初日）に参加してきた</title>
		<link>http://aerial.st/archive/2011/07/17/rubykaigi2011-1st-day/</link>
		<comments>http://aerial.st/archive/2011/07/17/rubykaigi2011-1st-day/#comments</comments>
		<pubDate>Sat, 16 Jul 2011 20:13:47 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rubyist]]></category>
		<category><![CDATA[rubykaigi]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=1113</guid>
		<description><![CDATA[午後から参加してきた。 とりあえず箇条書きのメモを載せておく。あとで感想を書こう。 Ruby を利用した大規模ウェブサービスの開発・運用 / @hotchpotch cookpadの中の話。extensionsがとても興味深かった。 この後のgithubとかもそうなんだけど、テスト＝CIがもう当たり前なんだな、という感じがした。 1.8.7/2.3 varnish 30ms tofu solr 集合を扱う（Facet 重み付け検索（Boost Search 動的なフィールド追加（Dynamicfields 速度は変わらない、検索の柔軟性 空間検索できるらしい amebaの事例http://www.cyberagent.co.jp/news/press/2010/0708_2.html ベストに集中 シンプル キャッシュにのりやすい 非同期を活用 共通部分とユーザ固有とを分けることでキャッシュしやすくする ユーザの体感速度的に問題ない テスト rspec 1.x unit functional integration JS周りの重視 capybara-webkit リモートサーバ上でテスト http://d.hatena.ne.jp/secondlife/20110410/1302442313 CIを通ったコードのみリリース みんなテストを書く CIで動かないテスト→将来的に価値のないテスト extensions 特定の条件下のみで有効になる機能拡張 新機能の試用などに利用 没になったら rm -rf app/extentions/foo_ext specなくてok 仕様の変更が多い 例外が発生したら自動的に無効になる Shipping at the Speed of Life / @atoms githubの中の人の話。マシンガントーク。凄くたくさんのツールを使ってるみたい。 githubの維持のためにたくさんのツールを作った 単純作業の自動化 BrowserdMod collectd 時系列データの収集（mysqlの書き込み時間とか nagios redis counters 何が何回使われたか campfire コミュニケーション http://propaneapp.com/ Haystack hoptoadみたいなもの 例外を監視 hubot CI/Jenkinsの結果をcampfireに通知 new relic http://newrelic.com/ パフォーマンスプロファイラ レイヤごとに表示 [...]]]></description>
		<wfw:commentRss>http://aerial.st/archive/2011/07/17/rubykaigi2011-1st-day/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2011/07/17/rubykaigi2011-1st-day/" />
	</item>
		<item>
		<title>geminaboxでローカルにgemをホストする</title>
		<link>http://aerial.st/archive/2011/06/10/geminabox/</link>
		<comments>http://aerial.st/archive/2011/06/10/geminabox/#comments</comments>
		<pubDate>Fri, 10 Jun 2011 10:43:34 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[pow]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[rvm]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=1071</guid>
		<description><![CDATA[geminaboxを使ってローカルにgemをホストしてみる。 （とりあえずでやってみただけなので、手順等にミスがあるかも） まずはサーバを立てる rvmとpowが入っている前提で。 ~/var/geminabox 以下を使うとする。 $ rvm use 1.8.7@geminabox --create $ gem install geminabox $ mkdir -p ~/var/geminabox/data $ echo "rvm use 1.8.7@geminabox" &#62; ~/var/geminabox/.rvmrc $ echo 'require "rubygems" require "geminabox" Geminabox.data = "#{ENV['HOME']}/var/geminabox/data" run Geminabox ' > ~/var/geminabox/config.ru $ ln -s $HOME/var/geminabox $HOME/.pow これで http://geminabox.dev/ にアクセスすればgeminaboxでホストしているgem一覧が表示される。 つぎにgemを追加する たとえばhello-0.0.1.gemをrubygems.orgから落としてきて追加する。 $ wget http://rubygems.org/downloads/hello-0.0.1.gem $ gem inabox hello-0.0.1.gem これをやると http://geminabox.dev/ の一覧に追加される。 使ってみる $ gem sources -a http://geminabox.dev/ もしくは~/.gemrcのsourcesに手動で追加する。 :sources: - http://geminabox.dev - http://rubygems.org bundlerだったらGemfileに追記する。 source "http://geminabox.dev" source :rubygems では実際にインストールしてみる。 $ gem [...]]]></description>
		<wfw:commentRss>http://aerial.st/archive/2011/06/10/geminabox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2011/06/10/geminabox/" />
	</item>
		<item>
		<title>rubygemsをバージョンを指定して更新</title>
		<link>http://aerial.st/archive/2011/06/09/update-rubygems-with-specific-version/</link>
		<comments>http://aerial.st/archive/2011/06/09/update-rubygems-with-specific-version/#comments</comments>
		<pubDate>Thu, 09 Jun 2011 02:00:25 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[gem]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=1059</guid>
		<description><![CDATA[メモ。 gem install rubygems-update -v update_rubygems バージョンの一覧はrubygems.orgなどで確認するとよい。]]></description>
		<wfw:commentRss>http://aerial.st/archive/2011/06/09/update-rubygems-with-specific-version/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2011/06/09/update-rubygems-with-specific-version/" />
	</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/


Served from: aerial.st @ 2012-05-23 01:54:45 -->
