user2317515
user2317515

Reputation: 41

What are the best practices for updating a gemspec's file list?

Regarding the files list for gemspecs.

I've noticed that jeweler updates this list manually with a listing of files in the project. e.g.

Gem::Specification.new do |s|
  # stuff

  s.files = [
    "lib/somegem.rb",
    "README.md"
  ]
  # ... more stuff

end

Is there any evidence that using git ls-files or Dir.glob('**/*') to dynamically generate the file list for a gemspec causes performance problems when using gems inside projects (especially rails projects)? e.g?

Gem::Specification.new do |s|
  # stuff

  s.files = `git ls-files`.split("\n")
  # ... more stuff

end

Upvotes: 4

Views: 1276

Answers (1)

infused
infused

Reputation: 24337

Its perfectly fine to generate the list of files dynamically. As a matter of fact, the Gemspec Specification docs show several ways to do this.

From the Rubygems docs:

require 'rake'
spec.files = FileList['lib     .rb',
                      'bin/*',
                      '[A-Z]*',
                      'test/   *'].to_a

# or without Rake...
spec.files = Dir['lib/   *.rb'] + Dir['bin/*']
spec.files += Dir['[A-Z]*'] + Dir['test/**/*']
spec.files.reject! { |fn| fn.include? "CVS" }

I would stick with the methods above and not use git ls-files, because I would not assume that every system using the gem will have git installed on it.

Upvotes: 1

Related Questions