11 Ruby Gems

Deepak Hagadur Bheemaraju
Deepak Hagadur BheemarajuSenior Software Engineer um PHE
Deepak H B
Full-Stack Developer
Gmail: deepakhb2@gmail.com
Linkedin: http://in.linkedin.com/in/deepakhb
GitHub: https://github.com/deepakhb2
Ruby Gems
Introduction
• The gem command allows you to interact with RubyGems.
• Finding Gems
$gem search rails
• To find more info on gems
$gem search rails –d
• The install command downloads and installs the gem and any necessary
dependencies then builds documentation for the installed gems.
$gem install rails
• The list of installed gems can be viewed by running following command
$gem list
• Uninstallin gems
$gem uninstall rails
• If you uninstall a dependency of a gem, RubyGems will ask for
confirmation before uninstalling.
• The documents can be viewed by using ri.
$ri RBTree
• You can view the documentation for your installed gem in your browser
with server command
$gem server
Structure of Gem
• Each gem has name version and platform
• RubyGems platform is ruby, which means it works on
any platform Ruby runs on.
Compnents of Ruby gems
• Code
• Documentation
• Gemspec
Contd..
• Each gem follows the same standard structure of
code organization
freewill/
├── bin/
│ └── freewill
├── lib/
│ └── freewill.rb
├── test/
│ └── test_freewill.rb
├── README
├── Rakefile
└── freewill.gemspec
Contd..
• The lib directory contains the code for the gem
• The test or spec directory contains tests, depending on
which test framework the developer uses.
• The gem usually has a Rakefile. Which the rake program
used to automate tests, generate code and perform other
tasks.
• Documentation is usally included in the README and inline
with the code.
• The final piece is the gemspec, which contains the
information about the gem.
Contd..
% cat freewill.gemspec
Gem::Specification.new do |s|
s.name = 'freewill‘
s.version = '1.0.0'
s.summary = "Freewill!"
s.description = "I will choose Freewill!"
s.authors = ["Nick Quaranto"]
s.email = 'nick@quaran.to‘
s.homepage = 'http://example.com/freewill'
s.files = ["lib/freewill.rb", ...]
end
Making your own gem
• Creating publishing your own gem is simple thanks to the tools baked
right into RubyGems.
• Create the folder containing hello.gemspec, lib and lib/hello.rb
• The code for your package is placed inside lib.
• The code inside of lib/hello.rb is pretty bare bones.
$cat lib/hello.rb
• The content for gemspec needs to be updated.
• After you have created gemspec , you can build the gem from it.
gem build hello.gemspec
• Then you can install the generated gem locally to test it out.
• This gem can be pushed to to ruby gems by running following command.
Gem push hello-0.0.0.gem
Name your gem
Gem name Require statement Main class or module
fancy_require require 'fancy_require' FancyRequire
ruby_parser require 'ruby_parser' RubyParser
net-http-persistent require
'net/http/persistent' Net::HTTP::Persistent
rdoc-data require 'rdoc/data' RDoc::Data
autotest-growl require 'autotest/growl' Autotest::Growl
net-http-digest_auth require
'net/http/digest_auth' Net::HTTP::DigestAuth
Contd..
• If you publish a gem on rubygems.org it may be removed if the
name is objectionalble, violates intellectual property or the
contents of the gem meet these criteria.
• You can also report such a gem on the RugyGems support site.
• Don’t use upper case letters.
• Use underscore for multiple words
– If a class or module has multiple words, use underscores to
separate them.
– This matches the file the user will require, making is easier for
the use to start using your gem.
Contd..
• Mix underscore and dashes appropriately.
– If your class or module has multiple words and your also adding
functionality to another gem, follow both of the rules above.
– Example, “net-http-digest_auth adds HTTP digest authentication
to net/http.
– The user will require “net/http/digest_aut” to use the extension
“Net::HTTP::DigestAuth.
• Use dashes for extensions.
– If your adding functionality to another gem, use a dash.
– This usually correspond to a / in the require statement and :: in
the name of your main class or module
Publishing to RubyGems.org
• The simplest way to distribute a gem for public consumption is to
use RubyGems.org.
• Gems that are published to RubyGems.org can be installed via the
gem install command.
• To begin, you will need to create an account on RubyGems.org.
• After creating the account, use your email and password when
pushing the gem.
• RubyGems saves the credentials in ~/.gem/credentials for you so
you only need to log in once.
1 von 12

Recomendados

Nodeconf npm 2011 von
Nodeconf npm 2011Nodeconf npm 2011
Nodeconf npm 2011Florent Jaby ヅ
841 views69 Folien
LAWDI - Rogue Linked Data von
LAWDI - Rogue Linked DataLAWDI - Rogue Linked Data
LAWDI - Rogue Linked DataRyan Baumann
410 views29 Folien
MongoDB at RubyEnRails 2009 von
MongoDB at RubyEnRails 2009MongoDB at RubyEnRails 2009
MongoDB at RubyEnRails 2009Mike Dirolf
885 views41 Folien
Rack von
RackRack
Rackshaokun
1.1K views21 Folien
WordPress Harrisburg Meetup - Best Practices von
WordPress Harrisburg Meetup - Best PracticesWordPress Harrisburg Meetup - Best Practices
WordPress Harrisburg Meetup - Best Practicesryanduff
1.8K views17 Folien
doing_it_right() with WordPress von
doing_it_right() with WordPressdoing_it_right() with WordPress
doing_it_right() with WordPressryanduff
605 views18 Folien

Más contenido relacionado

Was ist angesagt?

Martin Splitt "A short history of the web" von
Martin Splitt "A short history of the web"Martin Splitt "A short history of the web"
Martin Splitt "A short history of the web"Fwdays
569 views64 Folien
The JSON REST API for WordPress von
The JSON REST API for WordPressThe JSON REST API for WordPress
The JSON REST API for WordPressTaylor Lovett
30.9K views37 Folien
CouchDB: A NoSQL database von
CouchDB: A NoSQL databaseCouchDB: A NoSQL database
CouchDB: A NoSQL databaseRubyc Slides
770 views10 Folien
Please dont touch-3.6-jsday von
Please dont touch-3.6-jsdayPlease dont touch-3.6-jsday
Please dont touch-3.6-jsdayFrancesco Fullone
1.1K views87 Folien
Node js getting started von
Node js getting startedNode js getting started
Node js getting startedPallavi Srivastava
309 views7 Folien
Your first sinatra app von
Your first sinatra appYour first sinatra app
Your first sinatra appRubyc Slides
861 views18 Folien

Was ist angesagt?(20)

Martin Splitt "A short history of the web" von Fwdays
Martin Splitt "A short history of the web"Martin Splitt "A short history of the web"
Martin Splitt "A short history of the web"
Fwdays569 views
The JSON REST API for WordPress von Taylor Lovett
The JSON REST API for WordPressThe JSON REST API for WordPress
The JSON REST API for WordPress
Taylor Lovett30.9K views
CouchDB: A NoSQL database von Rubyc Slides
CouchDB: A NoSQL databaseCouchDB: A NoSQL database
CouchDB: A NoSQL database
Rubyc Slides770 views
Your first sinatra app von Rubyc Slides
Your first sinatra appYour first sinatra app
Your first sinatra app
Rubyc Slides861 views
Real-time search in Drupal. Meet Elasticsearch von Alexei Gorobets
Real-time search in Drupal. Meet ElasticsearchReal-time search in Drupal. Meet Elasticsearch
Real-time search in Drupal. Meet Elasticsearch
Alexei Gorobets8.1K views
[Blibli Brown Bag] Nodejs - The Other Side of Javascript von Irfan Maulana
[Blibli Brown Bag] Nodejs - The Other Side of Javascript[Blibli Brown Bag] Nodejs - The Other Side of Javascript
[Blibli Brown Bag] Nodejs - The Other Side of Javascript
Irfan Maulana1K views
PHP Indonesia - Nodejs Web Development von Irfan Maulana
PHP Indonesia - Nodejs Web DevelopmentPHP Indonesia - Nodejs Web Development
PHP Indonesia - Nodejs Web Development
Irfan Maulana1.8K views
Afrimadoni the power of docker von PHP Indonesia
Afrimadoni   the power of dockerAfrimadoni   the power of docker
Afrimadoni the power of docker
PHP Indonesia408 views
Apache Sling as an OSGi-powered REST middleware von Robert Munteanu
Apache Sling as an OSGi-powered REST middlewareApache Sling as an OSGi-powered REST middleware
Apache Sling as an OSGi-powered REST middleware
Robert Munteanu1.6K views
Getting started with node JS von Hamdi Hmidi
Getting started with node JSGetting started with node JS
Getting started with node JS
Hamdi Hmidi528 views
OpenERP and Perl von OpusVL
OpenERP and PerlOpenERP and Perl
OpenERP and Perl
OpusVL1.5K views
Ng init | EPI Sousse von Hamdi Hmidi
Ng init | EPI SousseNg init | EPI Sousse
Ng init | EPI Sousse
Hamdi Hmidi526 views
Intro to Rails and MVC von Sarah Allen
Intro to Rails and MVCIntro to Rails and MVC
Intro to Rails and MVC
Sarah Allen652 views
High Performance Front-End Development von drywallbmb
High Performance Front-End DevelopmentHigh Performance Front-End Development
High Performance Front-End Development
drywallbmb779 views

Similar a 11 Ruby Gems

Creating Ruby Gems von
Creating Ruby Gems Creating Ruby Gems
Creating Ruby Gems Flatiron School
681 views9 Folien
Install Guide von
Install GuideInstall Guide
Install GuideSantosh Kiran Beyagudem
436 views13 Folien
Everything-as-code - A polyglot adventure von
Everything-as-code - A polyglot adventureEverything-as-code - A polyglot adventure
Everything-as-code - A polyglot adventureQAware GmbH
922 views55 Folien
Everything-as-code. A polyglot adventure. #DevoxxPL von
Everything-as-code. A polyglot adventure. #DevoxxPLEverything-as-code. A polyglot adventure. #DevoxxPL
Everything-as-code. A polyglot adventure. #DevoxxPLMario-Leander Reimer
203 views55 Folien
Gemification for Ruby 2.5/3.0 von
Gemification for Ruby 2.5/3.0Gemification for Ruby 2.5/3.0
Gemification for Ruby 2.5/3.0Hiroshi SHIBATA
9K views62 Folien
Exploring Ruby on Rails and PostgreSQL von
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQLBarry Jones
3.2K views60 Folien

Similar a 11 Ruby Gems(20)

Everything-as-code - A polyglot adventure von QAware GmbH
Everything-as-code - A polyglot adventureEverything-as-code - A polyglot adventure
Everything-as-code - A polyglot adventure
QAware GmbH922 views
Exploring Ruby on Rails and PostgreSQL von Barry Jones
Exploring Ruby on Rails and PostgreSQLExploring Ruby on Rails and PostgreSQL
Exploring Ruby on Rails and PostgreSQL
Barry Jones3.2K views
The Future of library dependency manageement of Ruby von Hiroshi SHIBATA
The Future of library dependency manageement of RubyThe Future of library dependency manageement of Ruby
The Future of library dependency manageement of Ruby
Hiroshi SHIBATA988 views
Week6 von reneedv
Week6Week6
Week6
reneedv293 views
Writing a Ruby Gem for beginners von ConFoo
Writing a Ruby Gem for beginnersWriting a Ruby Gem for beginners
Writing a Ruby Gem for beginners
ConFoo2.4K views
Modeling Tricks My Relational Database Never Taught Me von David Boike
Modeling Tricks My Relational Database Never Taught MeModeling Tricks My Relational Database Never Taught Me
Modeling Tricks My Relational Database Never Taught Me
David Boike5.3K views
Web Development with Python and Django von Michael Pirnat
Web Development with Python and DjangoWeb Development with Python and Django
Web Development with Python and Django
Michael Pirnat188.7K views
JavaScript : A trending scripting language von AbhayDhupar
JavaScript : A trending scripting languageJavaScript : A trending scripting language
JavaScript : A trending scripting language
AbhayDhupar68 views
An introduction to Rails 3 von Blazing Cloud
An introduction to Rails 3An introduction to Rails 3
An introduction to Rails 3
Blazing Cloud846 views
Jasig rubyon rails von _zaMmer_
Jasig rubyon railsJasig rubyon rails
Jasig rubyon rails
_zaMmer_290 views
Jasig rubyon rails von _zaMmer_
Jasig rubyon railsJasig rubyon rails
Jasig rubyon rails
_zaMmer_271 views
Web Development using Ruby on Rails von Avi Kedar
Web Development using Ruby on RailsWeb Development using Ruby on Rails
Web Development using Ruby on Rails
Avi Kedar628 views

Más de Deepak Hagadur Bheemaraju

12 Introduction to Rails von
12 Introduction to Rails12 Introduction to Rails
12 Introduction to RailsDeepak Hagadur Bheemaraju
210 views62 Folien
10 Networking von
10 Networking10 Networking
10 NetworkingDeepak Hagadur Bheemaraju
113 views11 Folien
9 Inputs & Outputs von
9 Inputs & Outputs9 Inputs & Outputs
9 Inputs & OutputsDeepak Hagadur Bheemaraju
194 views11 Folien
8 Exception Handling von
8 Exception Handling8 Exception Handling
8 Exception HandlingDeepak Hagadur Bheemaraju
196 views17 Folien
7 Methods and Functional Programming von
7  Methods and Functional Programming7  Methods and Functional Programming
7 Methods and Functional ProgrammingDeepak Hagadur Bheemaraju
129 views37 Folien
6 Object Oriented Programming von
6 Object Oriented Programming6 Object Oriented Programming
6 Object Oriented ProgrammingDeepak Hagadur Bheemaraju
124 views39 Folien

Último

Gopal Chakraborty Memorial Quiz 2.0 Prelims.pptx von
Gopal Chakraborty Memorial Quiz 2.0 Prelims.pptxGopal Chakraborty Memorial Quiz 2.0 Prelims.pptx
Gopal Chakraborty Memorial Quiz 2.0 Prelims.pptxDebapriya Chakraborty
684 views81 Folien
Recap of our Class von
Recap of our ClassRecap of our Class
Recap of our ClassCorinne Weisgerber
81 views15 Folien
Google solution challenge..pptx von
Google solution challenge..pptxGoogle solution challenge..pptx
Google solution challenge..pptxChitreshGyanani1
135 views18 Folien
ACTIVITY BOOK key water sports.pptx von
ACTIVITY BOOK key water sports.pptxACTIVITY BOOK key water sports.pptx
ACTIVITY BOOK key water sports.pptxMar Caston Palacio
745 views4 Folien
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB... von
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...Nguyen Thanh Tu Collection
73 views113 Folien
The basics - information, data, technology and systems.pdf von
The basics - information, data, technology and systems.pdfThe basics - information, data, technology and systems.pdf
The basics - information, data, technology and systems.pdfJonathanCovena1
126 views1 Folie

Último(20)

BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB... von Nguyen Thanh Tu Collection
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
BÀI TẬP BỔ TRỢ TIẾNG ANH 11 THEO ĐƠN VỊ BÀI HỌC - CẢ NĂM - CÓ FILE NGHE (GLOB...
The basics - information, data, technology and systems.pdf von JonathanCovena1
The basics - information, data, technology and systems.pdfThe basics - information, data, technology and systems.pdf
The basics - information, data, technology and systems.pdf
JonathanCovena1126 views
Dance KS5 Breakdown von WestHatch
Dance KS5 BreakdownDance KS5 Breakdown
Dance KS5 Breakdown
WestHatch86 views
Ch. 8 Political Party and Party System.pptx von Rommel Regala
Ch. 8 Political Party and Party System.pptxCh. 8 Political Party and Party System.pptx
Ch. 8 Political Party and Party System.pptx
Rommel Regala53 views
Pharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptx von Ms. Pooja Bhandare
Pharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptxPharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptx
Pharmaceutical Inorganic chemistry UNIT-V Radiopharmaceutical.pptx
REPRESENTATION - GAUNTLET.pptx von iammrhaywood
REPRESENTATION - GAUNTLET.pptxREPRESENTATION - GAUNTLET.pptx
REPRESENTATION - GAUNTLET.pptx
iammrhaywood107 views
Ch. 7 Political Participation and Elections.pptx von Rommel Regala
Ch. 7 Political Participation and Elections.pptxCh. 7 Political Participation and Elections.pptx
Ch. 7 Political Participation and Elections.pptx
Rommel Regala105 views
The Accursed House by Émile Gaboriau von DivyaSheta
The Accursed House  by Émile GaboriauThe Accursed House  by Émile Gaboriau
The Accursed House by Émile Gaboriau
DivyaSheta212 views

11 Ruby Gems

  • 1. Deepak H B Full-Stack Developer Gmail: deepakhb2@gmail.com Linkedin: http://in.linkedin.com/in/deepakhb GitHub: https://github.com/deepakhb2
  • 3. Introduction • The gem command allows you to interact with RubyGems. • Finding Gems $gem search rails • To find more info on gems $gem search rails –d • The install command downloads and installs the gem and any necessary dependencies then builds documentation for the installed gems. $gem install rails • The list of installed gems can be viewed by running following command $gem list • Uninstallin gems $gem uninstall rails • If you uninstall a dependency of a gem, RubyGems will ask for confirmation before uninstalling. • The documents can be viewed by using ri. $ri RBTree • You can view the documentation for your installed gem in your browser with server command $gem server
  • 4. Structure of Gem • Each gem has name version and platform • RubyGems platform is ruby, which means it works on any platform Ruby runs on. Compnents of Ruby gems • Code • Documentation • Gemspec
  • 5. Contd.. • Each gem follows the same standard structure of code organization freewill/ ├── bin/ │ └── freewill ├── lib/ │ └── freewill.rb ├── test/ │ └── test_freewill.rb ├── README ├── Rakefile └── freewill.gemspec
  • 6. Contd.. • The lib directory contains the code for the gem • The test or spec directory contains tests, depending on which test framework the developer uses. • The gem usually has a Rakefile. Which the rake program used to automate tests, generate code and perform other tasks. • Documentation is usally included in the README and inline with the code. • The final piece is the gemspec, which contains the information about the gem.
  • 7. Contd.. % cat freewill.gemspec Gem::Specification.new do |s| s.name = 'freewill‘ s.version = '1.0.0' s.summary = "Freewill!" s.description = "I will choose Freewill!" s.authors = ["Nick Quaranto"] s.email = 'nick@quaran.to‘ s.homepage = 'http://example.com/freewill' s.files = ["lib/freewill.rb", ...] end
  • 8. Making your own gem • Creating publishing your own gem is simple thanks to the tools baked right into RubyGems. • Create the folder containing hello.gemspec, lib and lib/hello.rb • The code for your package is placed inside lib. • The code inside of lib/hello.rb is pretty bare bones. $cat lib/hello.rb • The content for gemspec needs to be updated. • After you have created gemspec , you can build the gem from it. gem build hello.gemspec • Then you can install the generated gem locally to test it out. • This gem can be pushed to to ruby gems by running following command. Gem push hello-0.0.0.gem
  • 9. Name your gem Gem name Require statement Main class or module fancy_require require 'fancy_require' FancyRequire ruby_parser require 'ruby_parser' RubyParser net-http-persistent require 'net/http/persistent' Net::HTTP::Persistent rdoc-data require 'rdoc/data' RDoc::Data autotest-growl require 'autotest/growl' Autotest::Growl net-http-digest_auth require 'net/http/digest_auth' Net::HTTP::DigestAuth
  • 10. Contd.. • If you publish a gem on rubygems.org it may be removed if the name is objectionalble, violates intellectual property or the contents of the gem meet these criteria. • You can also report such a gem on the RugyGems support site. • Don’t use upper case letters. • Use underscore for multiple words – If a class or module has multiple words, use underscores to separate them. – This matches the file the user will require, making is easier for the use to start using your gem.
  • 11. Contd.. • Mix underscore and dashes appropriately. – If your class or module has multiple words and your also adding functionality to another gem, follow both of the rules above. – Example, “net-http-digest_auth adds HTTP digest authentication to net/http. – The user will require “net/http/digest_aut” to use the extension “Net::HTTP::DigestAuth. • Use dashes for extensions. – If your adding functionality to another gem, use a dash. – This usually correspond to a / in the require statement and :: in the name of your main class or module
  • 12. Publishing to RubyGems.org • The simplest way to distribute a gem for public consumption is to use RubyGems.org. • Gems that are published to RubyGems.org can be installed via the gem install command. • To begin, you will need to create an account on RubyGems.org. • After creating the account, use your email and password when pushing the gem. • RubyGems saves the credentials in ~/.gem/credentials for you so you only need to log in once.