14

I just created a test gem using bundle and it created a .gem file with unreadable content so I was wondering

  1. what does that .gem file contains ? is this binary data ? as I used to think that .gem files contains packaged ruby functions

  2. how is this .gem file being used by rails framework ? since it doesn't look like a module

Thanks

4

2 回答 2

8

You can see what is happening if you check the file on your file system.

In a Posix environment, you can check the file with the file command:

$: file bundler-1.3.0.gem          
bundler-1.3.0.gem: POSIX tar archive

As you can see it is a tar archive. So it is a binary file, packaged and managed by the gem tool.

It is 'binary' so you will not see it as you may have expected.

You are correct though, and you can continue to think that it contains packaged ruby 'functions'.

Everything that you have told it to contain through your gemspec (however you included it) is there.

As far as how Rails uses the gemfile, it is used generally by installing the gem to your system, how ever that is done is partially dependent on your environment decisions.

于 2013-03-09T09:26:59.887 回答
5

A gem file is just a tar archive containing (at least) a gemspec file. There will also usually be ruby source files and possibly native code or supporting assets (for example a gem designed to be used with rails might also package some javascript). It is also common to include a README, CHANGELOG and other documentation.

于 2013-03-09T09:24:20.603 回答