Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are `files`, `executables`, `test_files`, and `require_paths` in gemspec file?

I am not clear on what certain specifications in the .gemspec file are doing. Specifically,

spec.files         = `git ls-files -z`.split("\x0")
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"]

Can someone explain how these relate to the functionality of a Ruby Gem and why they are necessary?

like image 897
Aaron Avatar asked Aug 07 '14 19:08

Aaron


People also ask

What is a Gemspec file?

Developer file that specifies the attributes of a RubyGems . GEM package; saves information such as the author, a description, an example usage, and the usage license; saved in a simple plain text format.

How do I install gems?

To install a gem, use gem install [gem] . Browsing installed gems is done with gem list . For more information about the gem command, see below or head to RubyGems' docs.


1 Answers

executables:

Executables included in the gem. For example, the rake gem has rake as an executable. These files must be executable Ruby files.

files:

Files included in the gem. These are the files that will be included in your gem when it is built.

require_paths:

Contains an Array of directories and files which should be added to the $LOAD_PATH on gem activation. By default it is ["lib"].

test_files

Test files included in the gem.

like image 71
Jakob S Avatar answered Oct 11 '22 15:10

Jakob S