Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Creating a Gem with Bundler
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Ben Morris
April 15, 2014
Technology
1
5.7k
Creating a Gem with Bundler
Ben Morris
April 15, 2014
Tweet
Share
More Decks by Ben Morris
See All by Ben Morris
Code Retreat
bnmrrs
1
62
Method Jam
bnmrrs
2
130
Other Decks in Technology
See All in Technology
Claude_CodeでSEOを最適化する_AI_Ops_Community_Vol.2__マーケティングx_AIはここまで進化した.pdf
riku_423
2
590
20260208_第66回 コンピュータビジョン勉強会
keiichiito1978
0
150
【Oracle Cloud ウェビナー】[Oracle AI Database + AWS] Oracle Database@AWSで広がるクラウドの新たな選択肢とAI時代のデータ戦略
oracle4engineer
PRO
2
170
OCI Database Management サービス詳細
oracle4engineer
PRO
1
7.4k
顧客との商談議事録をみんなで読んで顧客解像度を上げよう
shibayu36
0
260
広告の効果検証を題材にした因果推論の精度検証について
zozotech
PRO
0
190
会社紹介資料 / Sansan Company Profile
sansan33
PRO
15
400k
OpenShiftでllm-dを動かそう!
jpishikawa
0
120
量子クラウドサービスの裏側 〜Deep Dive into OQTOPUS〜
oqtopus
0
130
こんなところでも(地味に)活躍するImage Modeさんを知ってるかい?- Image Mode for OpenShift -
tsukaman
0
150
10Xにおける品質保証活動の全体像と改善 #no_more_wait_for_test
nihonbuson
PRO
2
310
Oracle Cloud Observability and Management Platform - OCI 運用監視サービス概要 -
oracle4engineer
PRO
2
14k
Featured
See All Featured
Game over? The fight for quality and originality in the time of robots
wayneb77
1
120
Believing is Seeing
oripsolob
1
56
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
66
37k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.7k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
310
The Limits of Empathy - UXLibs8
cassininazir
1
220
Discover your Explorer Soul
emna__ayadi
2
1.1k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
78
The Mindset for Success: Future Career Progression
greggifford
PRO
0
240
Music & Morning Musume
bryan
47
7.1k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
1.8k
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
130
Transcript
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://
[email protected]
/bnmrrs/eleventh.git $ git push fury master
PUBLISHING TO GEMFURY $ cd ../other-project $ vim Gemfile #
../other-project/Gemfile source 'https://
[email protected]
/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