なるようになるブログ

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

rails commit log流し読み(2014/06/12)

2014/06/12分のコミットです。

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

activerecord/CHANGELOG.md

actionview/CHANGELOG.md


Merge pull request #15628 from akshay-vishnoi/test-cases

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

presence_inメソッドのテストを追加しています。


Add has_one? docs [skip ci]

activerecord/lib/active_record/reflection.rbのdocの修正です。

has_one?メソッドについてdocを追加しています。


Merge pull request #15630 from eileencodes/refactor-join-keys-on-add_constraints

activerecord/lib/active_record/associations/association_scope.rbactiverecord/lib/active_record/reflection.rbの修正です。

associationsのkeyのマージ処理をjoin_keysに切り出しています。リファクタリング


Merge pull request #15582 from sgrif/sg-timestamps

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

max_updated_column_timestampメソッドリファクタリングしています。


Move test for blank.rb under object

activesupport/test/core_ext/blank_test.rbactivesupport/test/core_ext/object/blank_test.rbに移動しています。

libの方の構成と合わせた形ですね。


[ci skip] add tests for ActionModel::Conversion

activemodel/test/cases/conversion_test.rbの修正です。

ActionModel::Conversionのテストケースを追加しています。"ci skip"となっていますが、テストを追加しています。


No need to require to_param, it is already required in to_query.rb

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

不要なrequireを削除しています。


[ci skip] correct docs for conversion

activemodel/lib/active_model/conversion.rbのdocの修正です。

サンプルに間違いがあったらしく、修正しています。


reduce hash lookups and disconnect normalize_port from the options hash

actionpack/lib/action_dispatch/http/url.rbの修正です。

hashのルックアップ処理を減らしたのと、normalize_portoptionsから削除しています。


eliminate nil checks in normalize_port

actionpack/lib/action_dispatch/http/url.rbの修正です。

normalize_portメソッドからnilチェックを削除しています。


Remove unused require

activerecord/lib/active_record/connection_adapters/abstract/schema_dumper.rbの修正です。

不要なrequire 'ipaddr'を削除しています。


cache protocol on the stack to reduce options hash lookups

actionpack/lib/action_dispatch/http/url.rbの修正です。

optionsに格納されているprotocolを、別変数に格納するよう修正しています。hashのルックアップを減らす為のようです。


only pull :protocol from the options hash once

actionpack/lib/action_dispatch/http/url.rbの修正です。

そもそもprotocolの情報をoptionsに格納しないよう修正しています。


cache host on the stack so we only look it up once

actionpack/lib/action_dispatch/http/url.rbの修正です。

optionsに格納されているhostを、別変数に格納するよう修正しています。hashのルックアップを減らす為のようです。


remove warnings

actionpack/test/controller/routing_test.rbactionpack/test/journey/router_test.rbの修正です。

使用してない変数がある為、warningsが出ていたので、使用していない変数を削除しています。


remove unnecssary require of to_param, as to_query is already require to_param

不要なrequire 'active_support/core_ext/object/to_param'を削除しています。


Revert "remove unnecssary require of to_param, as to_query is already require to_param"

と思ったら、やっぱり必要だったらしく、先ほどの削除のコミットをrevertしています。


rm same_host?. The same conditional is two lines down.

actionpack/lib/action_dispatch/http/url.rbの修正です。

不要なsame_host?メソッドを削除しています。直ぐ下に同じチェック処理がある為。


Pluck should work with columns of the same name from different tables

activerecord/lib/active_record/relation/calculations.rbの修正です。

異なるテーブルに同じ名前のカラムがあった場合に、pluckメソッドが全ての結果が取得出来ていなかったバグを修正しています。

テストケースから抜粋

Topic.joins(:replies).pluck('topics.title', 'replies_topics.title')
# [["The First Topic", "The Second Topic of the day"], ["The Third Topic of the day", "The Fourth Topic of the day"]]

join/includesした場合にありえるケースですね。結構便利そうな。


these methods are always called with a tld_parameter

actionpack/lib/action_dispatch/http/url.rbの修正です。

メソッドの引数にデフォルト引数を設定していたのですが、必ず値が設定される筈、という事で、デフォルト引数を削除しています。


Updating argument names in default matcher for compiling files

rails guideのThe Asset Pipelineの修正です。

サンプルの変数名がわかりずらかったのを修正しています。


remove useless nil check

actionpack/lib/action_dispatch/http/url.rbの修正です。

不要なnilチェックを削除しています。

コミットログに、

irb(main):004:0> /foo/ !~ nil
=> true
irb(main):005:0> /foo/ !~ 'bar'
=> true
irb(main):006:0> /foo/ !~ 'foo'
=> false

と実行例が書いてあり、大変わかりやすかったです。


There are 3 caveats to Local Precompilation including 1 config change

rails guideのThe Asset Pipelineの修正です。

Local Precompilationの項の説明を追加しています。


pull the port out of the options hash once

actionpack/lib/action_dispatch/http/url.rbの修正です。

optionsに格納されているportを、別変数に格納するよう修正しています。hashのルックアップを減らす為のようです。


scheme should contain one or more characters

actionpack/lib/action_dispatch/http/url.rbの修正です。

ホスト名の正規表現を修正しています。

-      HOST_REGEXP     = /(^.*:\/\/)?([^:]+)(?::(\d+$))?/
+      HOST_REGEXP     = /(^[^:]+:\/\/)?([^:]+)(?::(\d+$))?/

shemeは一文字以上ある筈なので、* -> +に修正しています。


only look up the subdomain once

actionpack/lib/action_dispatch/http/url.rbの修正です。

optionsに格納されているsubdomainを、別変数に格納するよう修正しています。hashのルックアップを減らす為のようです。


remove useless to_param call

actionpack/lib/action_dispatch/http/url.rbの修正です。

Stringクラスの値に対して、to_paramを呼び出していたらしく、to_paramを削除しています。


remove unnused method from test

railties/test/rails_info_test.rbの修正です。

使用していないテストを削除しています。


Removed warning actionpack url.rb

actionpack/lib/action_dispatch/http/url.rbの修正です。

変数名がバッティングしてワーニングが出ていたのを対応しています。


Add unregister_template_handler to prevent leaks.

actionview/lib/action_view/template/handlers.rbの修正です。

ActionView::Template::Handler.unregister_template_handlerを追加しています。名前の通り、ActionView::Template::Handler.register_template_handlerで登録したhandlerを登録解除するためのメソッドです。


Fixed automatic maintaining test schema to properly handle sql structure schema format.

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

load_schemaメソッドを実行する際、purgeメソッドを呼び出すよう修正しています。

purgeメソッドではDBのdrop/createを行っています。なので、schema.rbを読むタスクでは、必ずDBの再作成が行われるようになります。なので、"automatic maintaining"何ですね。