なるようになるブログ

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

rails commit log流し読み(2015/12/09)

2015/12/09分のコミットです。

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

actionpack/CHANGELOG.md

railties/CHANGELOG.md


Use URL path extension as format in bad params exception handling

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

bad params exception がformatの情報も正しく返すよう、#path_parametersからformatの情報も返すよう修正しています。

が、path parametersのformat情報については、後ほど削除されています。


renames AS::FileEventedUpdateChecker to AS::EventedFileUpdateChecker

Active Supportの修正です。

ActiveSupport::FileEventedUpdateCheckeクラスをActiveSupport::EventedFileUpdateCheckerに名前を変更しています。英語としてそちらの方が良い為、との事です。


Fix make_response! when called by serve in RouteSet https://github.com/rails/rails/commit/b05801754f6423a1d90954ef3f6e2f5dc55c6320

actionpack/lib/action_controller/metal/live.rbの修正です。

master環境でActionController::Liveを使用しようとするとNoMethodErrorがraiseされてしまうバグがあったのを修正しています。

use dispatch instead of process to run requests though · rails/rails@42eb37aで、ActionController::Livemake_response!の引数がrequestからresponseになるよう修正していたのですが、実際は、RouteSet#serveメソッドからmake_response!メソッドが呼ばれる場合、引数にはrequestが設定されていた為にエラーになってしまっていたようです。

元の挙動(引数にrequestが来ることを想定)に修正し対応しています。


Response when error should be formatted properly in Rails API if local request

Action Packの修正です。

rails apiでは、ActionDispatch::DebugExceptionsクラスからdebug情報を返す際、JSONフォーマットでデータを返すよう対応しています。


Do not include web-console in Rails API apps

railties/test/generators/api_app_generator_test.rbの修正です。

rails apiではGemfileにweb-cosole gemが含まれない事を確認するテストを追加しています。


Fix some edge cases in AD::DebugExceptions in rails api apps

actionpack/lib/action_dispatch/middleware/debug_exceptions.rbの修正です。

#render_exceptionメソッドに、rails api / 普通のrails appそれぞれの場合の処理をまとめて定義していたのをメソッドに切り出し、及び、rails apiの場合、にrequestのformatのチェックをし、requestのformatに合わせてresponseのformatを設定するよう修正しています。


New hash syntax in AD::DebugExceptions

actionpack/lib/action_dispatch/middleware/debug_exceptions.rbの修正です。

#render_for_api_applicationメソッドで、Ruby 1.9のHah syntaxを使用するよう修正しています。


Remove unneeded args in AD::DebugExceptions

actionpack/lib/action_dispatch/middleware/debug_exceptions.rbの修正です。

#render_for_non_api_applicationメソッドから不要な空行を削除しています。


Minor cleanup in AD::DebugExceptions

actionpack/lib/action_dispatch/middleware/debug_exceptions.rbの修正です。

変数名を適切な名前に変更、不要なスペースを削除、等をまとめて行っています。


Improve regexp in AC::Http::Parameters

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

pathの終端チェックをする正規表現$を使用していたのを、\zを使用するよう修正しています。


Better name for method in DebugExceptions middleware

actionpack/lib/action_dispatch/middleware/debug_exceptions.rbの修正です。

#render_for_non_api_applicationメソッド#render_for_default_applicationメソッドに名前を変更しています。


Add debug_exception_response_format config to configure DebugException

railties/lib/rails/application/configuration.rbrailties/lib/rails/generators/rails/app/templates/config/environments/development.rb.ttの修正です。

configに、DebugExceptionのformatを指定する為のconfig.debug_exception_response_formatを追加しています。 rails apiの場合は、:apiという値が設定されるようになっています。


DebugException initialize with a response_format value

actionpack/lib/action_dispatch/middleware/debug_exceptions.rbrailties/lib/rails/application/default_middleware_stack.rbの修正です。

DebugExceptions#newの引数に、先ほど追加されたdebug_exception_response_formatを指定するよう修正しています。


Mention the debug_exception_response_format config in guides

rails guideのUsing Rails for API-only Applicationsの修正です。

先ほど追加されたconfig.debug_exception_response_formatについて、guideに説明を追加しています。


Fix indent in generated Rails API env file

railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.ttの修正です。

先ほど追加されたconfig.debug_exception_response_formatの箇所のインデントがおかしかったので修正しています。


debug_exception_response_format needs to be writeable in Configuration

railties/lib/rails/application/configuration.rbの修正です。

値の設定が出来るよう、debug_exception_response_formatの定義にattr_readerメソッドを使用していたのを、attr_accessor`メソッドを使用するよう修正しています。


Update Changelog with the added response_format option in AD::DebugExceptions

actionpack/CHANGELOG.mdrailties/CHANGELOG.mdの修正です。

ActionDispatch::DebugExceptionsクラスのresponse_format引数の対応について、CHANGELOGに追記しています。


Adjust comment in development.rb template file for app generator

railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.ttの修正です。

config.debug_exception_response_formatについての説明で、不要と思われる内容を削除しています。


Do not add format key to request_params

actionpack/lib/action_dispatch/http/mime_negotiation.rbactionpack/lib/action_dispatch/http/parameters.rbの修正です。

先ほど#path_parametersからformatの情報も返すよう修正していたのですが、やはり返さないよう修正しています。request paramsに悪影響が出てしまう為、のようです。

代わりに、Request#formatsメソッドでformatを取得する際に、URLのextensionからformatを取得するよう修正を行っています。


Avoid warning because of the mime type

actionpack/lib/action_dispatch/middleware/debug_exceptions.rbの修正です。

deprcate warningが出るのを避ける為に、Mimeの指定に定数(Mime::JSON)を使用していたのを、Hashから値を取得(Mime[:json])するよう修正しています。


Add tests for api_only configuration setting

railties/test/application/configuration_test.rbの修正です。

configurationのテストに、api_onlyが設定されている場合 / 設定されていない場合のテストを追加しています。


Make debug_exception_response_format config depends on api_only when is not set

railties/lib/rails/application/configuration.rbの修正です。

debug_exception_response_formatattr_accessorで定義していたのをやめて、api_onlyがconfigに指定されていた場合に、自動でdebug_exception_response_format:apiを設定するよう修正しています。


We don't need to set config.debug_exception_response_format given that :api is the default value for only API apps

railties/lib/rails/generators/rails/app/templates/config/environments/development.rb.ttrailties/test/generators/api_app_generator_test.rbの修正です。

先の対応でdebug_exception_response_formatをconfigで指定する必要は無くなった為、development.rb.ttからconfig.debug_exception_response_formatに指定に関する処理を削除しています。


Remove duplicated assertion from api_app_generator tests

railties/test/generators/api_app_generator_test.rbの修正です。

rails apiではGemfileにweb-cosole gemが含まれない事を確認するテストがすでにあったので、重複しているテストを削除しています。