なるようになるブログ

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

rails commit log流し読み(2015/03/02)

2015/03/02分のコミットです。

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

activesupport/CHANGELOG.md


[ci skip] Fix fenced code block lang

rails guideのRuby on Rails 4.0 Release Notesの修正です。

String#to_dateのexampleコードの箇所のmarkdownに、言語の設定が無かったのを修正しています。


Indexing a polymorphic assoc adds index on type and id [ci skip]

rails guideのActive Record Associationsの修正です。

polymorphic ssociationを使用している場合に生成されるmigrationファイルのexampleに誤りがあったのを修正しています。

が、この修正内容もmasterとは異なっている箇所があり、後ほど再度修正が行われています。


Removing unused mailer templates

ActionMailerのテストの修正です。使用していないテスト用のファイルを削除しています。


move _generate_paths_by_default to where it is used

actionpack/lib/action_dispatch/routing/url_for.rbactionview/lib/action_view/routing_url_for.rbの修正です。

ActionDispatch::Routing::UrlFor#_generate_paths_by_default メソッドActionView#RoutingUrlFor配下に移動しています。UrlForの方で定義されていたものの、UrlForの方では使用しておらず、RoutingUrlForの方でしか使用していなかった為とのことです。


Bump rack-test to fix nil values being sent to parse_nested_query

Gemfile.lockactionpack/actionpack.gemspec`の修正です。

rack-test gemのバージョンを0.6.2 -> 0.6.3に更新しています。

rackのparse_nested_queryメソッドnilが渡される事があるので、rack側でnilチェックを追加していたのですが、 rack-test側でnilを渡さないよう修正済みだったので、その対応が含まれているバージョンまでバージョンアップしたようです。


drop string allocations per model url_for call in views

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

path_forメソッドで引数のoptionのscript_nameから/を除去する処理があるのですが、その際に指定する/をfreezeで凍結するよう修正しています。

-          path  = options[:script_name].to_s.chomp("/")
+          path  = options[:script_name].to_s.chomp("/".freeze)

不要なStringオブジェクトの生成を削減する為との事です。


Merge pull request #19152 from tchandy/removing_unused_mailer_templates


drop allocations for string and class polymorphic routes

actionpack/lib/action_dispatch/routing/polymorphic_routes.rbの修正です。

Stringの連結処理を行っていた箇所を、式展開を使用するよう修正しています。

-          prefix + "#{str}_#{suffix}"
+          "#{prefix}#{str}_#{suffix}"

不要なStringオブジェクトの生成を削減する為。


refactor handle_model to use private helper methods for generation

actionpack/lib/action_dispatch/routing/polymorphic_routes.rbの修正です。

handle_modelメソッドで、named_routeを生成する際、クラス内で定義されているヘルパーメソッドを使用するよう修正しています。


remove useless conditional

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

update_attributes_from_transaction_stateメソッドから不要なコンディションチェックを削除しています。


Composite index is [:imageable_type, :imageable_id] [ci skip]

rails guideのActive Record Associationsの修正です。

polymorphic ssociationを使用している場合に生成されるmigrationファイルのexampleに誤りがあったのを修正しています。

-    add_index :pictures, [:imageable_id, :imageable_type]
+    add_index :pictures, [:imageable_type, :imageable_id]

Add Enumerable#without

activesupport/lib/active_support/core_ext/array/grouping.rbactivesupport/lib/active_support/core_ext/enumerable.rbの修正です。

指定した要素を削除した値を返すEnumerable#withoutArray#withoutメソッドを追加しています。

people = ["David", "Rafael", "Aaron", "Todd"]
people.without "Aaron", "Todd" # => ["David", "Rafael"]


{foo: 1, bar: 2, baz: 3}.without :bar # => {:foo=>1, :baz=>3}

Include object inclusion for enumerable test.

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

先に追加されたEnumerable#withoutin?メソッドを使用している影響で、 withoutメソッドのテストに active_support/core_ext/object/inclusionのrequireを追加しています。

テストではなく、Enumerable#withoutの方でrequire追加するのは正しそうな気がしたのですが、これは後ほど再度修正されています。


Remove parent transaction state

activerecord/lib/active_record/connection_adapters/abstract/transaction.rbactiverecord/lib/active_record/core.rbの修正です。

ConnectionAdapters::TransactionStateクラスから、親トランザクションの状態を保持していたparent変数を削除しています。

変数自体はあったものの、実際は何処からも値が設定されていない為、削除ようです。


Use include? instead of in? for Enumerable#without.

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

Enumerable#withoutメソッドで、rails拡張のin?メソッドではなく、Ruby標準のinclude?メソッドを使用するよう修正しています。


Move transaction code to transaction module

activerecord/lib/active_record/core.rbactiverecord/lib/active_record/transactions.rbの修正です。

トランザクションに関するメソッドActiveRecord::Coreから、Transactionクラスに移動しています。


Fixing incorrect class name used in an example.

rails guideのRails Routing from the Outside Inの修正です。

Controller Namespaces and Routingの項のexampleのコントローラ名が誤っていたのを修正しています。


Web Console documentation for the upcoming 2.1 release [ci skip]

rails guideのDebugging Rails Applicationsの修正です。

"Debugging with the web-console gem"の項の内容を、2.1 リリースの内容に修正しています。

config.web_console.whitelisted_ipsのデフォルト値の変更等が含まれているようです。


[ci skip] Add code example for MailHelper#block_format documentation

actionmailer/lib/action_mailer/mail_helper.rbの修正です。

MailHelper#block_formatメソッドのdocに、exampleを追加しています。


Nit pick the byebug settings guide for default values [ci skip]

rails guideのDebugging Rails Applicationsの修正です。

byebugについて説明している箇所で、default -> defaultsに表記を修正しています。


Avoid parallelizing Action Pack's tests on Rubinius

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

Rubiniusの場合に、ActionPackのテストのパラレル実行を行わないよう修正しています。

Minitest::Test.parallelize_me!メソッドを呼び出してパラレルで実行するようになっているのですが、parallelize_me!メソッドで呼び出しいるForkingExecutorクラスの処理が少々遅いため、処理が行わないようにしたとの事です。


Avoid accurate assertions on error messages

actionpack/test/dispatch/debug_exceptions_test.rbactionview/test/activerecord/polymorphic_routes_test.rbの修正です。

出力されるエラーメッセージをチェックしているテストで、実行環境により出力内容が異なる部分までチェックしていたのを、チェックするエラーメッセージの内容を緩めるよう修正しています。


Add the platform-specific skip helpers to ActiveModel

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

実行環境がRubinus、JRubyそれぞれの場合にテストをスキップする為のヘルパーメソッドを追加しています。


Modify guides for a better sounding sentence

rails guideのGetting Started with Railsの修正です。

Deleting Articlesの項のグラマーの修正を行っています。