SlideShare uma empresa Scribd logo
1 de 9
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.
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
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.
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].
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
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’
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
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
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

Mais conteúdo relacionado

Semelhante a Creating Ruby Gems

Writing a Ruby Gem for beginners
Writing a Ruby Gem for beginnersWriting a Ruby Gem for beginners
Writing a Ruby Gem for beginners
ConFoo
 
Your fist RubyMotion Application
Your fist RubyMotion ApplicationYour fist RubyMotion Application
Your fist RubyMotion Application
toamitkumar
 

Semelhante a Creating Ruby Gems (20)

11 Ruby Gems
11 Ruby Gems11 Ruby Gems
11 Ruby Gems
 
Gem That (2009)
Gem That (2009)Gem That (2009)
Gem That (2009)
 
Setup ruby
Setup rubySetup ruby
Setup ruby
 
The Future of Dependency Management for Ruby
The Future of Dependency Management for RubyThe Future of Dependency Management for Ruby
The Future of Dependency Management for Ruby
 
Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0
 
Exploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQL
 
Install Guide
Install GuideInstall Guide
Install Guide
 
Rails onCpanel
Rails onCpanelRails onCpanel
Rails onCpanel
 
Crate - ruby based standalone executables
Crate - ruby based standalone executablesCrate - ruby based standalone executables
Crate - ruby based standalone executables
 
Writing a Ruby Gem for beginners
Writing a Ruby Gem for beginnersWriting a Ruby Gem for beginners
Writing a Ruby Gem for beginners
 
Deploying your rails application to a clean ubuntu 10
Deploying your rails application to a clean ubuntu 10Deploying your rails application to a clean ubuntu 10
Deploying your rails application to a clean ubuntu 10
 
Bundler
BundlerBundler
Bundler
 
Create your-own-gem-with-github-jeweler-rubygems
Create your-own-gem-with-github-jeweler-rubygemsCreate your-own-gem-with-github-jeweler-rubygems
Create your-own-gem-with-github-jeweler-rubygems
 
Your fist RubyMotion Application
Your fist RubyMotion ApplicationYour fist RubyMotion Application
Your fist RubyMotion Application
 
An introduction to Rails 3
An introduction to Rails 3An introduction to Rails 3
An introduction to Rails 3
 
Ruby on Rails - An overview
Ruby on Rails -  An overviewRuby on Rails -  An overview
Ruby on Rails - An overview
 
How DSL works on Ruby
How DSL works on RubyHow DSL works on Ruby
How DSL works on Ruby
 
The story of language development
The story of language developmentThe story of language development
The story of language development
 
Ruby on rails toolbox
Ruby on rails toolboxRuby on rails toolbox
Ruby on rails toolbox
 
RoR (Ruby on Rails)
RoR (Ruby on Rails)RoR (Ruby on Rails)
RoR (Ruby on Rails)
 

Mais de Flatiron School

Mais de Flatiron School (13)

How to Leverage Your Network to Land Your First Job as a Developer
How to Leverage Your Network to Land Your First Job as a DeveloperHow to Leverage Your Network to Land Your First Job as a Developer
How to Leverage Your Network to Land Your First Job as a Developer
 
Pay and Get Paid: How To Integrate Stripe Into Your App
Pay and Get Paid: How To Integrate Stripe Into Your AppPay and Get Paid: How To Integrate Stripe Into Your App
Pay and Get Paid: How To Integrate Stripe Into Your App
 
Pick-a-Plex App: The Pinnacle of Cinema Experiences
Pick-a-Plex App: The Pinnacle of Cinema ExperiencesPick-a-Plex App: The Pinnacle of Cinema Experiences
Pick-a-Plex App: The Pinnacle of Cinema Experiences
 
Play Music...With Your Head: A Theremin App For Everyone
Play Music...With Your Head: A Theremin App For EveryonePlay Music...With Your Head: A Theremin App For Everyone
Play Music...With Your Head: A Theremin App For Everyone
 
Four Days Out: Quick Itineraries For Last-Minute Dates
Four Days Out: Quick Itineraries For Last-Minute DatesFour Days Out: Quick Itineraries For Last-Minute Dates
Four Days Out: Quick Itineraries For Last-Minute Dates
 
Into to Node.js: Building Fast, Scaleable Network Applications
Into to Node.js: Building Fast, Scaleable Network ApplicationsInto to Node.js: Building Fast, Scaleable Network Applications
Into to Node.js: Building Fast, Scaleable Network Applications
 
What's a Core Image? An Image-Processing Framework on iOS and OS X
What's a Core Image? An Image-Processing Framework on iOS and OS XWhat's a Core Image? An Image-Processing Framework on iOS and OS X
What's a Core Image? An Image-Processing Framework on iOS and OS X
 
Intro to D3: Data-Driven Documents
Intro to D3: Data-Driven DocumentsIntro to D3: Data-Driven Documents
Intro to D3: Data-Driven Documents
 
Database Opt
Database Opt Database Opt
Database Opt
 
Citi Bike Finder
Citi Bike FinderCiti Bike Finder
Citi Bike Finder
 
FOMO No Mo'
FOMO No Mo' FOMO No Mo'
FOMO No Mo'
 
JSON overview and demo
JSON overview and demoJSON overview and demo
JSON overview and demo
 
Form Helpers
Form Helpers Form Helpers
Form Helpers
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Último (20)

Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 

Creating Ruby Gems

  • 1. CREATING RUBY GEMS BY AMBER TUNNELL AND BEN SHORE Creating Ruby Gems - Tunnell & Shore
  • 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. 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. 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. 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. 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. 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. 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. 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