跳至主要內容

如何建立 gem

建立模板​

bundle gem <GEM Name> -t
cd <GEM Name>

編輯 Gemspec​

  1. 開啟 <GEM Name>.gemspec。
  2. 編輯 spec.summary、spec.description、spec.homepage,
  3. 將首頁 URL 寫入 spec.metadata["allowed_push_host"]
  4. 將 Gem 的頁面寫入 spec.homepage
  5. 將儲存庫 URL 寫入 spec.metadata["source_code_uri"]
  6. 將 changelog.md 的 URL 寫入 spec.metadata["changelog_uri"]

至少需要設定上述內容。

推送到 GitHub 並安裝​

git init
git add .
git commit -m First Commit
git remote add origin [email protected]:<username>/<GEM Name>.git
git push -u origin master

安裝​

gem install specific_instal
gem specific_install -l "git://github.com/<username>/<GEM Name>.git"

Gemfile​

gem "<GEM Name>", github: "<username>/<GEM Name>.git", branch: :main

評論

載入中...

發表評論

★★★★★