#245 New Gem with Bundler
Dec 20, 2010 | 7 minutes | Tools
Creating new gems is easy with the `bundle gem` command. In this episode I will walk you through how this works.
- source codeProject Files in Zip (3.62 KB)
- mp4Full Size H.264 Video (20.1 MB)
- m4vSmaller H.264 Video (9.2 MB)
- webmFull Size VP8 Video (22.5 MB)
- ogvFull Size Theora Video (16.8 MB)
Nice episode, Ryan. I still prefer Jeweler, though.
Wonderful Ryan. It's a great idea to revisit old topics showcasing the new improved ways to do things.
I like that you import info from github. FYI: The link to the website prepends http://railscast.com/users/www.rorecommerce.com
I was just looking for some information on how to put together a Gem so this is great! Also I noticed that the "Full episode source code" doesn't appear to point to the correct location.
Nice work again Ryan. Just thought of an idea for an episode for you:
Making the number of items on the page with will_paginate dependent on css3 media queries? Seems to be a good idea to me - if I am on a mobile browser I might only want to see one item on the page, but if I am on a large screen I might be able to see ten or more.
You might also want to look at using Ore (http://github.com/ruby-ore/ore#readme) which stores all project information in a single YAML file, inferring the rest.
Unlike Jeweler, Ore does not regenerate any files or make commits for you. Unlike Hoe, Ore does not need to keep a Manifest and does not add itself as a development dependency. Ore works fine with Bundler and can even be used with Jeweler::Tasks.
In case anyone might be interested, to complement the `bundle gem` approach (more generally, the approach of making the gemspec file authoritative), I've put together a small collection of Rake tasks (clean, compile, cucumber, rdoc, ronn, test), that look to the gemspec, .gitignore, cucumber.yml for their configuration:
(Perhaps it needs a rename -- "shoe" shares form with "hoe" and "echoe", but it also sounds too much like _why's Shoes.)
This was very helpful. I did have an issue with signing up for Rubygems -- I get an internal server error when trying to create an account. But otherwise, a great intro and it inspired me to create my first gem.
Thanks for the share! It's a very useful post. I already used it.
I created a post based on this post, to demonstrate a sample Rakefile to use with this Railscast
Do I need to use require statement in rails to use this gem. When I just do gem lorem it loads but the lorem.rb module is not available. please help
Very useful. Now I just need to go back and look at your episode on adding your own custom gem to another app.
Don't forget to git commit new files as you develop with bundler! I forgot this aspect and found myself lost for a few hours when the files I was requiring in my lib/some_gem_name file were not available in the gem!
rake install does not run rake build. at least not on my local machine.
This is probably a stupid question but is the Net::HTTP ruby library a gem or a library included in Ruby and how would I require it and the gems in my gemspec in my files?
Net::HTTP is part of std-lib which is installed with Ruby, you can find the documentation on ruby-doc.org. The links at the top of the page are for Ruby 1.9.3, if you're using an older version you'll have to scroll down to find the matching links.
std-lib will already be in your load path, so you can simply require files in it as you would files within your project:
What you need to require usually matches the name of the left frame in the std-lib documentation. Once you've installed a gem through Bundler you can require it in the same way, what you need to require differs per gem. Usually its the same as the gem's name, however there are exceptions (to be sure check out the documentation of the gems you're using).
I am trying to require the RMagick gem in a gem I'm making. I included it as a dependency in my gemspec file.
and require it before use in my lib/say_hello.rb
After that i bundle install, gem bundle, gem install.
The gem work without the 'require rmagick' but i receive the following error otherwise.
/Users/****/.rvm/gems/ruby-1.9.3-p194/gems/say_hello-0.0.1/lib/say_hello.rb:2:in require': cannot load such file -- rmagick (LoadError)
Can anyone give me some advice on what I am doing wrong?
Thanks in advance..
It's 2017 and the content of these videos are still relevant. Thank you, Ryan!
Amazing .... I'm new here but I've learn a lot. Thanks Ryan.