SlideShare a Scribd company logo
1 of 40
Download to read offline
LET'S MAKE A GEM
WHAT IS A GEM?
LET'S MAKE A GEM
1. Creating a Gem with Bundler
LET'S MAKE A GEM
1. Creating a Gem with Bundler
2. Testing it with rspec
LET'S MAKE A GEM
1. Creating a Gem with Bundler
2. Testing it with rspec
3. Setting up continuous integration
LET'S MAKE A GEM
1. Creating a Gem with Bundler
2. Testing it with rspec
3. Setting up continuous integration
4. Publishing to Rubygems
LET'S MAKE A GEM
1. Creating a Gem with Bundler
2. Testing it with rspec
3. Setting up continuous integration
4. Publishing to Rubygems
5. Publishing to a private gem server
1. Creating a Gem
RVM
BUNDLER
RUBYGEMS
INITIALIZING OUR GEM
$ rvm use 2.1.0
$ gem install bundler
$ bundle gem eleventh
$ cd eleventh
$ rvm --rvmrc --create 2.1.0@eleventh
$ cd ..; cd -
GENERATED STRUCTURE
$ ls
eleventh
|--- README.md
|--- eleventh.gemspec
|--- Rakefile
|--- Gemfile
|--- lib
|--- eleventh.rb
|--- eleventh
|--- version.rb
EXPLORING THE GENERATED STRUCTURE
$ vim eleventh.gemspec
$ vim Gemfile
$ vim lib/eleventh.rb
$ vim lib/eleventh/version.rb
$ rake -T
MAKE IT DO SOMETHING
$ vim lib/eleventh/array_access.rb
$ vim lib/eleventh.rb
$ git add .
$ git commit -m "Version 1"
MAKE IT DO SOMETHING
# ./lib/eleventh/array_access.rb
class Array
def eleventh
self[10]
end
end
# ./lib/eleventh.rb
require "eleventh/version"
require "eleventh/array_access"
module Eleventh
end
2. Testing our gem with rspec
TESTING OUR GEM
$ mkdir spec
$ vim spec/spec_helper.rb
$ vim spec/array_access_spec.rb
$ rspec spec/array_access.rb
TESTING OUR GEM
# ./spec/spec_helper.rb
require 'rubygems'
require 'bundler/setup'
Bundler.setup
require 'eleventh'
RSpec.configure do |config|
end
TESTING OUR GEM
# ./spec/array_access.rb
require 'spec_helper'
describe Array do
describe '#eleventh' do
it 'should return the eleventh element' do
arr = (1..15).to_a
arr.eleventh.should eq(11)
end
it 'should return nil if the eleventh element not not exist' do
arr = (1..9).to_a
arr.eleventh.should eq(nil)
end
end
end
TESTING OUR GEM
$ rspec spec/array_access.rb
..
Finished in 0.00135 seconds
2 examples, 0 failures
TESTING OUR GEM
$ vim Rakefile
# ./Rakefile
require "bundler/gem_tasks"
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new('spec')
task :default => :spec
TESTING OUR GEM
$ rake
/Users/bmorris/.rvm/rubies/ruby-2.1.0-p247/bin/ruby -S rspec ./spec/array_access_spec.rb
..
Finished in 0.00066 seconds
2 examples, 0 failures
3. Setting up continuous integration
JENKINS
CIRCLE CI
TRAVIS CI
SETTING UP CONTINUOUS INTEGRATION
$ vim travis.yml
$ vim eleventh.gemspec
$ vim README.md
$ vim git commit -m "Setting up Travis CI"
$ git push
SETTING UP CONTINUOUS INTEGRATION
# ./travis.yml
language: ruby
rvm:
- 2.1.0
4. Publishing to Rubygems
PUBLISHING TO RUBYGEMS
$ rake -T
$ rake release
$ gem build eleventh.gemspec
$ gem push eleventh-0.0.1.gem
$ open rubygems.org
TA-DA!
REMOVING THE GEM
$ gem yank eleventh -v 0.0.1
5. Publishing to a private gem server
WHY PRIVATE?
GITHUB
GEMINABOX
GEMFURY
PUBLISHING TO GEMFURY
$ gem install gemfury
$ gem build eleventh.gemspec
$ fury push eleventh-0.0.1.gem
$ git remote add fury https://bnmrrs@git.fury.io/bnmrrs/eleventh.git
$ git push fury master
PUBLISHING TO GEMFURY
$ cd ../other-project
$ vim Gemfile
# ../other-project/Gemfile
source 'https://TOKEN@gem.fury.io/bnmrrs/'
$ bundle install
PUBLISHING A NEW VERSION
$ vim lib/eleventh/version.rb
$ gem build eleventh.gemspec
$ git add .
$ git commit -m "Version 2"
$ fury push eleventh-0.0.2.gem
$ fury list
QUESTIONS?
@bnmrrs
www.boltmade.com
https://github.com/bnmrrs/talks

More Related Content

What's hot

Resources and providers chef conf 2013
Resources and providers chef conf 2013Resources and providers chef conf 2013
Resources and providers chef conf 2013rosekolodny
 
JavaScript Sprachraum
JavaScript SprachraumJavaScript Sprachraum
JavaScript Sprachraumpatricklee
 
No Callbacks, No Threads - RailsConf 2010
No Callbacks, No Threads - RailsConf 2010No Callbacks, No Threads - RailsConf 2010
No Callbacks, No Threads - RailsConf 2010Ilya Grigorik
 
Capistrano - automate all the things
Capistrano - automate all the thingsCapistrano - automate all the things
Capistrano - automate all the thingsJohn Cleary
 
Deploying Rails Apps with Chef and Capistrano
 Deploying Rails Apps with Chef and Capistrano Deploying Rails Apps with Chef and Capistrano
Deploying Rails Apps with Chef and CapistranoSmartLogic
 
Ruby Concurrency and EventMachine
Ruby Concurrency and EventMachineRuby Concurrency and EventMachine
Ruby Concurrency and EventMachineChristopher Spring
 
Going real time with Socket.io
Going real time with Socket.ioGoing real time with Socket.io
Going real time with Socket.ioArnout Kazemier
 
Socket.io under the hood
Socket.io under the hoodSocket.io under the hood
Socket.io under the hoodHaokang Den
 
Mage Titans USA 2016 - Miguel Balparda - Magento 2: Premium Performance with ...
Mage Titans USA 2016 - Miguel Balparda - Magento 2: Premium Performance with ...Mage Titans USA 2016 - Miguel Balparda - Magento 2: Premium Performance with ...
Mage Titans USA 2016 - Miguel Balparda - Magento 2: Premium Performance with ...Stacey Whitney
 
What Is Async, How Does It Work, And When Should I Use It?
What Is Async, How Does It Work, And When Should I Use It?What Is Async, How Does It Work, And When Should I Use It?
What Is Async, How Does It Work, And When Should I Use It?emptysquare
 
Getting Started with Capistrano
Getting Started with CapistranoGetting Started with Capistrano
Getting Started with CapistranoLaunchAny
 

What's hot (19)

Resources and providers chef conf 2013
Resources and providers chef conf 2013Resources and providers chef conf 2013
Resources and providers chef conf 2013
 
JavaScript Sprachraum
JavaScript SprachraumJavaScript Sprachraum
JavaScript Sprachraum
 
Socket.io
Socket.ioSocket.io
Socket.io
 
No Callbacks, No Threads - RailsConf 2010
No Callbacks, No Threads - RailsConf 2010No Callbacks, No Threads - RailsConf 2010
No Callbacks, No Threads - RailsConf 2010
 
Capistrano - automate all the things
Capistrano - automate all the thingsCapistrano - automate all the things
Capistrano - automate all the things
 
Deploying Rails Apps with Chef and Capistrano
 Deploying Rails Apps with Chef and Capistrano Deploying Rails Apps with Chef and Capistrano
Deploying Rails Apps with Chef and Capistrano
 
email delivery
email deliveryemail delivery
email delivery
 
Capistrano
CapistranoCapistrano
Capistrano
 
Ruby Concurrency and EventMachine
Ruby Concurrency and EventMachineRuby Concurrency and EventMachine
Ruby Concurrency and EventMachine
 
Socket.io (part 1)
Socket.io (part 1)Socket.io (part 1)
Socket.io (part 1)
 
Elastic search
Elastic searchElastic search
Elastic search
 
Nevermore Unit Testing
Nevermore Unit TestingNevermore Unit Testing
Nevermore Unit Testing
 
Going real time with Socket.io
Going real time with Socket.ioGoing real time with Socket.io
Going real time with Socket.io
 
Socket.io under the hood
Socket.io under the hoodSocket.io under the hood
Socket.io under the hood
 
Sinatra
SinatraSinatra
Sinatra
 
Mage Titans USA 2016 - Miguel Balparda - Magento 2: Premium Performance with ...
Mage Titans USA 2016 - Miguel Balparda - Magento 2: Premium Performance with ...Mage Titans USA 2016 - Miguel Balparda - Magento 2: Premium Performance with ...
Mage Titans USA 2016 - Miguel Balparda - Magento 2: Premium Performance with ...
 
What Is Async, How Does It Work, And When Should I Use It?
What Is Async, How Does It Work, And When Should I Use It?What Is Async, How Does It Work, And When Should I Use It?
What Is Async, How Does It Work, And When Should I Use It?
 
Getting Started with Capistrano
Getting Started with CapistranoGetting Started with Capistrano
Getting Started with Capistrano
 
bivou.ac
bivou.acbivou.ac
bivou.ac
 

Similar to Creating and Publishing Ruby Gems from Scratch

Gem That (2009)
Gem That (2009)Gem That (2009)
Gem That (2009)lazyatom
 
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 RubyHiroshi SHIBATA
 
Rocket Fuelled Cucumbers
Rocket Fuelled CucumbersRocket Fuelled Cucumbers
Rocket Fuelled CucumbersJoseph Wilk
 
RVM, Bundler and Ruby Tracker
RVM, Bundler and Ruby TrackerRVM, Bundler and Ruby Tracker
RVM, Bundler and Ruby TrackerKeith Pitty
 
Ruby gemsパッケージの作り方
Ruby gemsパッケージの作り方Ruby gemsパッケージの作り方
Ruby gemsパッケージの作り方Yamamoto Kazuhisa
 
Perl Sucks - and what to do about it
Perl Sucks - and what to do about itPerl Sucks - and what to do about it
Perl Sucks - and what to do about it2shortplanks
 
Open Source Saturday - How can I contribute to Ruby on Rails?
Open Source Saturday - How can I contribute to Ruby on Rails?Open Source Saturday - How can I contribute to Ruby on Rails?
Open Source Saturday - How can I contribute to Ruby on Rails?Pravin Mishra
 
Practical Testing of Ruby Core
Practical Testing of Ruby CorePractical Testing of Ruby Core
Practical Testing of Ruby CoreHiroshi SHIBATA
 
#CNX14 - Using Ruby for Reliability, Consistency, and Speed
#CNX14 - Using Ruby for Reliability, Consistency, and Speed#CNX14 - Using Ruby for Reliability, Consistency, and Speed
#CNX14 - Using Ruby for Reliability, Consistency, and SpeedSalesforce Marketing Cloud
 
Migrating Legacy Rails Apps to Rails 3
Migrating Legacy Rails Apps to Rails 3Migrating Legacy Rails Apps to Rails 3
Migrating Legacy Rails Apps to Rails 3Clinton Dreisbach
 
Extracting ruby gem
Extracting ruby gemExtracting ruby gem
Extracting ruby gemYura Tolstik
 
Redmine on amazon ec2
Redmine on amazon ec2Redmine on amazon ec2
Redmine on amazon ec2Ikuru Kanuma
 
Infrastructure as code - Python Saati #36
Infrastructure as code - Python Saati #36Infrastructure as code - Python Saati #36
Infrastructure as code - Python Saati #36Halil Kaya
 
Serializing Ruby Objects in Redis
Serializing Ruby Objects in RedisSerializing Ruby Objects in Redis
Serializing Ruby Objects in RedisBrian Kaney
 

Similar to Creating and Publishing Ruby Gems from Scratch (20)

Gem That (2009)
Gem That (2009)Gem That (2009)
Gem That (2009)
 
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
 
Rocket Fuelled Cucumbers
Rocket Fuelled CucumbersRocket Fuelled Cucumbers
Rocket Fuelled Cucumbers
 
RVM, Bundler and Ruby Tracker
RVM, Bundler and Ruby TrackerRVM, Bundler and Ruby Tracker
RVM, Bundler and Ruby Tracker
 
Ruby gemsパッケージの作り方
Ruby gemsパッケージの作り方Ruby gemsパッケージの作り方
Ruby gemsパッケージの作り方
 
Perl Sucks - and what to do about it
Perl Sucks - and what to do about itPerl Sucks - and what to do about it
Perl Sucks - and what to do about it
 
Unit Testing Lots of Perl
Unit Testing Lots of PerlUnit Testing Lots of Perl
Unit Testing Lots of Perl
 
Open Source Saturday - How can I contribute to Ruby on Rails?
Open Source Saturday - How can I contribute to Ruby on Rails?Open Source Saturday - How can I contribute to Ruby on Rails?
Open Source Saturday - How can I contribute to Ruby on Rails?
 
Practical Testing of Ruby Core
Practical Testing of Ruby CorePractical Testing of Ruby Core
Practical Testing of Ruby Core
 
Autotesting rails app
Autotesting rails appAutotesting rails app
Autotesting rails app
 
Laravel Day / Deploy
Laravel Day / DeployLaravel Day / Deploy
Laravel Day / Deploy
 
Babushka
BabushkaBabushka
Babushka
 
perlall
perlallperlall
perlall
 
#CNX14 - Using Ruby for Reliability, Consistency, and Speed
#CNX14 - Using Ruby for Reliability, Consistency, and Speed#CNX14 - Using Ruby for Reliability, Consistency, and Speed
#CNX14 - Using Ruby for Reliability, Consistency, and Speed
 
Migrating Legacy Rails Apps to Rails 3
Migrating Legacy Rails Apps to Rails 3Migrating Legacy Rails Apps to Rails 3
Migrating Legacy Rails Apps to Rails 3
 
Extracting ruby gem
Extracting ruby gemExtracting ruby gem
Extracting ruby gem
 
Creating Ruby Gems
Creating Ruby Gems Creating Ruby Gems
Creating Ruby Gems
 
Redmine on amazon ec2
Redmine on amazon ec2Redmine on amazon ec2
Redmine on amazon ec2
 
Infrastructure as code - Python Saati #36
Infrastructure as code - Python Saati #36Infrastructure as code - Python Saati #36
Infrastructure as code - Python Saati #36
 
Serializing Ruby Objects in Redis
Serializing Ruby Objects in RedisSerializing Ruby Objects in Redis
Serializing Ruby Objects in Redis
 

Recently uploaded

call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....ShaimaaMohamedGalal
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 

Recently uploaded (20)

call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Clustering techniques data mining book ....
Clustering techniques data mining book ....Clustering techniques data mining book ....
Clustering techniques data mining book ....
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 

Creating and Publishing Ruby Gems from Scratch

  • 2. WHAT IS A GEM?
  • 3. LET'S MAKE A GEM 1. Creating a Gem with Bundler
  • 4. LET'S MAKE A GEM 1. Creating a Gem with Bundler 2. Testing it with rspec
  • 5. LET'S MAKE A GEM 1. Creating a Gem with Bundler 2. Testing it with rspec 3. Setting up continuous integration
  • 6. LET'S MAKE A GEM 1. Creating a Gem with Bundler 2. Testing it with rspec 3. Setting up continuous integration 4. Publishing to Rubygems
  • 7. LET'S MAKE A GEM 1. Creating a Gem with Bundler 2. Testing it with rspec 3. Setting up continuous integration 4. Publishing to Rubygems 5. Publishing to a private gem server
  • 10. INITIALIZING OUR GEM $ rvm use 2.1.0 $ gem install bundler $ bundle gem eleventh $ cd eleventh $ rvm --rvmrc --create 2.1.0@eleventh $ cd ..; cd -
  • 11. GENERATED STRUCTURE $ ls eleventh |--- README.md |--- eleventh.gemspec |--- Rakefile |--- Gemfile |--- lib |--- eleventh.rb |--- eleventh |--- version.rb
  • 12. EXPLORING THE GENERATED STRUCTURE $ vim eleventh.gemspec $ vim Gemfile $ vim lib/eleventh.rb $ vim lib/eleventh/version.rb $ rake -T
  • 13. MAKE IT DO SOMETHING $ vim lib/eleventh/array_access.rb $ vim lib/eleventh.rb $ git add . $ git commit -m "Version 1"
  • 14. MAKE IT DO SOMETHING # ./lib/eleventh/array_access.rb class Array def eleventh self[10] end end # ./lib/eleventh.rb require "eleventh/version" require "eleventh/array_access" module Eleventh end
  • 15. 2. Testing our gem with rspec
  • 16. TESTING OUR GEM $ mkdir spec $ vim spec/spec_helper.rb $ vim spec/array_access_spec.rb $ rspec spec/array_access.rb
  • 17. TESTING OUR GEM # ./spec/spec_helper.rb require 'rubygems' require 'bundler/setup' Bundler.setup require 'eleventh' RSpec.configure do |config| end
  • 18. TESTING OUR GEM # ./spec/array_access.rb require 'spec_helper' describe Array do describe '#eleventh' do it 'should return the eleventh element' do arr = (1..15).to_a arr.eleventh.should eq(11) end it 'should return nil if the eleventh element not not exist' do arr = (1..9).to_a arr.eleventh.should eq(nil) end end end
  • 19. TESTING OUR GEM $ rspec spec/array_access.rb .. Finished in 0.00135 seconds 2 examples, 0 failures
  • 20. TESTING OUR GEM $ vim Rakefile # ./Rakefile require "bundler/gem_tasks" require 'rspec/core/rake_task' RSpec::Core::RakeTask.new('spec') task :default => :spec
  • 21. TESTING OUR GEM $ rake /Users/bmorris/.rvm/rubies/ruby-2.1.0-p247/bin/ruby -S rspec ./spec/array_access_spec.rb .. Finished in 0.00066 seconds 2 examples, 0 failures
  • 22. 3. Setting up continuous integration
  • 26. SETTING UP CONTINUOUS INTEGRATION $ vim travis.yml $ vim eleventh.gemspec $ vim README.md $ vim git commit -m "Setting up Travis CI" $ git push
  • 27. SETTING UP CONTINUOUS INTEGRATION # ./travis.yml language: ruby rvm: - 2.1.0
  • 28. 4. Publishing to Rubygems
  • 29. PUBLISHING TO RUBYGEMS $ rake -T $ rake release $ gem build eleventh.gemspec $ gem push eleventh-0.0.1.gem $ open rubygems.org
  • 31. REMOVING THE GEM $ gem yank eleventh -v 0.0.1
  • 32. 5. Publishing to a private gem server
  • 37. PUBLISHING TO GEMFURY $ gem install gemfury $ gem build eleventh.gemspec $ fury push eleventh-0.0.1.gem $ git remote add fury https://bnmrrs@git.fury.io/bnmrrs/eleventh.git $ git push fury master
  • 38. PUBLISHING TO GEMFURY $ cd ../other-project $ vim Gemfile # ../other-project/Gemfile source 'https://TOKEN@gem.fury.io/bnmrrs/' $ bundle install
  • 39. PUBLISHING A NEW VERSION $ vim lib/eleventh/version.rb $ gem build eleventh.gemspec $ git add . $ git commit -m "Version 2" $ fury push eleventh-0.0.2.gem $ fury list