Skip to content

Reduce gem size by excluding test files#1042

Merged
parndt merged 1 commit intonorman:masterfrom
yuri-zubov:reduce-gem-size
Feb 12, 2026
Merged

Reduce gem size by excluding test files#1042
parndt merged 1 commit intonorman:masterfrom
yuri-zubov:reduce-gem-size

Conversation

@yuri-zubov
Copy link
Copy Markdown
Contributor

This pull request updates the *.gemspec file to optimize the gem package size and structure

$ gem build -o before.tar.gz

$ git switch reduce-gem-size

$ gem build -o after.tar.gz

du -sh before.tar.gz after.tar.gz
 52K	before.tar.gz
 32K	after.tar.gz
Metric Before After Saved
Size 52K 32K −20K (⏷ −40.0%)

whitch files was deleted?

data
-├── .gemtest
-├── .github
-│   ├── dependabot.yml
-│   ├── FUNDING.yml
-│   ├── stale.yml
-│   └── workflows
-│       ├── release.yml
-│       └── test.yml
-├── .gitignore
-├── .yardopts
-├── bench.rb
 ├── Changelog.md
-├── CONTRIBUTING.md
-├── friendly_id.gemspec
-├── Gemfile
-├── gemfiles
-│   ├── Gemfile.rails-6.0.rb
-│   ├── Gemfile.rails-6.1.rb
-│   ├── Gemfile.rails-7.0.rb
-│   ├── Gemfile.rails-7.1.rb
-│   ├── Gemfile.rails-7.2.rb
-│   └── Gemfile.rails-8.0.rb
-├── guide.rb
 ├── lib
 │   ├── friendly_id
 │   │   ├── .gitattributes
 │   │   ├── base.rb
 │   │   ├── candidates.rb
 │   │   ├── configuration.rb
 │   │   ├── finder_methods.rb
 │   │   ├── finders.rb
 │   │   ├── history.rb
 │   │   ├── initializer.rb
 │   │   ├── migration.rb
 │   │   ├── object_utils.rb
 │   │   ├── reserved.rb
 │   │   ├── scoped.rb
 │   │   ├── sequentially_slugged
 │   │   │   └── calculator.rb
 │   │   ├── sequentially_slugged.rb
 │   │   ├── simple_i18n.rb
 │   │   ├── slug_generator.rb
 │   │   ├── slug.rb
 │   │   ├── slugged.rb
 │   │   └── version.rb
 │   ├── friendly_id.rb
 │   └── generators
 │       └── friendly_id_generator.rb
 ├── MIT-LICENSE
-├── Rakefile
 ├── README.md
-├── test
-│   ├── base_test.rb
-│   ├── benchmarks
-│   │   ├── finders.rb
-│   │   └── object_utils.rb
-│   ├── candidates_test.rb
-│   ├── configuration_test.rb
-│   ├── core_test.rb
-│   ├── databases.yml
-│   ├── finders_test.rb
-│   ├── generator_test.rb
-│   ├── helper.rb
-│   ├── history_test.rb
-│   ├── numeric_slug_test.rb
-│   ├── object_utils_test.rb
-│   ├── reserved_test.rb
-│   ├── schema.rb
-│   ├── scoped_test.rb
-│   ├── sequentially_slugged_test.rb
-│   ├── shared.rb
-│   ├── simple_i18n_test.rb
-│   ├── slugged_test.rb
-│   └── sti_test.rb
-└── UPGRADING.md

ps: you can see on rails repo

Comment thread friendly_id.gemspec
s.homepage = "https://github.com/norman/friendly_id"
s.summary = "A comprehensive slugging and pretty-URL plugin."
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test}/*`.split("\n")
Copy link
Copy Markdown
Contributor Author

@yuri-zubov yuri-zubov Feb 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test_files directive is no longer used by RubyGems.org.

Copy link
Copy Markdown
Collaborator

@parndt parndt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, makes sense!

@parndt parndt merged commit cf4b81c into norman:master Feb 12, 2026
42 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants