なるようになるブログ

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

rails commit log流し読み(2014/05/30)

2014/05/30分のコミットです。

CHANGELOGにのったコミットは以下の通りです(詳細は本文参照)。

activerecord/CHANGELOG.md

railties/CHANGELOG.md

activesupport/CHANGELOG.md

bin/setupスクリプトは便利そうです。まだまだ改善されそうな。


Name#model_name doesn't return a String object

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

model_nameメソッドがStringを返すサンプルになってましたが、実際はmodel_nameはStringを返さないので、model_name.nameに修正しています。


Update url to rake docs [ci skip]

RUNNING_UNIT_TESTS.rdocの修正です。

rakeのURLをhttp://docs.seattlerb.org/rake/を修正しています。


"controllers" should be a valid path name

actionpack/test/dispatch/routing_test.rbの修正です。

params["controllers"]の値のチェックをテストを追加しています。


Refactor serialized types to be partially defined as custom properties

ConnectionAdaptersの修正です。

Type::SimpleDelegator::Serializedクラスを新規に作成して、gserialized typeについてはこちらのクラスで扱うよう修正しています。


Fix broken link in Rails 3.0 release_notes

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

URLの記述に誤りがあって、リンクが壊れてしまったいた箇所を修正しています。3.0とはまた古いな。


Add missing period from 4b802bc [ci skip]

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

上記URLの修正でピリオドが無くなってしまったのを追加しています。


Move type_cast_for_write behavior over to the serialized type object

ConnectionAdaptersの修正です。

type_cast_for_writeメソッドType::SimpleDelegator::Serializedクラスに移動しています。


Don't reference comments that do not exist

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

不要なコメントの削除。


Generated engines don't include bin/rake, fixes #15409 [ci skip]

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

bin/rakerakeに修正しています。engineの場合、bin/rakeは生成されないんですね。


[ci skip] Include ActiveModel::Model in a class instead of inheriting

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

-    #   class Person < ActiveModel::Model
+    #   class Person
+    #     include ActiveModel::Model

継承ではなく、includeする必要があるのが誤っていますね。


pass the parsed parameters through the methods so we don't reparse or

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

メソッドの引数に解析済みのパラメータを追加し、使いまわすようにしています。


use a parser to extract the group parts from the path

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

pathをパースする処理をactionpack/lib/action_dispatch/journey/nodes/node.rbに切り出しています。


reuse the ast we already made

actionpack/lib/action_dispatch/routing/mapper.rbの修正済み。

メソッドの引数を追加して、作成済みのASTを使いまわすようにしています。


disconnect path from the instance

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

インスタンス変数からpathを削除しています。代わりに、メソッドの引数を追加して、使いまわすようにしています。


remove dead code

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

使用していないWILDCARD_PATHを削除しています。


ask the strexp for the ast

actionpack/lib/action_dispatch/journey/router/strexp.rbの修正です。

astメソッドを追加しています。


add an alternate constructor to Strexp that takes a string

actionpack/lib/action_dispatch/journey/router/strexp.rbの修正です。

インスタンス生成用にself.buildメソッドを追加しています。

astについてもbuildメソッドの中で行うようにしているので、先ほど追加されたastメソッドは削除されています。


pass the parsed path from mapper to the Strexp

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

build_pathメソッドの引数にastを追加しています。


Strexp#names is only used in a test, so rm

actionpack/lib/action_dispatch/journey/router/strexp.rbの修正です。

Strexp#namesメソッドをテストでしか使用してなかったらしく、削除しています。


Path::Pattern is instantiated internally, so make the contructor require a strexp object

actionpack/lib/action_dispatch/journey/path/pattern.rbの修正です。

Journey::Router::Strexpインスタンスを生成する為のself.from_stringメソッドを追加しています。


no more is_a checks on instantiation

actionpack/lib/action_dispatch/journey/path/pattern.rbの修正です。

initializeメソッドで最初に、引数がRouter::Strexpかどうかチェック行っていたのですが、そのチェック処理を削除しています。


no reason to make a Mapper object if the path is blank

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

add_routeメソッドでpathのチェックを行い、空だった場合、ArgumentErrorをraiseするよう修正しています。


Mapping never actually uses @set, so rm

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

Mapperクラスの@setインスタンス変数使ってないらしく、削除しています。


[ci skip] Document Rails' shifted semver.

rails guideのMaintenance Policy for Ruby on Railsの修正です。

セマンティックバージョニングについて説明を追加しています。

X.Y.Zのフォーマットについて、以下のような説明が追加されています。

**Patch `Z`**

Only bug fixes, no API changes, no new features.
Except as necessary for security fixes or deprecations.

**Minor `Y`**

New features, may contain API changes (Serve as major versions of Semver).
Breaking changes are paired with deprecation notices in patch level release of
the last minor version level.

**Major `X`**

New features, will likely contain API changes. The difference between Rails'
minor and major releases is the magnitude of breaking changes, and usually
reserved for special occasions.

何となくそうだろうなーと思ってた内容ではあるんですが、名言されてなかったんですね。


pg, PostgreSQL::Name to hold schema qualified names.

PostgreSQLのConnectionAdapterの修正です。

ActiveRecord::ConnectionAdapters::PostgreSQL::Nameクラスを新設しています。

PostgreSQL::Nameクラスでは、schemaの修飾名を保持しています。

obj = Name.new("public", "articles")
assert_equal "public.articles", obj.to_s

バラバラと行われていた処理をクラスに切り出した形ですかね。


pg, reset_pk_sequence! respects schemas. Closes #14719.

activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rbの修正です。

reset_pk_sequence!がschema情報を参照してなくて、エラーになるケースがあるのを修正しています。

ActiveRecord::ConnectionAdapters::PostgreSQL::Nameクラスはこの為か。なるほど。


bin/setup script to bootstrap applications.

bin/setupscriptが追加されました。

setupの中では、

  • gem install bundler --conservative"
  • bundle install
  • bin/rake db:setup
  • rm -f log/*
  • rm -rf tmp/cache
  • touch tmp/restart.txt

が実行されます。割と便利な気が。


:scissors: removed deprecated Numeric#ago and friends

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

deprecateだったNumeric#agoが削除されました。

5.ago   => 5.seconds.ago
5.until => 5.seconds.until
5.since => 5.seconds.since
5.from_now => 5.seconds.from_now

Numeric#ago自体知らなかっです。


Merge pull request #11896 from nkondratyev/fix_pg_columns_for_distinct

activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rbの修正です。

ActiveRecord::Base.connection.columns_for_distinctメソッドSQL構文の解析が誤っていたのを修正しています。

- s.gsub(/\s+(ASC|DESC)\s*(NULLS\s+(FIRST|LAST)\s*)?/i, '')
+ s.gsub(/\s+(?:ASC|DESC)?\s*(?:NULLS\s+(?:FIRST|LAST)\s*)?/i, '')

ASC|DESCは必須ではないんですね。


pg, default_sequence_name respects schema. Closes #7516. activerecord/lib/active_record/connection_adapters/postgresql/schema_statements.rbの修正です。

default_sequence_nameメソッドがschema情報を参照してなかったバグを修正しています。


pg, support default values for enum types. Closes #7814.

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

PostgreSQLenum方でデフォルバリューを指定出来るよう修正しています。


refactor, introduce Type#type_cast_for_schema to cast for schema.rb

ConnectionAdaptersの修正です。

Type#type_cast_for_schemaリファクタリングを行っています。


Update Minitest references in Testing Guide

rails guideのA Guide to Testing Rails Applicationsの修正です。

test/unitminitestに、MiniTestMinitestにそれぞれ修正しています。


bin/setup uses bundle check || bundle install to improve performance.

railties/lib/rails/generators/rails/app/templates/bin/setupの修正です。

-  system "bundle install"
+  system "bundle check || bundle install"

bundle checkを先に実行するよう修正しています。


Change the version schema to reflect how deprecations are handled

rails guideのMaintenance Policy for Ruby on Railsの修正です。

deprecatiosの扱いについて説明を修正しています。


Merge pull request #15313 from andreychernih/time-with-zone-string-conversion-speed-up

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

TimeWithZone#respond_to?メソッドを追加しています。

Stringからの変換処理時の処理高速化になるそうです。へー。