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
Search
Jeff Felchner
March 22, 2013
Technology
1
100
Creating a Gem
Jeff Felchner
March 22, 2013
Tweet
Share
More Decks by Jeff Felchner
See All by Jeff Felchner
Rails Engines as an SOA Middle Ground
jfelchner
1
390
Advanced and Intermediate Git
jfelchner
1
65
Rails Templates
jfelchner
1
55
Other Decks in Technology
See All in Technology
Terraformあれやこれ/terraform-this-and-that
emiki
8
1.4k
ExaDB-D dbaascli で出来ること
oracle4engineer
PRO
0
2.1k
地理空間データ可視化・解析・活用ソリューション Pacific Spatial Solutions (PSS)
pacificspatialsolutions
0
290
LayerXにおけるLLMプロダクト開発の今までとこれから
layerx
PRO
1
370
DMM.com アルファ室採用案内資料
hsugita
1
160
Meta Quest 3 で動く桜マシマシ WebXR アプリを IBM Cloud Code Engine と Babylon.js で作った話
1ftseabass
PRO
0
120
いつか使うかも貯金してたらめちゃめちゃ機能が増えてた話
riyaamemiya
0
290
Azureの基本的な権限管理の勉強会
yhana
0
590
GrafanaMeetup_AmazonManagedGrafanaのアクセス制御機能とマルチテナント環境下でのアクセス制御について
daitak
0
240
ゼロから始めるVue.jsコミュニティ貢献 / first-vuejs-community-contribution-link-and-motivation
lmi
1
130
家族アルバム みてねにおけるGrafana活用術 / Grafana Meetup Japan Vol.1 LT
isaoshimizu
1
770
KubeCon EU 2024 Recap “Kubernetes Policy Time Machine: Where to Next?”
ryysud
0
220
Featured
See All Featured
Designing with Data
zakiwarfel
96
4.8k
Keith and Marios Guide to Fast Websites
keithpitt
408
22k
Unsuck your backbone
ammeep
663
57k
Building Applications with DynamoDB
mza
88
5.6k
Building Adaptive Systems
keathley
31
1.9k
Adopting Sorbet at Scale
ufuk
68
8.6k
Producing Creativity
orderedlist
PRO
337
39k
Thoughts on Productivity
jonyablonski
58
3.8k
The World Runs on Bad Software
bkeepers
PRO
61
6.7k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
244
20k
Writing Fast Ruby
sferik
621
60k
Stop Working from a Prison Cell
hatefulcrawdad
266
19k
Transcript
Creating Your First Gem
What?
Does One Thing Well
Why?
Programming is hard.
Programming well is really hard.
The Problem
Naming
The First Rule
Name It Something Clever
The Second Rule
Don’t Take One Of My Names
None
615.555.1234
None
The Third Rule
Don’t Be Inappropriate
Don't name it something sexual.
Don't name it something misogynistic
Don't name it after crude words for your anatomy
F&%#
None
Why Listen To Me?
rspectacular null_and_void bangers_and_hash envision dolla_dolla_bill stipend use_the_forcible referehencible molten_core dynamo
johnny_five i_am_valid oscillator chronological greenwich get_together enwrap pinpoint chicken_soup apple_cart ruby-progressbar
Our Example
None
“Translating pig latin is fun”.to_pig_latin # => “anslating-tray ig-pay atin-lay
is-ay un-fay”
None
Creating Your Gem
Jewler
Hoe
Bundler
</disclaimer>
gem install bundler bundle gem pope_francis
create pope_francis/Gemfile create pope_francis/Rakefile create pope_francis/LICENSE.txt create pope_francis/README.md create pope_francis/.gitignore
create pope_francis/pope_francis.gemspec create pope_francis/lib/pope_francis.rb create pope_francis/lib/pope_francis/version.rb
create pope_francis/Gemfile create pope_francis/Rakefile create pope_francis/LICENSE.txt create pope_francis/README.md create pope_francis/.gitignore
create pope_francis/pope_francis.gemspec create pope_francis/lib/pope_francis.rb create pope_francis/lib/pope_francis/version.rb
Gem::Specification.new do |gem| gem.name = "pope_francis" gem.version = PopeFrancis::VERSION gem.authors
= ["Jeff Felchner"] gem.email = ["
[email protected]
"] gem.description = %q{TODO: Write a gem description} gem.summary = %q{TODO: Write a gem summary} gem.homepage = "" end
Gem::Specification.new do |gem| gem.name = "pope_francis" gem.version = PopeFrancis::VERSION gem.authors
= ["Jeff Felchner"] gem.email = ["
[email protected]
"] gem.description = %q{ig-pay atin-lay anslator-tray} gem.summary = %q{The one-stop shop for your Pig Latin needs} gem.homepage = "http://github.com/jfelchner/pope_francis" end
Releasing Your Gem
Sign Up on rubygems.org
None
Add Your Gem to Github (optional)
None
rake release
pope_francis 0.0.1 built to pkg/ pope_francis-0.0.1.gem Tagged v0.0.1 Pushed git
commits and tags Pushed pope_francis 0.0.1 to rubygems.org
None
Versioning
Use Semantic Versioning (http://semver.org)
x.y.z Major . Minor . Patch (eg 1.8.4)
Your Gem’s Version
pope_francis/lib/pope_francis/version.rb
module PopeFrancis VERSION = "0.0.1" end
arning-way! Pushing The Same Version Twice Will Fail
> gem push pkg/pope_francis-0.0.1.gem Pushing gem to https://rubygems.org... Repushing of
gem versions is not allowed. Please use `gem yank` to remove bad gem releases.
Yanking Releases
> gem install gemcutter > gem yank pope_francis -v 0.0.1
Yanking gem from RubyGems.org... Pushing gem to https://rubygems.org... Successfully yanked gem: pope_francis (0.0.1)
None
> gem install pope_francis ERROR: Could not find a valid
gem 'pope_francis' (>= 0) in any repository ERROR: Possible alternatives: francis, tolerances
README Driven Development
Waaaaaaiiiiiiiiiiiiitttttttttt a second.....
Your Public API = Your Version
Your Public API is the most important thing when developing
a gem.
None
Write the Code
Fast Forward
pope_francis/lib/pope_francis.rb
require ‘pope_francis’
require ‘pope_francis’ while english_phrase = gets do puts english_phrase.to_pig_latin end
Hacking On It
Fork the Gem
https://github.com/jfelchner/pope_francis
Rename the Gem in Your Fork
pope_francis-nash-rails
pope_francis-nash-rails-jfelchner
Using It In Another Project
gem install pope_francis-nash-rails-jfelchner
require ‘pope_francis’
require ‘pope_francis-nash-rails-jfelchner’
Exercises
Additional Options
“Translating pig latin is fun” .to_pig_latin(:hyphenate => false) # =>
“anslatingtray igpay atinlay isway unfay”
Preserve Capitalization
“Translating Pig Latin is fun”.to_pig_latin # => “Anslating-tray Ig-pay Atin-lay
is-way un-fay”
Rails App
None
Thanks! Jeff Felchner @jfelchner