Enter a test framework. rspec/minitest/test-unit/(none): # 今回はそのままEnter Enter a CI service. github/travis/gitlab/circle/(none): # 今回はそのままEnter
Do you want to license your code permissively under the MIT license? # ~~省略~~ You can read more about the MIT license at https://choosealicense.com/licenses/mit. y/(n): y
Do you want to include a code of conduct in gems you generate? # ~~省略~~ For suggestions about how to enforce codes of conduct, see https://bit.ly/coc-enforcement. y/(n): y
Do you want to include a changelog? # ~~省略~~ see https://keepachangelog.com y/(n): y
Do you want to add rubocop as a dependency for gems you generate? # ~~省略~~ For more information, see the RuboCop docs (https://docs.rubocop.org/en/stable/) and the Ruby Style Guides (https://github.com/rubocop-hq/ruby-style-guide). y/(n): y
Gem::Specification.new do |spec| spec.name = "test_gem" spec.version = TestGem::VERSION spec.authors = ["TODO: Write your name"] spec.email = ["TODO: Write your email address"]
spec.summary = "TODO: Write a short summary, because RubyGems requires one." spec.description = "TODO: Write a longer description or delete this line." spec.homepage = "TODO: Put your gem's website or public repo URL here." spec.license = "MIT" spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
spec.metadata["homepage_uri"] = spec.homepage spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here." spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
# Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. spec.files = Dir.chdir(File.expand_path(__dir__)) do `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) } end spec.bindir = "exe" spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"]
# Uncomment to register a new dependency of your gem # spec.add_dependency "example-gem", "~> 1.0"
# For more information and examples about making a new gem, checkout our # guide at: https://bundler.io/guides/creating_gem.html end
TODO などの記載が残っていると、ビルド時にエラーとなるので、一旦適当に書き換えます。 (本来は、内容を検討して記述すべきものです!)
Gem::Specification.new do |spec| spec.name = "test_gem" spec.version = TestGem::VERSION spec.authors = ["Write your name"] spec.email = ["Write your email address"]
spec.summary = "Write a short summary, because RubyGems requires one." spec.description = "Write a longer description or delete this line." spec.homepage = "https://ccbaxy.xyz" spec.license = "MIT" spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
spec.metadata["allowed_push_host"] = "Set to 'http://mygemserver.com'"
# Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. spec.files = Dir.chdir(File.expand_path(__dir__)) do `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) } end spec.bindir = "exe" spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"]
# Uncomment to register a new dependency of your gem # spec.add_dependency "example-gem", "~> 1.0"
# For more information and examples about making a new gem, checkout our # guide at: https://bundler.io/guides/creating_gem.html end
ビルドしてインストールします。
1 2 3 4 5 6 7 8 9 10
cd test_gem rake build test_gem 0.1.0 built to pkg/test_gem-0.1.0.gem.
$ rake release Username for 'https://github.com': [githubのユーザー名] Password for 'https:// [githubのユーザー名]@github.com': [githubのユーザーのパスワード]
test_gem_2 0.1.0 built to pkg/test_gem_2-0.1.0.gem. Tag v0.1.0 has already been created. Enter your RubyGems.org credentials. Don't have an account yet? Create one at https://rubygems.org/sign_up Email: [rubygemsに登録しているアカウントのメールアドレス] Password: [rubygemsに登録しているアカウントのパスワード]
Signed in with API key: XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Pushing gem to https://rubygems.org... Successfully registered gem: test_gem_2 (0.1.0) Pushed test_gem_2 0.1.0 to rubygems.org
$ bundle info test_gem_2 * test_gem_2 (0.1.1) Summary: Write a short summary, because RubyGems requires one. Homepage: https://github.com/Octo8080X/test_gem_2 Path: /usr/src/app/test_gem_2
$ gem yank test_gem_2 -v 0.1.0 Yanking gem from https://rubygems.org... The existing key doesn't have access of yank_rubygem on RubyGems.org. Please sign in to update access. Email: [Rubygemsのアカウントのメールアドレス] Password: [Rubygemsのアカウントのパスワード] Added yank_rubygem scope to the existing API key Successfully deleted gem: test_gem_2 (0.1.0)
バージョン履歴には、更新後の 0.1.1 だけが表示されています。
全バージョンを表示すると、0.1.0 は yanked と書かれています。
この状態で、再度インストールすると次のようにエラーになります。
1 2 3 4 5 6 7 8
$ bundle install Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root users on this machine. Fetching gem metadata from https://rubygems.org/. Resolving dependencies... Your bundle is locked to test_gem_2 (0.1.0) from rubygems repository https://rubygems.org/ or installed locally, but that version can no longer be found in that source. That means the author of test_gem_2 (0.1.0) has removed it. You'll need to update your bundle to a version other than test_gem_2 (0.1.0) that hasn't been removed in order to install.