なるようになるブログ

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

rails commit log流し読み(2016/02/04)

2016/02/04分のコミットです。

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

railties/CHANGELOG.md

actioncable/CHANGELOG.md


Merge pull request #23443 from prathamesh-sonpatki/fix-logging-in-development

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

envがdevelopmentの場合のみ、assetsでないリクエストの後に空行を追加するよう修正しています。

# before
Processing by PostsController#show as HTML
  Parameters: {"id"=>"1"}
  Post Load (0.1ms)  SELECT  "posts".* FROM "posts" WHERE "posts"."id" = ? LIMIT ?  [["id", 1], ["LIMIT", 1]]
  Rendered posts/show.html.erb within layouts/application (0.6ms)
Completed 200 OK in 22ms (Views: 18.2ms | ActiveRecord: 0.1ms)
Processing by PostsController#index as HTML
  Post Load (0.2ms)  SELECT "posts".* FROM "posts"
  Rendered posts/index.html.erb within layouts/application (1.9ms)
Completed 200 OK in 26ms (Views: 24.6ms | ActiveRecord: 0.2ms)
# after
Processing by PostsController#show as HTML
  Parameters: {"id"=>"1"}
  Post Load (0.1ms)  SELECT  "posts".* FROM "posts" WHERE "posts"."id" = ? LIMIT ?  [["id", 1], ["LIMIT", 1]]
  Rendered posts/show.html.erb within layouts/application (0.6ms)
Completed 200 OK in 22ms (Views: 18.2ms | ActiveRecord: 0.1ms)

Processing by PostsController#index as HTML
  Post Load (0.2ms)  SELECT "posts".* FROM "posts"
  Rendered posts/index.html.erb within layouts/application (1.9ms)
Completed 200 OK in 26ms (Views: 24.6ms | ActiveRecord: 0.2ms)

Document the fact that Action Cable does not require a multi-threaded app server

actioncable/README.mdの修正です。

READMEにAction Cableを使用するapp serverはマルチスレッドでないと駄目である旨、説明があったのですが、実際はそうでない(シングルスレッドでも大丈夫)だった為、説明を修正しています。

Action CableはRack socket hijacking APIを使用しており、コネクションの管理をapp serverから引き継いており、Action Cable内部ではconnectionをマルチスレッドで管理しており、app serverがマルチスレッドである必要性は無いとの事です。

参考:[ruby] Rack 1.5 新機能「ハイジャックAPI」について | 私の小岩ホッチキス


Remove json gem dependency

Gemfileactivesupport/activesupport.gemspecの修正です。

gem dependencyからjson gemを削除しています。

Ruby処理系はjsongemをstdlibの一部として同梱しており、依存に追加する必要はもう無い、という事で削除したようです。


Merge pull request #23442 from prathamesh-sonpatki/improve-pg-version-old-error-message

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

PostgreSQL 9.1未満のPostgreSQLを使用した場合に出力するエラーメッセージに、Active RecordはPostgreSQL 9.1以上のみサポートしている旨メッセージを表示するよう修正しています。

-          raise "Your version of PostgreSQL (#{postgresql_version}) is too old, please upgrade!"
+          raise "Your version of PostgreSQL (#{postgresql_version}) is too old. Active Record supports PostgreSQL >= 9.1."

Add dummy apple icon files

railtiesの修正です。

新規Railsアプリを作成した際、publicディレクトリ配下にapple iconのダミーファイル(apple-touch-icon.pngapple-touch-icon-precomposed.png)を追加するよう修正しています。

Safariが上記ファイルをロードしようとする為、不要なエラーメッセージが出力されるのを避ける為、ダミーファイルを追加した、との事です。


Fix line filters running tests from multiple runnables.

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

一つのファイルに複数のrunnableがあった場合に、行数指定でのテストが正しく動かないバグがあったのを修正しています。

複数のrunnableがある、というのは

class PostTest < ActiveSupport::TestCase
  test 'truth' do
    assert true
  end
end

class SecondPostTest < ActiveSupport::TestCase
  test 'truth' do
    assert false, 'ran second runnable'
  end
end

上記のように、複数のテストクラスが一つのファイルにある状態だと、該当します。


Fix model test path typo uncovered in previous commit.

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

既存のテストで、テスト用ファイルの拡張子の指定が漏れていた箇所があったのを修正しています。


Defer Arel attribute lookup to the model class

Active Recordの修正です。

Arelのattributeの取得処理をメソッド(ActiveRecord::Core#arel_attribute)に切り出しています。


Active Record supports MySQL >= 5.0

Active Recordの修正です。

サポートするMySQLのバージョンを5.0以上に修正しています。

元々MySQL 5.0で追加されたinformation_schemaを使用している箇所ががいくつかあり、既に4系は使えない状態になっていたので、明確に5.0以上のみサポートする、というようにしたようです。


Remove unused dependency

Gemfile.lockactivesupport/activesupport.gemspecの修正です。

Active Supportのdependencyからmethod_sourceを削除しています。 Active Supportでは使用していない為。


InnoDB supports FULLTEXT and Spatial Indexes [ci skip]

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

add_indexメソッドのdocにFULLTEXT及びSpatialインデックスはMyISAMでのみサポートしている旨コメントがあったのですが、実際はInnoDBでもサポートしている為、該当のコメントを削除しています。


Extract a Relation#arel_attribute

Active Recordの修正です。

Relation#arel_attributeメソッドを追加し、Relation配下の各クラスでは、そちらのメソッドを使用するよう修正しています。


Remove commented out code in ci/travis.rb [ci skip]

ci/travis.rbの修正です。

デバッグ用と思われるコードがコメントアウトした状態で残されていたので、削除しています。


SQLite 2 support has been dropped [ci skip]

各docの修正です。

doc内に既にサポートしていないSQLite 2について言及している箇所があったのをまとめて削除しています。


Typos in AR tests

Active Recordのテストの修正です。

テストメソッド名、テスト内で使用している変数名等にタイポしている箇所があったのを修正しています。


Revert "Lines of code can be 100,000+ in a Rails app"

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

5桁までしか出力する事を想定してなかったrake statsを、コードの行数が6桁以上の場合でも崩れず表示されるよう修正した、Lines of code can be 100,000+ in a Rails appをrevertしています。ヘッダーが崩れてしまっていた為とのことです。


rake stats dynamically scales now

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

ヘッダーの幅等が固定の値で設定されていたrake statsを、動的に幅を計算するよう修正しています。


Don't publicize Kernel core extensions

activesupport/lib/active_support/core_ext/kernel/concern.rbactivesupport/lib/active_support/core_ext/kernel/reporting.rbの修正です。

RailsKernel moduleに追加しているメソッドがpublicメソッドになってしまっていたのを、privateメソッドにするよう修正しています。


Allow for non-standard redis connectors

actioncable/lib/action_cable/subscription_adapter/evented_redis.rbactioncable/lib/action_cable/subscription_adapter/redis.rbの修正です。

redisのconnectorを生成する為のActionCable::SubscriptionAdapter::EventedRedis.em_redis_connectorActionCable::SubscriptionAdapter::EventedRedis.redis_connectorActionCable::SubscriptionAdapter::Redis.redis_connectorメソッドを追加しています。

-            @redis_connection_for_subscriptions ||= EM::Hiredis.connect(@server.config.cable[:url]).tap do |redis|
+            @redis_connection_for_subscriptions ||= self.class.em_redis_connector.call(@server.config.cable).tap do |redis|

通常のやり方と事なる形でredisのconnectorを生成したい場合に、任意の処理を定義出来るようになっています。


Redis is now only needed if you want to use Action Cable in production

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

Gemfileにredisを記載する際、コメントアウトするよう修正しています。

developmentではRails内部のasync adapterを使用するようになり、デフォルトではredisはproductionでのみ必要な状態になった為、との事です。


Turbolinks has moved out

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

TurbolinksのリポジトリのURLをhttps://github.com/rails/turbolinksからhttps://github.com/turbolinks/turbolinksに移動しています。

Turbolinks 5がhttps://github.com/turbolinks/turbolinksで管理されるようになったからですね。


Pass api only option to rails rails:update task to update only based on API.

railties/lib/rails/tasks/framework.rakeの修正です。

rails:update taskにapi onlyかどうかの値を渡すよう修正しています。現状、api onlyかどうかの値を渡していない為、Rails APIで作られたアプリでも、Railsアプリの変更内容をそのまま反映してしまう為。


Update assertion on redis in generated Gemfile

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

Gemfileにredisが定義されている事を確認するテストを、Gemfileにredisコメントアウトされた状態になっている事を確認するテストに修正しています。

Redis is now only needed if you want to use Action Cable in productionの対応のテスト修正漏れ対応。