Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does a .gem file contain? How it is being used by Rails framework?

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

like image 495
iCyborg Avatar asked Mar 09 '13 09:03

iCyborg


People also ask

What is RubyGems How does it work?

The RubyGems software allows you to easily download, install, and use ruby software packages on your system. The software package is called a “gem” which contains a packaged Ruby application or library. Gems can be used to extend or modify functionality in Ruby applications.

How do I play a .gem file?

ThunderSoft GemPlayer is a free video player which supports password protected video file(GEM file) and many other common media files. It is powerful that can play all the most popular video/audio format. And it is the only player which can play GEM file, an encrypted video format.

Where is Gemfile in Ruby on Rails?

Gemfile is a file which must be located in root of your rails project. It is used for describing gem dependencies for Ruby programs.

What is a gem in rails?

Gems in Rails are libraries that allow any Ruby on Rails developer to add functionalities without writing code. You can also call Ruby on Rails gems as plugins for adding features. A Ruby gem enables adding features without creating the code again and again.


1 Answers

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.

like image 118
vgoff Avatar answered Oct 05 '22 08:10

vgoff