Skip to content

Commit

Permalink
Remove docs & tests from gem to reduce its size by over 50%
Browse files Browse the repository at this point in the history
I was looking through https://rubygems.org/gems/mocha/versions and
noticed the .gem's file size increased from 94kb in v1.7.0 to 219kb in
v1.8.0 - an increase of 125kb.

The culprit seems to be the addition of generated docs to the repo in
4a85555. I don't think there reasonable
value in including the generated docs in the compiled .gem, especially
for the byte size increase. Gem users still can locally still produce
documentation with rdoc/ri. I've also removed the test directory, since
they are not useful to gem users.

I'm using the syntax from the gemspec used in `bundle gem` [1].

[1]: https://github.com/rubygems/bundler/blob/v2.1.4/lib/bundler/templates/newgem/newgem.gemspec.tt#L23-L27
  • Loading branch information
gabetax authored and floehopper committed Dec 23, 2020
1 parent e5b9fee commit a84ab9d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mocha.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ Gem::Specification.new do |s| # rubocop:disable Metrics/BlockLength
s.description = 'Mocking and stubbing library with JMock/SchMock syntax, which allows mocking and stubbing of methods on real (non-mock) classes.'
s.email = 'mocha-developer@googlegroups.com'

s.files = `git ls-files`.split("\n")
s.files = Dir.chdir(File.expand_path('..', __FILE__)) do
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(docs|test)/}) }
end
s.files.delete('.travis.yml')
s.files.delete('.gitignore')

Expand Down

0 comments on commit a84ab9d

Please sign in to comment.