Skip to content

Commit

Permalink
🚚 Rename gem to stone_checksums
Browse files Browse the repository at this point in the history
  • Loading branch information
pboling committed Feb 24, 2025
1 parent 9974aed commit 7249f5b
Show file tree
Hide file tree
Showing 12 changed files with 78 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ open_collective: # Replace with a single Open Collective username
patreon: galtzo # Replace with a single Patreon username
polar: pboling
thanks_dev: u/gh/pboling
tidelift: rubygems/gem_checksums # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
tidelift: rubygems/stone_checksums # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ GIT
PATH
remote: .
specs:
gem_checksums (1.0.0)
stone_checksums (1.0.0)
version_gem (>= 1.1.5, < 3)

GEM
Expand Down Expand Up @@ -239,7 +239,6 @@ DEPENDENCIES
benchmark (~> 0.4)
bundler-audit (~> 0.9.2)
debug (>= 1.0.0)
gem_checksums!
github-markup (~> 5.0, >= 5.0.1)
kettle-soup-cover (~> 1.0, >= 1.0.4)
pry (~> 0.14)
Expand All @@ -256,6 +255,7 @@ DEPENDENCIES
rubocop-rspec (~> 3.2)
simplecov
standard (>= 1.35.1, != 1.42.0, != 1.41.1)
stone_checksums!
yard (~> 0.9, >= 0.9.37)
yard-junk (~> 0.0, >= 0.0.10)

Expand Down
38 changes: 18 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# GemChecksums
# StoneChecksums née GemChecksums

[![Version][👽versioni]][👽version]
[![License: MIT][📄license-img]][📄license-ref]
Expand Down Expand Up @@ -34,11 +34,11 @@ A ruby shell script, and rake task, to generate SHA-256 and SHA-512 checksums of
shipped as a RubyGem.

You may be familiar with the standard rake task `build:checksum` from RubyGems.
This gem ships an improved version as `build:checksums`, based on the
This gem ships an improved version as `build:generate_checksums`, based on the
[RubyGems pull request][🔒️rubygems-checksums-pr] I started in October 2022.

```shell
rake build:checksums
rake build:generate_checksums
```

Or giving the same result...
Expand Down Expand Up @@ -69,22 +69,22 @@ gem_checksums
Install the gem and add to your library's Gemfile by executing:

```bash
bundle add gem_checksums
bundle add stone_checksums
```

Or add it as a development dependency to the gemspec:

```ruby
Gem::Specification.new do |spec|
# ...
spec.add_development_dependency("gem_checksums", "~> 1.0")
spec.add_development_dependency("stone_checksums", "~> 1.0")
end
```

If bundler is not being used to manage dependencies, install the gem by executing:

```bash
gem install gem_checksums
gem install stone_checksums
```

## Usage
Expand All @@ -100,11 +100,11 @@ However, if you want to use the bundled rake task you'll need to add it to your

```ruby
begin
require "gem_checksums"
require "stone_checksums"
GemChecksums.install_tasks
rescue LoadError
task("build:checksums") do
warn("gem_checksums is not available")
task("build:generate_checksums") do
warn("stone_checksums gem is not available")
end
end
```
Expand All @@ -113,7 +113,7 @@ Then you can do:

```shell
# prepend with `bundle exec` if gem was added to Gemfile instead of installed globally
rake build:checksums
rake build:generate_checksums
```

It is different from, and improves on, the standard rake task in that it:
Expand All @@ -139,7 +139,7 @@ a specific `.gem` package you want to generate checksums for.

The script version does not accept arguments, and should be controlled by the ENV variables if needed.

### How To: Release gem with checksums generated by `gem_checksums`
### How To: Release gem with checksums generated by `stone_checksums`

Generating checksums makes sense when you are building and releasing a gem, so how does it fit into that process?

Expand Down Expand Up @@ -314,12 +314,10 @@ or one of the others at the head of this README.
[![Buy me a latte][🖇buyme-img]][🖇buyme]

[✇bundle-group-pattern]: https://gist.github.com/pboling/4564780
[🏘chat]: https://gitter.im/pboling/gem_checksums
[🏘chat-img]: https://img.shields.io/gitter/room/pboling/gem_checksums.svg
[⛳️gem-namespace]: https://github.com/pboling/gem_checksums/blob/main/lib/gem_checksums.rb
[⛳️namespace-img]: https://img.shields.io/badge/namespace-GemChecksums-brightgreen.svg?style=flat&logo=ruby&logoColor=white
[⛳️gem-name]: https://rubygems.org/gems/gem_checksums
[⛳️name-img]: https://img.shields.io/badge/name-gem__checksums-brightgreen.svg?style=flat&logo=rubygems&logoColor=red
[⛳️gem-name]: https://rubygems.org/gems/stone_checksums
[⛳️name-img]: https://img.shields.io/badge/name-stone__checksums-brightgreen.svg?style=flat&logo=rubygems&logoColor=red
[🚂bdfl-blog]: http://www.railsbling.com/tags/gem_checksums
[🚂bdfl-blog-img]: https://img.shields.io/badge/blog-railsbling-0093D0.svg?style=for-the-badge&logo=rubyonrails&logoColor=orange
[🚂bdfl-contact]: http://www.railsbling.com/contact
Expand Down Expand Up @@ -357,12 +355,12 @@ or one of the others at the head of this README.
[📜docs-head-rd-img]: https://img.shields.io/badge/RubyDoc-HEAD-943CD2?style=for-the-badge&logo=readthedocs&logoColor=white
[📜wiki]: https://gitlab.com/pboling/gem_checksums/-/wikis/home
[📜wiki-img]: https://img.shields.io/badge/wiki-examples-943CD2.svg?style=for-the-badge&logo=Wiki&logoColor=white
[👽dl-rank]: https://rubygems.org/gems/gem_checksums
[👽dl-ranki]: https://img.shields.io/gem/rd/gem_checksums.svg
[👽dl-rank]: https://rubygems.org/gems/stone_checksums
[👽dl-ranki]: https://img.shields.io/gem/rd/stone_checksums.svg
[👽oss-help]: https://www.codetriage.com/pboling/gem_checksums
[👽oss-helpi]: https://www.codetriage.com/pboling/gem_checksums/badges/users.svg
[👽version]: https://rubygems.org/gems/gem_checksums
[👽versioni]: https://img.shields.io/gem/v/gem_checksums.svg
[👽version]: https://rubygems.org/gems/stone_checksums
[👽versioni]: https://img.shields.io/gem/v/stone_checksums.svg
[🔑cc-mnt]: https://codeclimate.com/github/pboling/gem_checksums/maintainability
[🔑cc-mnti♻️]: https://api.codeclimate.com/v1/badges/ff2234fcbe9051436f37/maintainability
[🔑cc-cov]: https://codeclimate.com/github/pboling/gem_checksums/test_coverage
Expand Down Expand Up @@ -457,7 +455,7 @@ or one of the others at the head of this README.
[📄license-img]: https://img.shields.io/badge/License-MIT-green.svg
[📄ilo-declaration]: https://www.ilo.org/declaration/lang--en/index.htm
[📄ilo-declaration-img]: https://img.shields.io/badge/ILO_Fundamental_Principles-✓-brightgreen.svg?style=flat
[🚎yard-current]: http://rubydoc.info/gems/gem_checksums
[🚎yard-current]: http://rubydoc.info/gems/stone_checksums
[🚎yard-head]: https://rubydoc.info/github/pboling/gem_checksums/main
[🖇buyme-img]: https://img.buymeacoffee.com/button-api/?text=Buy%20me%20a%20latte&emoji=&slug=pboling&button_colour=FFDD00&font_colour=000000&font_family=Cookie&outline_colour=000000&coffee_colour=ffffff
[🖇buyme]: https://www.buymeacoffee.com/pboling
Expand Down
1 change: 0 additions & 1 deletion checksums/gem_checksums-1.0.0.gem.sha256

This file was deleted.

1 change: 0 additions & 1 deletion checksums/gem_checksums-1.0.0.gem.sha512

This file was deleted.

33 changes: 25 additions & 8 deletions gem_checksums.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,33 @@ gem_version = GemChecksums::Version::VERSION
GemChecksums::Version.send(:remove_const, :VERSION)

Gem::Specification.new do |spec|
spec.name = "gem_checksums"
# Linux distros may package ruby gems differently,
# and securely certify them independently via alternate package management systems.
# Ref: https://gitlab.com/oauth-xx/version_gem/-/issues/3
# Hence, only enable signing if the cert_file is present.
# See CONTRIBUTING.md
cert_file = ENV.fetch("GEM_CERT_PATH", "certs/#{ENV.fetch("GEM_CERT_USER", ENV["USER"])}.pem")
if cert_file && File.exist?(File.join(__dir__, cert_file))
spec.cert_chain = [ENV.fetch("GEM_CERT_PATH", "certs/#{ENV.fetch("GEM_CERT_USER", ENV["USER"])}.pem")]
if $PROGRAM_NAME.end_with?("gem", "rake") && ARGV[0] == "build"
spec.signing_key = File.expand_path("~/.ssh/gem-private_key.pem")
end
end

spec.name = "stone_checksums"
spec.version = gem_version
spec.authors = ["Peter Boling"]
spec.email = ["peter.boling@gmail.com"]

# See CONTRIBUTING.md
spec.cert_chain = [ENV.fetch("GEM_CERT_PATH", "certs/#{ENV.fetch("GEM_CERT_USER", ENV["USER"])}.pem")]
if $PROGRAM_NAME.end_with?("gem") && ARGV == ["build", __FILE__]
spec.signing_key = File.expand_path("~/.ssh/gem-private_key.pem")
end

spec.summary = "Generate both SHA256 & SHA512 checksums of RubyGem libraries"
spec.description = "Generate both SHA256 & SHA512 checksums into the checksums directory, and git commit them"
spec.description = <<-DESCRIPTION.rstrip
Generate both SHA256 & SHA512 checksums into the checksums directory, and git commit them.
gem install stone_checksums
Then, use the rake task or the script:
rake build:generate_checksums
gem_checksums
Control options with ENV variables!
DESCRIPTION
spec.homepage = "https://github.com/pboling/gem_checksums"
spec.license = "MIT"
spec.required_ruby_version = ">= 2.2.0"
Expand All @@ -46,8 +60,11 @@ Gem::Specification.new do |spec|
spec.extra_rdoc_files = Dir[
# Files (alphabetical)
"CHANGELOG.md",
"CODE_OF_CONDUCT.md",
"CONTRIBUTING.md",
"LICENSE.txt",
"README.md",
"SECURITY.md",
]
spec.rdoc_options += [
"--title",
Expand Down
2 changes: 1 addition & 1 deletion lib/gem_checksums.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Error < StandardError; end
# The positive lookahead ensures it is present, and prevents it from being captured.
VERSION_REGEX = /((\d+\.\d+\.\d+)([-.][0-9A-Za-z-]+)*)(?=\.gem)/.freeze
RUNNING_AS = File.basename($PROGRAM_NAME)
BUILD_TIME_ERROR_MESSAGE = "Environment variable SOURCE_DATE_EPOCH must be set. You'll need to rebuild the gem. See gem_checksums/README.md"
BUILD_TIME_ERROR_MESSAGE = "Environment variable SOURCE_DATE_EPOCH must be set. You'll need to rebuild the gem. See README.md of stone_checksums"
GIT_DRY_RUN_ENV = ENV.fetch("GEM_CHECKSUMS_GIT_DRY_RUN", "false").casecmp("true") == 0
CHECKSUMS_DIR = ENV.fetch("GEM_CHECKSUMS_CHECKSUMS_DIR", "checksums")
PACKAGE_DIR = ENV.fetch("GEM_CHECKSUMS_PACKAGE_DIR", "pkg")
Expand Down
2 changes: 1 addition & 1 deletion lib/gem_checksums/rakelib/gem_checksums.rake
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace :build do
desc "Generate both SHA256 & SHA512 checksums into the checksums directory, and git commit them"
task :checksums do
task :generate_checksums do
GemChecksums.generate
end
end
2 changes: 2 additions & 0 deletions lib/stone_checksums.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# RubyGems disallowed pushing a gem called `gem_checksums`, hence the name games.
require_relative "gem_checksums"
18 changes: 9 additions & 9 deletions spec/gem_checksums/tasks_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require "rake"

RSpec.describe "rake build:checksums" do # rubocop:disable RSpec/DescribeClass
RSpec.describe "rake build:generate_checksums" do # rubocop:disable RSpec/DescribeClass
subject(:build_checksums) { invoke }

include_context "with rake", "gem_checksums"
Expand All @@ -19,7 +19,7 @@
end

it "raises an error" do
block_is_expected.to raise_error(GemChecksums::Error, "Unable to find gems pkg/*.gem")
block_is_expected.to raise_error(GemChecksums::Error, "Unable to find gems avocado_packages/*.gem")
end

context "when good package directory" do
Expand All @@ -44,12 +44,12 @@
[ GEM PKG LOCATION: spec/support/fixtures/gem_checksums-1.0.0.gem ]
[ CHECKSUM SHA-256: 8e35e0a7cae7fab47c0b7e3d3e81d38294151138bcfcfe8d4aa2e971ff302339 ]
[ CHECKSUM SHA-512: 8b18f8422f22a5a3b301deeaeb8b4e669dfc8033a63c1b5fbfc787af59f60e9df7f920ae2c48ede27ef7d09f0b025f63fc2474a842d54d8f148b266eac4bfa94 ]
[ CHECKSUM SHA-256 PATH: checksums/gem_checksums-1.0.0.gem.sha256 ]
[ CHECKSUM SHA-512 PATH: checksums/gem_checksums-1.0.0.gem.sha512 ]
[ CHECKSUM SHA-256 PATH: banana_checksums/gem_checksums-1.0.0.gem.sha256 ]
[ CHECKSUM SHA-512 PATH: banana_checksums/gem_checksums-1.0.0.gem.sha512 ]
... Running ...
git add checksums/* && git commit --dry-run -m "🔒️ Checksums for v1.0.0" && echo "Cleaning up in dry run mode" && git reset checksums/gem_checksums-1.0.0.gem.sha512 && git reset checksums/gem_checksums-1.0.0.gem.sha256 && rm -f checksums/gem_checksums-1.0.0.gem.sha512 && rm -f checksums/gem_checksums-1.0.0.gem.sha256
git add banana_checksums/* && git commit --dry-run -m "🔒️ Checksums for v1.0.0" && echo "Cleaning up in dry run mode" && git reset banana_checksums/gem_checksums-1.0.0.gem.sha512 && git reset banana_checksums/gem_checksums-1.0.0.gem.sha256 && rm -f banana_checksums/gem_checksums-1.0.0.gem.sha512 && rm -f banana_checksums/gem_checksums-1.0.0.gem.sha256
CHECKSUMS_OUTPUT
end
Expand Down Expand Up @@ -79,12 +79,12 @@
[ GEM PKG LOCATION: spec/support/fixtures/gem_checksums-1.0.0.gem ]
[ CHECKSUM SHA-256: 8e35e0a7cae7fab47c0b7e3d3e81d38294151138bcfcfe8d4aa2e971ff302339 ]
[ CHECKSUM SHA-512: 8b18f8422f22a5a3b301deeaeb8b4e669dfc8033a63c1b5fbfc787af59f60e9df7f920ae2c48ede27ef7d09f0b025f63fc2474a842d54d8f148b266eac4bfa94 ]
[ CHECKSUM SHA-256 PATH: checksums/gem_checksums-1.0.0.gem.sha256 ]
[ CHECKSUM SHA-512 PATH: checksums/gem_checksums-1.0.0.gem.sha512 ]
[ CHECKSUM SHA-256 PATH: banana_checksums/gem_checksums-1.0.0.gem.sha256 ]
[ CHECKSUM SHA-512 PATH: banana_checksums/gem_checksums-1.0.0.gem.sha512 ]
... Running ...
git add checksums/* && git commit --dry-run -m "🔒️ Checksums for v1.0.0" && echo "Cleaning up in dry run mode" && git reset checksums/gem_checksums-1.0.0.gem.sha512 && git reset checksums/gem_checksums-1.0.0.gem.sha256 && rm -f checksums/gem_checksums-1.0.0.gem.sha512 && rm -f checksums/gem_checksums-1.0.0.gem.sha256
git add banana_checksums/* && git commit --dry-run -m "🔒️ Checksums for v1.0.0" && echo "Cleaning up in dry run mode" && git reset banana_checksums/gem_checksums-1.0.0.gem.sha512 && git reset banana_checksums/gem_checksums-1.0.0.gem.sha256 && rm -f banana_checksums/gem_checksums-1.0.0.gem.sha512 && rm -f banana_checksums/gem_checksums-1.0.0.gem.sha256
CHECKSUMS_OUTPUT
end
Expand Down Expand Up @@ -129,7 +129,7 @@
end

it "raises an error" do
block_is_expected.to raise_error(GemChecksums::Error, "Environment variable SOURCE_DATE_EPOCH must be set. You'll need to rebuild the gem. See gem_checksums/README.md")
block_is_expected.to raise_error(GemChecksums::Error, "Environment variable SOURCE_DATE_EPOCH must be set. You'll need to rebuild the gem. See README.md of stone_checksums")
end
end
end
4 changes: 2 additions & 2 deletions spec/gem_checksums_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
end

it "raises an error" do
block_is_expected.to raise_error(GemChecksums::Error, "Unable to find gems pkg/*.gem")
block_is_expected.to raise_error(GemChecksums::Error, "Unable to find gems avocado_packages/*.gem")
end
end

Expand All @@ -28,7 +28,7 @@
end

it "raises an error" do
block_is_expected.to raise_error(GemChecksums::Error, "Environment variable SOURCE_DATE_EPOCH must be set. You'll need to rebuild the gem. See gem_checksums/README.md")
block_is_expected.to raise_error(GemChecksums::Error, "Environment variable SOURCE_DATE_EPOCH must be set. You'll need to rebuild the gem. See README.md of stone_checksums")
end
end
end
Expand Down
18 changes: 17 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,27 @@
nil
end

# Set ENV variables to alter the defaults since we don't want to destroy this gem's actual checksums.
ENV["GEM_CHECKSUMS_GIT_DRY_RUN"] = "true"
ENV["GEM_CHECKSUMS_CHECKSUMS_DIR"] = "banana_checksums"
ENV["GEM_CHECKSUMS_PACKAGE_DIR"] = "avocado_packages"

# This gem
require "gem_checksums"
require "stone_checksums"

RSpec.configure do |config|
config.before do
# We must delete the package directory because the real gems built for release go there,
# which makes this spec flaky locally.
# In order to delete it we must ensure it is empty first.
pkg_dir = "pkg"
Dir[File.join(pkg_dir, "*.gem")].each do |file|
puts "Deleting old gem #{file} to normalize specs"
File.delete(file)
end
# This will fail if the directory is still not empty.
Dir.rmdir(pkg_dir) if Dir.exist?(pkg_dir)

stub_const("GemChecksums::GIT_DRY_RUN_ENV", true)
end
end

0 comments on commit 7249f5b

Please sign in to comment.