<?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</title>
	<atom:link href="http://aerial.st/feed" rel="self" type="application/rss+xml" />
	<link>http://aerial.st</link>
	<description></description>
	<lastBuildDate>Sat, 20 Feb 2010 09:40:54 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/feed" />
		<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が呼ばれるたびにその先頭から順に取り出すようになる
config.before(:all)    { Sham.reset(:before_all)  }
config.before(:each)   { Sham.reset(:before_each) }


Dataset


$ cd RAILS_ROOT
$ ruby script/plugin install git://github.com/aiwilliams/dataset.git
$ mkdir spec/datasets
$ vi spec/spec_helper.rb [...]]]></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>acts_as_paranoidの挙動</title>
		<link>http://aerial.st/archive/2010/02/11/acts_as_paranoid_in_relations</link>
		<comments>http://aerial.st/archive/2010/02/11/acts_as_paranoid_in_relations#comments</comments>
		<pubDate>Thu, 11 Feb 2010 05:53:51 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[開発]]></category>
		<category><![CDATA[acts_as_paranoid]]></category>
		<category><![CDATA[Rails]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=620</guid>
		<description><![CDATA[acts_as_paranoidを使うことでレコードの論理削除が容易になる。さらにリレーションが設定されているときには関連する論理削除も行われるように設定できる。

けど、どのメソッドがどのような挙動を示すのかがいまいち不鮮明だったので、ざっくりと調べてみた。

モデル定義

GroupとPersonが1対多のリレーションを持っているとする（多対多の場合も同様だと思う）。

app/models/group.rb


class Group < ActiveRecord::Base
  acts_as_paranoid
  has_many :people, :dependent => :destroy
end


:dependent => :destroyは、レコードの削除時にリレーション先のレコードをどう処理するかを指定するオプションで、:destroyを指定するとリレーション先のレコードに対してdestroyメソッドを実行する。詳細はActiveRecord::Associations::ClassMethodsを参照。

app/models/person.rb


class Person < ActiveRecord::Base
  acts_as_paranoid
  belongs_to :group
end


挙動

Groupに対して削除系メソッドを実行したときに、それと関連するPersonがどうなるかを調べた。

なお、"!"がついているメソッドは破壊的メソッドなので、物理削除（DELETE文）が実行される。

クラスメソッド




  メソッド名
  Group
  関連するPerson




  Group.delete(id)
  論理削除
  変化無し


  Group.destroy(id)
  論理削除
  論理削除


  Group.delete_all
  論理削除
  変化無し


  Group.delete_all!
  物理削除
  変化無し


  Group.destroy_all
  [...]]]></description>
		<wfw:commentRss>http://aerial.st/archive/2010/02/11/acts_as_paranoid_in_relations/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2010/02/11/acts_as_paranoid_in_relations" />
	</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 # mysqlから編集
>    username: app_name
>    password:
>    [...]]]></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>Gitで無視するファイルを設定する</title>
		<link>http://aerial.st/archive/2010/02/01/gitignore</link>
		<comments>http://aerial.st/archive/2010/02/01/gitignore#comments</comments>
		<pubDate>Sun, 31 Jan 2010 15:12:38 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[開発]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[xcode]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=611</guid>
		<description><![CDATA[gitの操作（addやstatus）で特定のファイルを無視するには、リポジトリのルートディレクトリに.gitignoreファイルを設定すればよい。

ただし以下の点に注意。


.gitignore自体をadd/commitしないと効果は現れない
一度commitしたファイルはあとから無視設定をしても効果がない（一旦リポジトリから削除する必要がある）（gitignoreでハマる）


以下、自分の設定内容をメモっておく。

Xcodeで作成したプロジェクト


*.DS_Store
profile
build/*
*.pbxuser
*.mode1v3


buildディレクトリ以下の更新内容は無視して構わない（と以前どこかで読んだ）。あとはnib/xib以下にできるバックアップファイルとか、Finderの設定ファイルとか。

Stack Overflowにもいろいろな例があがっている（そこからgistを作った人もいる）。

Rails

Railsアプリをgitで管理するときのやり方を参考にするとよさそう。
]]></description>
		<wfw:commentRss>http://aerial.st/archive/2010/02/01/gitignore/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2010/02/01/gitignore" />
	</item>
		<item>
		<title>MClock : 最前面に表示する時計</title>
		<link>http://aerial.st/archive/2010/01/31/mclock</link>
		<comments>http://aerial.st/archive/2010/01/31/mclock#comments</comments>
		<pubDate>Sun, 31 Jan 2010 14:21:52 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[ソフトウェア]]></category>
		<category><![CDATA[Cocoa]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=605</guid>
		<description><![CDATA[「会議中にはプロジェクタを時計で映せば時間管理がしやすい」らしいので、常に最前面に表示する時計を作ってみた。

GitHubにおいてある： MClock

全然大したことはやってなくて、次の２つをやってるだけ。


アプリケーション起動時にNSWindowのlevelをNSFloatingWindowLevelにする（なのでアラート画面よりは下に来る）
NSTimerで0.5秒ごとにNSDateを生成してNSTextFieldの文字列を更新してる（なので最大0.5秒のずれが生じる）。


デジタル表示だとわかりにくいので、会議の開始・終了時間を設定してプログレスバー表示するとか、改善方法を考え中。
]]></description>
		<wfw:commentRss>http://aerial.st/archive/2010/01/31/mclock/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2010/01/31/mclock" />
	</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>
		<item>
		<title>Mac版Google Chromeで拡張が利用可能に</title>
		<link>http://aerial.st/archive/2010/01/10/google-chrome-extensions-on-mac-got-available</link>
		<comments>http://aerial.st/archive/2010/01/10/google-chrome-extensions-on-mac-got-available#comments</comments>
		<pubDate>Sat, 09 Jan 2010 18:10:00 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[未分類]]></category>
		<category><![CDATA[googlechrome]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=597</guid>
		<description><![CDATA[Mac版Google ChromeのDev Channelで拡張（extensions）が利用可能になったので、早速以下の3つを入れた。


AutoPatchWork : AutoPagerize的なもの。AutoPagerizeと何が違うのかは知らない。
Hatena Bookmark : はてなブックマーク。Firefoxのものと似たような感じ
Chrome Reader : サイトフィードが提供されている場合に、Google Readerに追加するボタンを表示する。その場でフォルダの設定ができるんだけど、日本語には未対応な雰囲気。正直微妙


Greasemonkey/Grease Kit + AutoPagerizeで慣れてたので拡張が使えない間はちょっと辛かったけど、これで一気にブラウジングが快適になった。
]]></description>
		<wfw:commentRss>http://aerial.st/archive/2010/01/10/google-chrome-extensions-on-mac-got-available/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2010/01/10/google-chrome-extensions-on-mac-got-available" />
	</item>
		<item>
		<title>Wordpressの更新をした</title>
		<link>http://aerial.st/archive/2010/01/10/upgrade-wordpress-to-2_9</link>
		<comments>http://aerial.st/archive/2010/01/10/upgrade-wordpress-to-2_9#comments</comments>
		<pubDate>Sat, 09 Jan 2010 17:57:46 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[ソフトウェア]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=595</guid>
		<description><![CDATA[Wordpress 2.9に更新した。特に凝った使い方をしていないので互換性の問題とかはなさそう。

ついでにテーマを変えた。freethemelayouts.comから探して来たOmicというものを使っている。

twitterのロゴは無料で使えるTwitter(トゥイッター）用アイコン５０個まとめで見つけた、IconsPediaに掲載されているものを使っている。

デザインやってる人は凄いなぁと感じずにはいられない。

ただちょっと文字の色が薄く感じるので、まだまだ要調整といった感じ。
]]></description>
		<wfw:commentRss>http://aerial.st/archive/2010/01/10/upgrade-wordpress-to-2_9/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2010/01/10/upgrade-wordpress-to-2_9" />
	</item>
		<item>
		<title>モジュールの特異メソッドをincludeして使う（修正）</title>
		<link>http://aerial.st/archive/2009/12/25/share-singular-methods-among-modules-2</link>
		<comments>http://aerial.st/archive/2009/12/25/share-singular-methods-among-modules-2#comments</comments>
		<pubDate>Thu, 24 Dec 2009 18:33:55 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[開発]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://aerial.st/?p=589</guid>
		<description><![CDATA[以前の記事が恐ろしく分かりにくいので、軽くまとめ直す。


module A
  def instance_method_of_a
    puts "A#instance_method_of_a was called."
  end

  module ClassMethods
    # A::ClassMethodsで定義されたインスタンスメソッドは、
    # Aをincludeしたクラスのクラスメソッドとして利用できる
    def class_method_of_a
      puts "A::ClassMethods.class_method_of_a was called. Not A.a_class_method!"
    end
  end
  
  def self.included(mod)
  [...]]]></description>
		<wfw:commentRss>http://aerial.st/archive/2009/12/25/share-singular-methods-among-modules-2/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2009/12/25/share-singular-methods-among-modules-2" />
	</item>
		<item>
		<title>Twitterでlock outをくらってます</title>
		<link>http://aerial.st/archive/2009/12/21/locked-out-from-twitter</link>
		<comments>http://aerial.st/archive/2009/12/21/locked-out-from-twitter#comments</comments>
		<pubDate>Sun, 20 Dec 2009 17:06:28 +0000</pubDate>
		<dc:creator>ikm</dc:creator>
				<category><![CDATA[ネット]]></category>
		<category><![CDATA[oauth]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://aerial.st/archive/2009/12/21/twitter%e3%81%a7lock-out%e3%82%92%e3%81%8f%e3%82%89%e3%81%a3%e3%81%a6%e3%81%be%e3%81%99</guid>
		<description><![CDATA[先日のTwitterの障害のためパスワードを変更したのですが、その影響なのか頻繁にlock out状態をくらってログインできずにいます。

多分外部アプリケーションがパスワード変更したことを知らずに旧パスワードでログインしようとしているからかなぁと思っているのですが、いまいちOAuthがどういう仕組みなのか理解していないため、ちょっと判別がついていないです。そんな仕組みだったらいちいちTwitter側にリダイレクトしてパスワードを入力している必要がないんだけど。

追記

iのある生活を読んでちょっと分かった。

パスワードを変更して、iPhone版Echofonには新しいパスワードを適用することができて（十分時間が経過してlock outが解除されれば）問題なく利用できている。

そしてMac版Echofonではそれが適用できていないから、毎回起動時にTLを旧パスワードで取得しようとするからlock outを食らう。そうだよな、OAuthとはちょっと別だ。

起動時にTLを取得されるのはEchofonの仕様上無理かもしれないので、とりあえずKeychain Accessからパスワードを上書きしておいた。どうだろう、これで次回lock outが解けたときには効くかな？

ただ会社にもEchofonを入れてあってそいつの設定もしなきゃならないから、とりあえず明日、長いと明後日まではTwitterがまともに使えないかもしれない。

追記2

lock outが解除されていたので、Mac版Echofon（Keychain Accessでパスワード変更済み）を開いてみたら無事TLが取得できた。

ついでにOAuthの仕組みを調べたけど、Twitterを利用したアプリケーション側ではログインパスワードを保持していないのでこっちは問題なさそう。クライアントに保存されているパスワードを変更すればokのようだ。
]]></description>
		<wfw:commentRss>http://aerial.st/archive/2009/12/21/locked-out-from-twitter/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<xhtml:link rel="alternate" media="handheld" type="text/html" href="http://aerial.st/archive/2009/12/21/locked-out-from-twitter" />
	</item>
	</channel>
</rss>
