diff --git a/CHANGELOG.md b/CHANGELOG.md index e79827b..571e10a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - CI runs the test suite on Ruby 3.2, 3.3, 3.4, and 4.0. - Releases are published from GitHub Actions when a `v*` tag on `main` is pushed, after the CI suite passes. +- The gem package contains only `lib/`, `LICENSE.txt`, `README.md`, and + `CHANGELOG.md`, and building it no longer requires a git checkout. ## [3.5.0] - 2026-07-10 diff --git a/drip-ruby.gemspec b/drip-ruby.gemspec index 956f321..fff6a9b 100644 --- a/drip-ruby.gemspec +++ b/drip-ruby.gemspec @@ -14,7 +14,7 @@ Gem::Specification.new do |spec| spec.homepage = "http://github.com/DripEmail/drip-ruby" spec.license = "MIT" - spec.files = `git ls-files -z`.split("\x0") + spec.files = Dir.glob(["lib/**/*.rb", "LICENSE.txt", "README.md", "CHANGELOG.md"], base: __dir__).sort spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } spec.require_paths = ["lib"] diff --git a/test/gemspec_test.rb b/test/gemspec_test.rb new file mode 100644 index 0000000..6c76952 --- /dev/null +++ b/test/gemspec_test.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +require_relative 'test_helper' +require "open3" +require "rubygems/package" +require "tmpdir" + +class Drip::GemspecTest < Drip::TestCase + ROOT = File.expand_path("..", __dir__) + + def gem_contents + spec = Gem::Specification.load(File.join(ROOT, "drip-ruby.gemspec")) + Dir.mktmpdir do |dir| + path = File.join(dir, spec.file_name) + Dir.chdir(ROOT) { Gem::Package.build(spec, false, false, path) } + Gem::Package.new(path).contents.sort + end + end + + def tracked_lib_files + out, status = Open3.capture2("git", "-C", ROOT, "ls-files", "-z", "lib") + assert status.success?, "git ls-files failed" + out.split("\x0").grep(/\.rb\z/) + end + + should "package exactly the tracked lib files and top-level docs" do + expected = (tracked_lib_files + %w[LICENSE.txt README.md CHANGELOG.md]).sort + assert_equal expected, gem_contents + end +end