Gemfileに記載してあるgemの説明を一覧で表示する #fjordbootcamp
追記: bundle info
でgemの情報を表示できるので、一覧じゃなければコレで十分かも。
$ bundle info rails * rails (6.1.3.2) Summary: Full-stack web application framework. Homepage: https://rubyonrails.org Documentation: https://api.rubyonrails.org/v6.1.3.2/ Source Code: https://github.com/rails/rails/tree/v6.1.3.2 Changelog: https://github.com/rails/rails/releases/tag/v6.1.3.2 Bug Tracker: https://github.com/rails/rails/issues Mailing List: https://discuss.rubyonrails.org/c/rubyonrails-talk Path: /app/vendor/bundle/ruby/3.0.0/gems/rails-6.1.3.2
タイトルに #fjordbootcamp
がついていますが、これは #fjordbootcamp
の課題とかではありません。
フィヨルドブートキャンプとは
きっかけ
フィヨルドブートキャンプのGitHubリポジトリに以下のIssueが登録されていた。*1
これを読んでいて、ふと「gemspecから説明を抜き出して、一覧で表示できると便利そう」と思いついたので、試しに実装してみた。
コード
#!/usr/bin/env ruby # frozen_string_literal: true require 'bundler' lockfile = Bundler.default_lockfile.read parser = Bundler::LockfileParser.new(lockfile) spec_per_name = parser.specs.group_by(&:name).transform_values(&:first) parser.dependencies.keys.each do |name| spec = spec_per_name[name] if spec path = "#{Bundler.specs_path}/#{name}-#{spec.version}.gemspec" gemspec = Gem::Specification.load(path) end puts "#{name}: #{gemspec&.summary}" end
実行結果
$ ./bundler-summaries bootsnap: Boot large ruby/rails apps faster byebug: Ruby fast debugger - base + CLI capybara: Capybara aims to simplify the process of integration testing Rack applications, such as Rails, Sinatra or Merb jbuilder: Create JSON structures via a Builder-style DSL listen: Listen to file modifications puma: Puma is a simple, fast, threaded, and highly concurrent HTTP 1.1 server for Ruby/Rack applications rack-mini-profiler: Profiles loading speed for rack applications. rails: Full-stack web application framework. sass-rails: Sass adapter for the Rails asset pipeline. selenium-webdriver: The next generation developer focused tool for automated testing of webapps spring: Rails application preloader sqlite3: This module allows Ruby programs to interface with the SQLite3 database engine (http://www.sqlite.org) turbolinks: Turbolinks makes navigating your web application faster tzinfo-data: web-console: A debugging tool for your Ruby on Rails applications. webdrivers: Easy download and use of browser drivers. webpacker: Use webpack to manage app-like JavaScript modules in Rails