gemspec: Exclude Gemfile and gemspec from gem (#1279)

* gemspec: Exclude Gemfile and gemspec from gem

This change was inspired by the rubocop-packaging efforts, which in turn
are Debian efforts. They wrote a kind rationale for their work at https://packaging.rubystyle.guide/#using-git-in-gemspec

* Squash: restore the `reject`, add docs

* Squash: more docs

[ci skip]

Co-authored-by: Jared Beck <jared@jaredbeck.com>
This commit is contained in:
Olle Jonsson 2020-12-27 01:50:26 +01:00 committed by GitHub
parent 6dd55dbdb2
commit ce2e055cef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 3 deletions

View File

@ -19,9 +19,21 @@ has been destroyed.
s.email = "jared@jaredbeck.com"
s.license = "MIT"
s.files = `git ls-files -z`.split("\x0").select { |f|
f.match(%r{^(Gemfile|LICENSE|lib/|paper_trail.gemspec)})
}
# > Files included in this gem. .. Only add files you can require to this
# > list, not directories, etc.
# > https://guides.rubygems.org/specification-reference/#files
#
# > Avoid using `git ls-files` to produce lists of files. Downstreams (OS
# > packagers) often need to build your package in an environment that does
# > not have git (on purpose).
# > https://packaging.rubystyle.guide/#using-git-in-gemspec
#
# By convention, the `.gemspec` is omitted. Tests and related files (like
# `Gemfile`) are omitted. Documentation is omitted because it would double
# gem size. See discussion:
# https://github.com/paper-trail-gem/paper_trail/pull/1279#pullrequestreview-558840513
s.files = Dir["lib/**/*", "LICENSE"].reject { |f| File.directory?(f) }
s.executables = []
s.require_paths = ["lib"]