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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
22
ヨシケイの撮り忘れを対策した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
370
開発環境公開ハード編 / 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
800
Kanazawa.rb 10周年KPT / Kanazawa.rb 10th Anniversary KPT
cottondesu
0
910
Kanazawa.rb 9周年KPT / Kanazawa.rb 9th Anniversary KPT
cottondesu
0
500
Other Decks in Technology
See All in Technology
「Docker Desktop不要の時代」は 来たのか?
ueponx
0
770
Webの常識が通じないHTMLメールのダークモード
teamlab
PRO
0
120
スプシの手作業からの解脱 ~更新はClaude Codeに、見せ方と使い方はGASアプリに任せる~
kentarofujii
0
150
古い指輪から広がった JAVA コミュニティ とのつながり
yamad
0
100
日本語に強いオープンな大規模言語モデル「LLM-jp」
odashi
4
1.1k
CTO Night|NotionのAIエージェントとFDE
kzkhykw1991
0
120
会社説明資料
persolserverworks
0
9.8k
Local CI × GitHub Actions
gogutan
2
200
re:Invent初参加で変わったこと、2回目にやってみたいこと(JAWS-UG彩の国埼玉 #12)
mhrtech
2
230
スキマバイトという雇用形態は存在しないので、雇用期間1日のアルバイト契約を事業者とワーカーが結ぶ手続きを支えるのがタイミーなんです
akitoshiga
0
200
JAWSUG TOHOKU 青森支部 「LoGoチャット」のAWS移行で 乗り越えたこと
taketakekaho
0
330
Active Record Connection Adaptersにおける長年の課題に再び取り組む
yahonda
0
150
Featured
See All Featured
The Limits of Empathy - UXLibs8
cassininazir
2
720
Building a Scalable Design System with Sketch
lauravandoore
464
34k
Unsuck your backbone
ammeep
672
58k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.8k
The Organizational Zoo: Understanding Human Behavior Agility Through Metaphoric Constructive Conversations (based on the works of Arthur Shelley, Ph.D)
kimpetersen
PRO
0
500
Reality Check: Gamification 10 Years Later
codingconduct
0
2.3k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
2.1k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
300
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
640
Context Engineering - Making Every Token Count
addyosmani
9
1.2k
Deep Space Network (abreviated)
tonyrice
0
370
Code Reviewing Like a Champion
maltzj
529
40k
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を作りましょう 総括