rastam on rails

東京在住のマレーシア人 Rubyist

Ruby Weekly #407: 日本語サマリー

職場の Slack 窓で Ruby Weekly メルマガが毎週配信されます。その中から面白そうなものをピックアップして、日本語で簡単なサマリーを書くようにしています。そのサマリーをここでまとまさせていただきます。くだけた日本語で失礼いたします。

http://rubyweekly.com/issues/407rubyweekly.com

Highlights

Generating Music with Sonic Pi and Ruby

Sonic Pi で音楽生成。

'Why I Recommend Against Using Cucumber'

Cucumber が Capybara に一切勝らないという主張。

Under the Hood of “Slurping” and Streaming Files in Ruby

IO.readIO.foreach の内部処理の解説。

Tutorials

Improving Your Ruby Development Process with Pry

Pry とその便利機能の紹介。

  • ls -G または find-method でメソッド検索
  • show-source
  • show-doc
  • .pryrc でお気に入りエディター設定
  • play -l で指定行のコード実行
  • show-models
  • show-routes

A Look at Some Useful ActiveRecord Methods

ActiveRecord メソッド紹介。

  • #pluck
  • #sum
  • #uniq
  • #update_all

Write Bash/Zsh Tab Completion Scripts in Ruby

bash でも zsh でも動くタブ補完スクリプトRuby で実装する方法。

  • zshARGV を設定してくれないから、COMP_LINE 環境変数でコマンドやオプションを地道にパース
  • .zshrc と .bash_profile の設定

Ruby 2.6 Raises an Exception if 'else' Is Used Inside 'begin..end' Block Without 'rescue'

rescue を書かなかった下記ブロックは

begin
else
end

Ruby 2.6 以降、例外を投げるようになった。

Queries on Rails: A Tour of Active Record and Arel

ActiveRecord と Arel のメソッド紹介。

  • #where 連結で AND
  • #or
  • #find_by
  • #limit
  • #not
  • #order
  • #group
  • #includes
  • #joins
  • Arel の #matches

Code & Tools

Staytus: An Open Source Service Status App

システム稼動ステータス告知用 Rails アプリ。

PgHero: A Performance Dashboard for Postgres

PostgreSQL パフォーマンス監視ダッシュボード用 Rails engine。

Down: For Flexible Streaming and Downloading of Remote Files over HTTP

ファイルダウンロード用 gem。ストリーミングにも対応。

StaleOptions: A Gem for Caching HTTP Responses

ActionController のレスポンスをキャッシュしてくれる gem。

Spreadsheet Architect: Create Excel, OpenDocument or CSV Spreadsheets from Ruby Objects

CSVExcel スプレッドシート生成用 gem が v3 にバージョンアップ。