なるようになるブログ

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

rails commit log流し読み(2015/04/23)

2015/04/23分のコミットです。

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

activesupport/CHANGELOG.md

railties/CHANGELOG.md


Silence warning from requiring mathn

actionview/test/template/date_helper_test.rbの修正です。

mathnrequireするとwarning(lib/mathn.rb is deprecated)が表示されるため、warningを表示しないようmathnrequiresilence_warningsメソッドのブロック内で行うよう修正しています。


Clearify that alias_method_chain is deprecated

activesupport/lib/active_support/core_ext/module/aliasing.rbのdocの修正です。

alias_method_chainはdeprecateになっており代わりにModule#prependを使うようファイルの先頭に説明を追加しています。


Add ActiveSupport::TimeZone#strptime.

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

指定されたタイムゾーンに合わせてtimeのパース処理を行う為のActiveSupport::TimeZone#strptimeメソッドを追加しています。

Time.zone = 'Tokyo'
Time.zone.strptime('1999-12-31 10:00:00', '%Y-%m-%d %H:%M:%S')  #=> Fri, 31 Dec 1999 10:00:00 JST +09:00

Refactor ActiveSupport::Timezone#strptime

activesupport/lib/active_support/values/time_zone.rbリファクタリングです。

TimeZone#strptimeメソッドTimeZone#parseメソッドそれぞれがメソッド内で行っていたTimeのパース処理をparts_to_timeメソッドに切り出しています。


Improve ActiveSupport::TimeWithZone conversion to YAML

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

ActiveSupport::TimeWithZoneクラスのオブジェクトをto_yamlメソッドyamlに変換した際に、timezoneの情報が失われていた(timezoneの値に関わらずUTCとして出力されていた)のを、timezoneの情報も正しく出力するよう修正しています。

# before
Time.zone = 'Tokyo'
Time.zone.now.to_yaml # => "--- 2015-04-22 23:39:43.156271198 Z\n...\n"

# after
Time.zone = 'Tokyo'
Time.zone.now.to_yaml # => "--- !ruby/object:ActiveSupport::TimeWithZone\nutc: 2015-04-22 23:39:25.461766748 Z\nzone: !ruby/object:ActiveSupport::TimeZone\n  name: Asia/Tokyo\ntime: 2015-04-23 08:39:25.461766748 Z\n"

Fix formatting of scaffold css

railties/lib/rails/generators/rails/scaffold/templates/scaffold.cssの修正です。

不要なスペースの削除、スタイル毎に改行の追加、等フォーマットの整理を行っています。


Don't ask something that we don't want to

railties/lib/rails/commands/dbconsole.rbの修正です。

DB adapterにrailsが認識していないadapterを指定しdbconsoleコマンドを実行した際、クライアントアプリに何を使用したら良いかrailsはわからないのでエラーになるのですが、 そのエラーメッセージに、"対応したかったらパッチを送ってね"と記載してあったのですが、その部分を削除しています。

-        abort "Unknown command-line client for #{config['database']}. Submit a Rails patch to add support!"
+        abort "Unknown command-line client for #{config['database']}."

railsとしては、今対応しているadapter(MySQL、Postgres、sqlite3、oraclesqlserver)のみをオフィシャルサポートとするため、との事です。

dbconsoleにRedshiftを対応するPRが送られていたのですが、上記理由によりクローズされてしまっていたようです。


Fix find_each options [ci skip]

rails guideのActive Record Query Interfaceの修正です。

find_eachメソッドについて説明している箇所に:end_atオプションについての説明を追記しています。


Remove sqlite support from rails dbconsole

railties/lib/rails/commands/dbconsole.rbの修正です。

rails dbconsoleコマンドからsqlite用の処理を削除しています。当然sqlite3向けの処理はそのまま。

古いsqlite向けの処理は、rails本体から大分前に削除されており、dbconsolesqliteをサポートする必要は無いだろう、との事で削除したようです。


Require yaml before trying to rescue its exception class

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

config_forメソッド内で行っていたyamlのrequire処理をファイルの先頭で行うよう修正しています。


Queue Classic runs a second earlier than scheduled

activejob/test/integration/queuing_test.rbの修正です。

指定された時間が経過した後にjobが実行される事を確認する為のテストで、wait時間の調整を行っています。

計算上元に設定した値で問題無い筈なのですが、実際の所上手く動作しておらず、恐らくQueue Classic のバグなのでは、との事です。


[ci skip] Add, clean up docs in ActionDispatch ActionDispatch middleware

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

FileHandlerクラスのdocのグラマーの修正、及び、FileHandler#match?メソッドにdocを追加しています。


Fix a minor grammatical issue in the doc

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

Enum moduleのdoc内のグラマーの修正を行っています。