なるようになるブログ

読書感想文かrailsについてかrubyについてか

rails commit log流し読み(2014/08/30)

2014/08/30分のコミットです。

CHANGELOGにのったコミットは以下の通りです。

activesupport/CHANGELOG.md


Don't allow AR::Tasks::DatabaseTasks.migrate to mutate Migration.verbose value

activerecord/lib/active_record/tasks/database_tasks.rbの修正です。

migrateメソッドの後処理でMigration.verboseの値を元の値を設定し直すよう修正しています。

元々は、元の値すら行っていなかったのですが、テストがランダムに行われるようになって、失敗するようになってしまった為対応したとの事です。


Fixed Active Job Backburner adapter

activejob/lib/active_job/queue_adapters/backburner_adapter.rbの修正です。

enqueue_atメソッドで処理を遅延させる時間の計算が間違えてたのを修正しています。


Added yield to Object#presence

activesupport/lib/active_support/core_ext/object/blank.rbの修正です。

Object#presenceメソッドにブロックを渡せるよう対応しています。

doc及びテストから抜粋。

"sally".presence(&:upcase) || "Nobody"
# => "SALLY"

Update examples to show real worth

activesupport/lib/active_support/core_ext/object/blank.rbのdocの修正です。

上で追加したObject#presenceメソッドについて、サンプルを追加しています。

# before
project.account.owner ? project.account.owner.name.first || 'Nobody'

# after
project.account.owner.presence { name.first } || 'Nobody'

上記について、次のコミットで再度修正が行われており、サンプルは修正後の書き方です。 元々のサンプルがあまり良くない気も。この場合、きっとtry使いますよねえ。


Use instance_eval on @tenderlove's suggestion :trollface:

activesupport/lib/active_support/core_ext/object/blank.rbの修正です。

上で追加したObject#presenceメソッドについて、ブロックの実行をyieldを使用していたのを、instance_evalを使用するように修正しています。

元々がproject.account.owner.presence { |p| p.name.first }だったのが、project.account.owner.presence { name.first }こう書けるようになっています。


Clarify the origin of this great addition to Rails :trollface: :trollface :trollface:

activesupport/test/core_ext/object/blank_test.rbの修正です。

-    assert_equal "SALLY", "sally".presence { upcase } || "Nobody"
+    assert_equal "THIS WAS TENDERLOVE'S IDEA", "this was tenderlove's idea".presence { upcase } || "Nobody"

とても楽しげな感じ良いですねえ。このコミットに関するコメントも大分良いです。


We tenderized the wrong method! Object#try already had the yield option, just needed some tenderloving instance_eval to fit the bill

ActiveSupportの修正です。

上記数コミットで対応してきたObject#presenceの対応ですが、Object#tryで良くない? とういう流れになったようで、 Object#presenceの対応は全て削除して、Object#tryメソッドinstance_evalを行うよう修正しています。

@person.try { upcase.truncate(50) }

reduce object allocations in utc_offset

activesupport/lib/active_support/values/time_zone.rbの修正です。

utc_offsetメソッドtryを使用していたのを、後置ifでチェックを行うよう修正しています。

tryメソッドをコールすることでArrayオブジェクトを生成してしまう為、アロケーションを減らす為、削除したとの事です。


Forgot to set Migration.verbose at f8d9a51949d6f6cfcab7cc7d501e137836eb88dc :bomb:

activerecord/lib/active_record/tasks/database_tasks.rbの修正です。

元々あったMigration.verboseの設定処理を誤って削除してしまっていたので戻しています。


Bring back the test cases for presence

activesupport/test/core_ext/object/blank_test.rbの修正です。

Object#presenceの処理の戻しを行う際、誤って既存のテストまで削除してしまっていたのを戻しています。。


Merge pull request #16644 from Agis-/drb-tests-actionpack-vagrant

actionpack/test/abstract_unit.rbの修正です。

ActionPackのテストを行う際、一時ファイルの保存場所に/tmpを使用するよう修正しています。


Refer to the library name instead of the constant

各ライブラリのgem_version.rbの修正です。

ライブラリの名称にスペースをいれるよう修正しています。

-  # Returns the version of the currently loaded ActionMailer as a <tt>Gem::Version</tt>
+  # Returns the version of the currently loaded Action Mailer as a <tt>Gem::Version</tt>

[ci skip] add line about text layout

rails guideのLayouts and Rendering in Railsの修正です。

layoutファイルについての説明を追加しています。