0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Gem作成個人メモ(2025/06時点)

Last updated at Posted at 2025-06-03
  1. Gitのリポジトリ作っておいてクローン

  2. (option)bundlerを適当にアップデート

  3. Gemの雛形作成。上記で作っておいたリポジトリの名前を入れる。

    • rspec,rubocopが適当に入る
      bundle gem gem_name --mit --test=rspec
      
  4. gem_name.gemspec, README.mdを適切に編集。

    • 実行に必要なGemなども追加。開発環境でのみ必要なものはGemfileへの追加で良い。railsでよく使い便利なメソッド等はactivesupportを入れる必要があったりする。
      spec.add_dependency 'activesupport'
      spec.add_dependency 'json'
      
  5. コード書く。

    • requireやrequire_relativeはgem_name.rbに集約した方が見やすい
      require 'active_support/core_ext/hash/keys'
      require_relative 'gem_name/version'
      
    • ディレクトリはこういう感じがよさそう
      lib/gem_name/hoge_module/hoge.rb
      lib/gem_name/version.rb
      lib/gem_name.rb
      
    • rspecも簡単に書いておいた方が良さそう
  6. テストする

    • bin/setupで環境構築できるのでruby examples/sample.rbとか適当にテストのファイル作って実行してデバック等する
    • bundle exec rspec, bundle exec rubocopあたりもやっておく
  7. テストで動確問題なければ、gitにpushしてリリース

  8. リリース

    • bundle exec rake releaseでリリース(Gitのタグ付け&Rubygemへ登録)が行われる。VERSIONに設定した値でタグづけとリリースが行われるのでgitにpushする際に忘れずにバージョンアップなど等しておく。
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?