なるようになるブログ

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

rails commit log流し読み(2015/05/29)

2015/05/29分のコミットです。

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

actionpack/CHANGELOG.md

railties/CHANGELOG.md

activesupport/CHANGELOG.md


Remove already defined methods in super class of ActionDispatch::Request class

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

不要な、Request#get?Request#post?Request#patch?Request#put?Request#delete?Request#head?メソッドを削除しています。同じメソッドが親クラスであるRack::Requestに定義済みの為、との事です。


removed erroneous line. Corrected presence validation example.

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

boolean型のattributeにvalidates presence: trueを使用する、という誤った例が記載されていたのを削除しています。


Merge pull request #20331 from arunagw/arunagw-remove-unused-package-tasks

コンポーネントRakefileの修正です。

使用していないpackage 用のタスクを削除しています。今はリリースにはall:build タスクというのを使用しているとの事です。


Merge pull request #20017 from eliotsykes/configurable-static-index-filename

ActionDispatch::StaticActionDispatch::Staticクラスのコンストラクタにインデックス ファイル名を指定出来るよう対応しています。また、コンストラクタに指定するファイル名はconfig.static_indexに指定された値が設定されます。 デフォルトは変わらず"index"(index.html)です。


Allow proc defaults with the Attributes API

ActiveRecordの修正です。

Attributes APIdefaultオプションに、Procを指定出来るよう対応しています。

例。

class OverloadedType < ActiveRecord::Base
  @@counter = 0
  attribute :counter, :integer, default: -> { @@counter += 1 }
end

Persist user provided default values, even if unchanged

activerecord/lib/active_record/attribute/user_provided_default.rbactiverecord/lib/active_record/attributes.rbの修正です。

Attributes APIdefaultオプションに指定した値を、DBに保持するよう修正しています。

例。

class Account < ActiveRecord::Base
  attribute :name, :string, default: "my default"
end

Account.create!
puts Account.last.name.inspect
# => “my default”

ちょっとだけ、違和感が…。


Remove use of mocha from Active Model

ActiveModelの修正です。

テストのmock処理にmochaを使用するのを止めています。


Fix the shadowing warning for reflection

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

merge_preloadsメソッドで"shadowing warning for reflection" のwarningが出ていたのを、変数名を変更して対応しています。


Add Enumerable#pluck.

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

配列から同じキーの値を取得するEnumerable#pluckメソッドを追加しています。

[{ name: "David" }, { name: "Rafael" }, { name: "Aaron" }].pluck(:name)
=> ["David", "Rafael", "Aaron"]

Merge pull request #20267 from kaspth/fix-minitest-constant-clashing

ActiveSupportのテストの修正です。

テスト用にEという名前のクラスを定義していたのですが、Minitestで同名の定数を定義している為、名前がかぶらないよう、EMという名前にクラス名を変更しています。


Updating the guides for Enumerable#pluck

rails guideのActive Support Core Extensionsの修正です。

先に追加されたEnumerable#pluckメソッドについての説明を追加しています。


Use bundler < 1.10 until its bugs are fixed

.travis.ymlの修正です。

テストで使用するbundlerのバージョンを1.10以下に固定しています。 どうもRubyGemsのバージョンチェック処理にバグがあるらしく、そちらのバグが直るまで、古いバージョンを使用するようにするためのようです。bundleのissueはこちら


Uninstall bundler 1.10

.travis.ymlの修正です。

先のコミットの続きです。before_installで、gem install bundlerする前にgem uninstall bundlerして、キャッシュされてるbundlerを削除するよう修正しています。


Force the uninstall

.travis.ymlの修正です。

先のコミットの続きです。gem uninstall bundlerする際、-x --forceオプションを付与して、強制的に削除するようにしています。


Merge pull request #19878 from pabloh/replace_alias_chains_with_prepend

ActiveSupportの修正です。

Dateクラス、Timeクラスで既存のメソッドの書き換えを行うのにalias_methodを使って行っていたのを、Module#prependを使用しるよう修正しています。


Revert "Force the uninstall"

先に記載したRubyGemsのバージョンチェック処理のバグを修正したbundler 1.10.1をリリースしたので、bundler 1.10がインストールされないようにしたコミットをrevertしています。

まずは、Force the uninstall のコミットをrevertしています。


Revert "Uninstall bundler 1.10"

先のコミットの続きです。Uninstall bundler 1.10 をrevertしています。


Fix warning about ambiguous first argument

actionpack/test/controller/log_subscriber_test.rbの修正です。

ambiguous first argumentのwarnigが出ていたのを、メソッドの引数に()を追加して対応しています。

-    assert_match /Completed 200 OK in [\d]ms/, logs[1]
+    assert_match(/Completed 200 OK in [\d]ms/, logs[1])

Revert "Use bundler < 1.10 until its bugs are fixed"

bundlerの対応の続きです。

Use bundler < 1.10 until its bugs are fixed をrevertしています。


Generate Bundler 1.10.1 lockfile

Gemfile.lockの修正です。

lockfile で 1.10.1を使用するようバージョン定義を追加しています。

+
+BUNDLED WITH
+   1.10.1

こんな書き方出来るんですねえ。


Remove unused code.

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

使用していない@assigns変数への値のセット処理を削除しています。


Update docs for ActiveRecord serialize

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

PostgreSQLjson/jsonb型を使用する場合serializeを使用する必要は無いというのと、データが複雑な場合、ActiveRecord::Attributes APIを使用する事を検討した方が良い旨ノートを追加しています。