CREATING
RUBY
GEMS
BY AMBER TUNNELL
AND BEN SHORE
Creating Ruby Gems - Tunnell & Shore
WHAT IS A GEM?
• A RubyGem is a package manager that provides a
standardized format for distributing Ruby programs.
Popula...
LET’S CREATE A GEM
Use “Bundler” to create the standard directory of files
needed for your Gem.
Creating Ruby Gems - Tunne...
A LOOK AT SOME KEY
FILES
This is where you will tell the world what your
Gem does, how to install it, and how to use it.
C...
SETTING UP THE
GEMSPEC
Gem::Specification.new do |spec|
spec.name = "your_gem_name"
spec.version = gem_name::VERSION
spec....
USING RAKE TO BUILD
AND INSTALL
• Run to see a list of available rake tasks
provided by bundler. You should see:
• Run to ...
RELEASE IT TO THE
WORLD
• Create an account at RubyGems.org
• Make sure you have everything working (you should build
some...
WE BUILT A GEM
• Feel free to download it:
A web-scraping gem that provides live news updates related
to the High Yield Bo...
ADDITIONAL RESOURCES
• RubyGems.org Guides (http://guides.rubygems.org/)
• Gem It (http://gemit.us/)
Thank You!
If you hav...
Upcoming SlideShare
Loading in …5
×

Creating Ruby Gems

474 views

Published on

Presented by Liz Baillie and Luke Demarest on July 15, 2014 at The Flatiron School.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
474
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
3
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Creating Ruby Gems

  1. 1. CREATING RUBY GEMS BY AMBER TUNNELL AND BEN SHORE Creating Ruby Gems - Tunnell & Shore
  2. 2. WHAT IS A GEM? • A RubyGem is a package manager that provides a standardized format for distributing Ruby programs. Popular Gems include: • Gems provide pre-made code to Ruby users, increasing functionality and efficiency • They also allow for “lighter” applications because the Gem code does not need to be a part of the application. Creating Ruby Gems - Tunnell & Shore
  3. 3. LET’S CREATE A GEM Use “Bundler” to create the standard directory of files needed for your Gem. Creating Ruby Gems - Tunnell & Shore $ bundle gem your_gem_name This is the Gem directory Bundler will create locally. Let’s look at these files more closely.
  4. 4. A LOOK AT SOME KEY FILES This is where you will tell the world what your Gem does, how to install it, and how to use it. Creating Ruby Gems - Tunnell & Shore README.rdoc lib/your_gems_name.rb Gemfile lib/your_gems_name/version.rb This is where your application’s code will live. Your Gem will need a version in order to work at all. Try to follow the Ruby A very minimal file, most of the leg work happens in the gemspec file [next slide].
  5. 5. SETTING UP THE GEMSPEC Gem::Specification.new do |spec| spec.name = "your_gem_name" spec.version = gem_name::VERSION spec.authors = ["author’s name"] spec.email = ["author’s email"] spec.summary = %q{SHORT DESC} spec.description = %q{LONG DESC} … spec.add_development_dependency "bundler", "~> 1.6" spec.add_development_dependency "rake" spec.add_runtime_dependency "nokogiri" end Creating Ruby Gems - Tunnell & Shore
  6. 6. USING RAKE TO BUILD AND INSTALL • Run to see a list of available rake tasks provided by bundler. You should see: • Run to add the Gem to your local system. • To test for the successful installation, run and see if it appears. • Next hop into IRB and , if it returns true, you are in business. Creating Ruby Gems - Tunnell & Shore $ rake -T rake build # Build your_gem_name-0.0.1.gem into the pkg directory rake install # Build and install your_gem_name-0.0.1.gem into system gems rake release # Creates tag v0.0.1 and build and push your_gem_name-0.0.1.g. $ rake install $ gem list require ‘your_gem_name’
  7. 7. RELEASE IT TO THE WORLD • Create an account at RubyGems.org • Make sure you have everything working (you should build some tests) and that your work has been committed • Run • Dude, you are officially the author of a RubyGem! Creating Ruby Gems - Tunnell & Shore $ rake release
  8. 8. WE BUILT A GEM • Feel free to download it: A web-scraping gem that provides live news updates related to the High Yield Bond Markets. Anticipating 10+ million downloads this week. Creating Ruby Gems - Tunnell & Shore $ gem install hybondnews
  9. 9. ADDITIONAL RESOURCES • RubyGems.org Guides (http://guides.rubygems.org/) • Gem It (http://gemit.us/) Thank You! If you have questions, contact us! Amber - amber.tunnell@flatironschool.com Ben - benjamin.shore@flatironschool.com Creating Ruby Gems - Tunnell & Shore

×