なるようになるブログ

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

rails commit log流し読み(2017/02/24)

2017/02/24分のコミットです。

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

activerecord/CHANGELOG.md


Merge pull request #28128 from rails/revert-28127-revert-28038-encrypted-secrets

railtiesの修正です。

Encrypted Secretsを操作する為のsecrets:setup及びsecrets:editコマンドを追加しています。

Encrypted Secretsを使用する為には、まずsecrets:setupコマンドを実行する必要があります。secrets:setupコマンドを実行すると、下記ファイルが生成されます。

Adding config/secrets.yml.key to store the encryption key: 6c59e63ec2965b8c78324b37ad142635

Save this in a password manager your team can access.

If you lose the key, no one, including you, can access any encrypted secrets.

      create  config/secrets.yml.key

Ignoring config/secrets.yml.key so it won't end up in Git history:

      append  .gitignore

Adding config/secrets.yml.enc to store secrets that needs to be encrypted.

      create  config/secrets.yml.enc

For now the file contains this but it's been encrypted with the generated key:

# See `secrets.yml` for tips on generating suitable keys.
# production:
#  external_api_key: 1466aac22e6a869134be3d09b9e89232fc2c2289…

You can edit encrypted secrets with `bin/rails secrets:edit`.
Add this to your config/environments/production.rb:
config.read_encrypted_secrets = true

config/secrets.yml.keyにsecret keyが生成され、そのkeyを使用して暗号化されたファイルがconfig/secrets.yml.encになっています。また、config/secrets.yml.keyをバージョン管理に含まないように、.gitignoreconfig/secrets.yml.keyが追加されています。

secrets fileを編集するには、secrets:editコマンドを使用する必要があります。secrets:editコマンドを実行するとエディタが起動し、secret fileの編集が出来るようになります(エディタは$EDITORに設定されているエディタが使用されます)。

EDITOR=vim bin/rails secrets:edit

secret fileのデータを読み込むには、上記secret:setupコマンドの実行結果に書かれている通り、configにconfig.read_encrypted_secrets = trueを設定する必要があります。config.read_encrypted_secretsがfalseの場合、secret fileのデータを読み込まないようになっています(デフォルトはfalse)。

secret fileから読み込んだ値はRails.application.secrets経由で使用出来るようになっています。

なお、暗号化にはaes-256-cbcが使用されるようになっています。が、デフォルトでAES-128-GCMを使用するPR(Update secrets to use modern crypto by stouset · Pull Request #28139 · rails/rails)がきており、今後変わりそうです。


���� :nodoc: AS::Duration::ISO8601Serializer

activesupport/lib/active_support/duration/iso8601_serializer.rbのdocの修正です。

内部向けAPIであるActiveSupport::Duration::ISO8601Serializerクラスに:nodoc:を設定しています。


Merge pull request #28105 from y-yagi/add_wrapper_for_plugins_test_runner

railties/lib/rails/generators/rails/plugin/templates/bin/test.ttrailties/lib/rails/plugin/test.rbの修正です。

Rails pluginで使用するtest runner用のscriptで、Railsのprivate APIを直接使用していたのを、test runner用のwrapperファイルを新規に作成し、そちらをrequireするよう修正しています。private APIを外に晒すのを避ける為。


Use double quotes in the generated plugin test script.

railties/lib/rails/generators/rails/plugin/templates/bin/test.ttの修正です。

Rails pluginで使用するtest runner用のscriptでシングルクォートを使用していた箇所をダブルクォートに修正しています。


Move documentation to the correct place

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

ActionDispatch::SystemTestCaseクラスのdocの記載されている箇所に誤りがあった(クラス定義の前に無いと正しくdocが生成されないのが、クラス定義の後にdocがあった)のを修正しています。


Fix Rakefile loading generator relatively

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

generatorファイルの読み込みをrequire_relativeで行うよう修正しています。

-require "rails/api/generator"
+require_relative "generator"

generatortask.rbと同じディレクトリにあり、LOAD_PATHはデフォルトでは通ってないので、require_relativeじゃないとロード出来ないから、ですかねえ。


Preparing for 5.1.0.beta1 release

コンポーネントのバージョンを5.1.0.beta1に更新、CHANGELOGのヘッダーにRails 5.1.0.beta1を追加等を行っています。


Update package.json

actioncable/package.jsonactionview/package.jsonの修正です。

npmとしてリリースするライブラリ(actioncable、rails-ujs)のバージョンも5.1.0-beta1に更新しています。


Do not override the global variable

tasks/release.rbの修正です。

gem及びnpmをpushするようのrake taskで、task実行時にグローバル変数を上書きしてしまう処理があったのを、上書きしないよう修正しています。


Add a task to build a draft of the release announcement

tasks/release.rbの修正です。

release announcement作成用のtaskを追加しています。


Rearrange npm release process again

tasks/release.rbの修正です。

npm release用の処理を整理しています。prep_releaseタスクが冪等になっていなかったのを、冪等になるよう修正したとのことです。


Fix wait_timeout to configurable for mysql2 adapter

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

MySQL adapterを使用している場合、wait_timeoutの設定が正しく反映されないバグがあったのを修正しています。


Fix w3c_validator.rb validation script

guides/w3c_validator.rbの修正です。

rails guideのvalidationにMarkupValidatorクラスを使用していたのを、NuValidatorを使用するよう修正しています。

今はhttp://validator.w3.org/nu/の方が使用するのが推奨されている為、とのことです。

参考:Service » Input » GET · validator/validator Wiki


Merge pull request #28112 from bolek/include-job_id-in-all-active-job-logs

activejob/lib/active_job/logging.rbの修正です。

Active Jobがデフォルトで出力するログにjob idを含むよう修正ですしています。


Enable Active Model testing for JRuby

.travis.ymlの修正です。

Active Model + JRubyのテストをCIで実行するよう修正しています。


Make HWIA#compact not return nil when no nils

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

保持しているHashにnilが含まれていない場合に、HashWithIndifferentAccess#compactnilを返してしまっていたのを、保持している値をそのまま返すよう修正しています。


Merge pull request #27962 from kamipo/deprecate_quoted_id

Active Recordの修正です。

quote処理にquoted_idメソッドを使用するのがdeprecateになりました。quoted_idは昔のquote処理用のメソッドで、現状はtype castingを使用するようになっている為、deprecateにしたとのことです。


Merge pull request #25285 from kamipo/fix_remove_reference_to_multiple_foreign_keys_in_the_same_table

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

同じテーブルに対して、remove_referenceメソッドで複数のforeign keys を削除しようとした場合に正常にforeign keyの削除が行われないバグがあったのを修正しています。


Make security policy more prominent in docs

CONTRIBUTING.mdREADME.mdの修正です。

security vulnerabilityについてはGitHubのissueにあげるのではなく、http://rubyonrails.org/security/ を参照して欲しい旨説明を追加しています。


Make version short-cut alias to work

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

versionコマンドのショートカット(-v--version)を指定してもversionコマンドが動作しないバグがあったのを修正しています。


Make help short-cut alias to work

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

helpコマンドのショートカット(-h--help)を指定してもhelpコマンドが動作しないバグがあったのを修正しています。


Make adding gemfile entry work even if specify only the plugin name

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

rails plugin作成時のディレクトリがrails application配下だった場合に、自動でrails applicationのGemfileにそのpluginを追加する、という処理がありますが。が、それがplugin名を絶対パスで指定しないと動作しないようになっていたのを、相対パスを指定した場合も動作するよう修正しています。


Improve docs for ActiveRecord::Result. [ci skip]

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

ActiveRecord::Resultクラス配下の各メソッドにdocを追加しています。


does not show hidden namespaces in generator’s help

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

generatorのhelpに表示しないように設定していたnamespaceまで出てしまっていたのを、Rails 5.0までと同様に表示されないよう修正しています。