Skip to content

Commit

Permalink
Include minimum files in packed gem (#91)
Browse files Browse the repository at this point in the history
* Include minimum files in packed gem

This aims to reduce the gem size by excluding unneeded files like test files, CI files, etc.
Note that `test_files` in a gemspec is no longer supported.

Gem size diff:

```sh-session
$ du -h database_rewinder-1.0.1.gem*
 12K	database_rewinder-1.0.1.gem
 16K	database_rewinder-1.0.1.gem.old
```

Newly included files in the gem:

```sh-session
$ tree -aF database_rewinder-1.0.1
database_rewinder-1.0.1/
├── MIT_LICENSE
├── README.md
└── lib/
    ├── database_rewinder/
    │   ├── active_record_monkey.rb
    │   ├── cleaner.rb
    │   ├── compatibility.rb
    │   ├── dummy_model.rb
    │   ├── multiple_statements_executor.rb
    │   └── railtie.rb
    └── database_rewinder.rb

3 directories, 9 files
```

* Prefer `git ls-files` to exclude unexpected files
  • Loading branch information
ybiquitous authored Jul 10, 2024
1 parent 11b383b commit 551e547
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions database_rewinder.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ Gem::Specification.new do |spec|
spec.homepage = 'https://github.com/amatsuda/database_rewinder'
spec.license = "MIT"

spec.files = `git ls-files`.split($/)
spec.files = `git ls-files lib/ MIT_LICENSE README.md`.split
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]

spec.add_development_dependency 'bundler'
Expand Down

0 comments on commit 551e547

Please sign in to comment.