Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
gem入門
Search
cottondesu
December 19, 2016
Technology
120
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
gem入門
簡単なgemの作り方の説明
cottondesu
December 19, 2016
More Decks by cottondesu
See All by cottondesu
在庫管理・買い物メモを作成中/creating-inventory-management-shopping-list
cottondesu
0
20
ヨシケイの撮り忘れを対策したPart2/measures-were-taken-to-prevent-forgetting-to-pick-up-yoshikei-part2
cottondesu
0
55
ヨシケイの取り忘れ対策した / Measures were taken to prevent forgetting to pick up Yoshikei
cottondesu
0
360
開発環境公開ハード編 / Development environment public hardware version
cottondesu
0
190
開発環境公開ソフト編 / Development environment public software edition
cottondesu
0
190
正規表現で心が折れた/Regular expressions broke my heart
cottondesu
0
190
オレオレGASからMakeへの移行を検討してみた / Considering the transition from Ore Ore GAS to Make
cottondesu
0
790
Kanazawa.rb 10周年KPT / Kanazawa.rb 10th Anniversary KPT
cottondesu
0
900
Kanazawa.rb 9周年KPT / Kanazawa.rb 9th Anniversary KPT
cottondesu
0
500
Other Decks in Technology
See All in Technology
Claude Codeを「使うほど育つ」AI秘書にするノウハウ
minorun365
PRO
32
32k
GitHub Agentic Workflows を触ってみる
htkym
2
690
「ピッケル本」日本語版は4.0(第6版)が出版されるべき / pickaxe4-nagoyark05
kakutani
2
300
3人で1000GPU超を統合運用する?マルチクラウド&オンプレを跨ぐ、構築と運用のリアル!
kazukun0716
2
410
AWS DevOps Agent スキルをつかいこなそう / Master AWS DevOps Agent Skills
kinunori
2
520
品質と信頼性を地続きにする
grimoh
2
1k
SREへの勘違いに気づいた後の話
tomodakengo
0
160
プラットフォームを「作る」、 チームに「入り込む」
sansantech
PRO
0
190
事業課題から技術的負債に向き合う
sansantech
PRO
2
2.4k
CI/CDではもう遅い - 人とAIが迂回しないDevSecOps Verify基盤の再設計 -
kintotechdev
1
290
なぜ「決定性」が 決定的に重要なのか? Durable Execution 基盤の数理的理解 #serverlessjp / ServerlessDays Tokyo 2026
ytaka23
4
1.3k
LLMに渡さなかった仕事
nanaism
0
13k
Featured
See All Featured
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1.1k
Docker and Python
trallard
47
4.2k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
So, you think you're a good person
axbom
PRO
2
2.2k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
840
Speed Design
sergeychernyshev
33
2.1k
SEO for Brand Visibility & Recognition
aleyda
0
4.8k
Building a A Zero-Code AI SEO Workflow
portentint
PRO
0
730
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Transcript
gem 入門 kanazawa.rb meetup#52 2016年12月17日
@cotton_desu
gem作ったことある?
難易度が高い?
それは思い込みです
gemは簡単に作れる
gemとは
• パッケージ化されたRubyアプリケーション • rubyライブラリ • gemコマンドを使って簡単にinstallやremove 等ができる gemとは
CLI系gem作成手順
CLI系gem作成手順 1. bundle gem コマンド実行 2. gemspecファイルに追記 3. exe/<gem名>ファイルに追記 4.
lib/<gem名>.rbに追記 5. lib/<gem名>/cli.rbを作成
CLI系gem作成手順 1. bundle gem コマンド実行 2. gemspecファイルに追記 3. exe/<gem名>ファイルに追記 4.
lib/<gem名>.rbに追記 5. lib/<gem名>/cli.rbを作成
bundle gem コマンド bundle gem <gem໊> -b ҎԼͷίϚϯυΛ࣮ߦ͢Δ
bundle gem コマンド % bundle gem exsample_gem -b Creating gem
'exsample_gem'... MIT License enabled in config Code of conduct enabled in config create exsample_gem/Gemfile create exsample_gem/.gitignore create exsample_gem/lib/exsample_gem.rb create exsample_gem/lib/exsample_gem/version.rb create exsample_gem/exsample_gem.gemspec create exsample_gem/Rakefile create exsample_gem/README.md create exsample_gem/bin/console create exsample_gem/bin/setup create exsample_gem/LICENSE.txt create exsample_gem/CODE_OF_CONDUCT.md create exsample_gem/exe/exsample_gem Initializing git repo in /tmp/exsample_gem ࣮ߦྫ
CLI系gem作成手順 1. bundle gem コマンド実行 2. gemspecファイルに追記 3. exe/<gem名>ファイルに追記 4.
lib/<gem名>.rbに追記 5. lib/<gem名>/cli.rbを作成
gemspecファイル追記 spec.add_dependency 'thor' HFNTQFDʹҎԼΛه͢Δ UIPS3VCZͷ$-*πʔϧͷ࡞Λࢧԉ͢ΔHFN
gemspecファイル追記 FYTBNQMF@HFNHFNTQFDهྫ # coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib)
unless $LOAD_PATH.include?(lib) require 'exsample_gem/version' Gem::Specification.new do |spec| spec.name = "exsample_gem" spec.version = ExsampleGem::VERSION —————-লུ—————- spec.add_development_dependency "bundler", "~> 1.11" spec.add_development_dependency "rake", "~> 10.0" spec.add_dependency 'thor' end ˡه
CLI系gem作成手順 1. bundle gem コマンド実行 2. gemspecファイルに追記 3. exe/<gem名>ファイルに追記 4.
lib/<gem名>.rbに追記 5. lib/<gem名>/cli.rbを作成
exe/<gem名>ファイル追記 <※1>::CLI.start ҎԼΛه͢Δ ※1 gem໊ͷ಄ɺ_ͷޙͷจࣈΛେจࣈʹ_Λআ͢Δ ྫ) exsample_gem " ExsampleGem
exe/<gem名>ファイル追記 FYFFYTBNQMF@HFNهྫ #!/usr/bin/env ruby require "exsample_gem" ExsampleGem::CLI.start ˡه
CLI系gem作成手順 1. bundle gem コマンド実行 2. gemspecファイルに追記 3. exe/<gem名>ファイルに追記 4.
lib/<gem名>.rbに追記 5. lib/<gem名>/cli.rbを作成
lib/<gem名>.rb追記 require "<gem໊>/cli" ҎԼΛه͢Δ
lib/<gem名>.rb追記 FYFFYTBNQMF@HFNSCهྫ require "exsample_gem/version" require "exsample_gem/cli" module ExsampleGem # Your
code goes here... end ˡه
CLI系gem作成手順 1. bundle gem コマンド実行 2. gemspecファイルに追記 3. exe/<gem名>ファイルに追記 4.
lib/<gem名>.rbに追記 5. lib/<gem名>/cli.rbを作成
lib/<gem名>/cli.rb作成 def hoge puts "Hello world" end DMJSCΛ৽ن࡞͠ɺػೳΛՃ͢Δ ࠓճIPHFίϚϯυͰ)FMMPXPSMEΛ දࣔ͢Δػೳͱ͢Δ
ίϚϯυϝιουͱͯ͠ఆٛ͢Δ
lib/<gem名>/cli.rb作成 MJCʻHFN໊ʼDMJSC require 'exsample_gem' require 'thor' module ExsampleGem class CLI
< Thor desc "hoge", "Hello world print." #ίϚϯυͷ༻ྫͱɺ֓ཁ def hoge #ίϚϯυϝιουͱͯ͠ఆٛ͢Δ puts "Hello world" end end end
gem実行 $ bundle install # Thor ͳΜ͔ΛΠϯετʔϧ͢ΔͨΊʹ $ % bundle
exec exe/exsample_gem hoge Hello world HFNΛ࣮ߦ͢ΔલʹCVOEMFJOTUBMM͕ඞཁ
作ったgemのDemo
• bundle gemコマンドでほぼ必要な ファイルの雛形が作成される • gemを作るのは難しくない • 気軽にgemを作りましょう 総括