Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making a Ruby project that is not a gem (or some other kind)

I'm working on a project currently that I don't want to be a gem (or some other kind of project). How would I go about setting it up so that I can still have the same compatibility requirement abilities as a gem (e.g. Gemfile dependencies) but simultaneously not be a gem (or some other kind of project)?

like image 831
T145 Avatar asked Dec 06 '13 16:12

T145


People also ask

What is gem require false?

You use :require => false when you want the gem to be installed but not "required". So in the example you gave: gem 'whenever', :require => false when someone runs bundle install the whenever gem would be installed as with gem install whenever .


1 Answers

You have to actually try to build a gem so this is easy!

to use bundler without Rails, a gem, whatever just create a directory

  mkdir my-non-gem-project
  cd my-non-gem-project

install bundler

  gem install bundler

and initialize your Gemfile

  bundle init

that will create a Gemfile for you and you can add to it and run bundle to install the dependencies from it

The simplest way to use bundler in your project would then be to open your main app file and add

require 'bundler/setup'
Bundler.require

This will require all of the gems you have in your Gemfile in the file this is added to. I am pretty sure that this file must be in the same directory as your Gemfile. More information here

Have fun with your Ruby project!

like image 148
mraaroncruz Avatar answered Sep 29 '22 20:09

mraaroncruz