Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Using Ruby in a Non-Ruby World
Samuel E. Giddins
March 04, 2015
Technology
0
50
Using Ruby in a Non-Ruby World
Samuel E. Giddins
March 04, 2015
Tweet
Share
More Decks by Samuel E. Giddins
See All by Samuel E. Giddins
Switching Disciplines as a Tech Lead
segiddins
0
6
Source Code to Executable
segiddins
0
55
Empowering iOS Developers
segiddins
1
55
Empowering iOS Developers
segiddins
0
340
Making CocoaPods Fast (with Modern Ruby Tooling)
segiddins
0
18
Making CocoaPods Fast
segiddins
0
230
Answering the Existential Question
segiddins
0
27
Scaling CocoaPods
segiddins
0
33
Building Swift Static Libraries
segiddins
0
270
Other Decks in Technology
See All in Technology
創業1年目のスタートアップでAWSコストを抑えるために取り組んでいること / How to Keep AWS Costs Down at a Startup
yuj1osm
3
2.2k
SSMパラメーターストアでクロススタック参照の罠を回避する
shuyakinjo
0
8k
MarvelClient Upgrade 64bit クライアントへの自動アップグレード設定
mitsuru_katoh
0
220
IoTを始めたきっかけの話と個人でできるIoTの今後 / 新年LT会「私の愛するIoT 2023」
you
0
250
日経電子版だけじゃない! 日経の新規Webメディアの開発 - NIKKEI Tech Talk #3
sztm
0
350
Periodic Multi-Agent Path Planning
hziwara
0
160
Bill One 開発エンジニア 紹介資料
sansantech
PRO
0
130
IoT から見る AWS re:invent 2022 ― AWSのIoTの歴史を添えて/Point of view the AWS re:invent 2022 with IoT - with a history of IoT in AWS
ma2shita
0
290
オンプレk8sとEKSの並行運用の実際
ch1aki
0
320
MoT/コネヒト/Kanmu が語るプロダクト開発xデータ分析 - 分析から機械学習システムの開発まで一人で複数ロールを担う大変さ
masatakashiwagi
3
800
ECテックカンファレンス2023 EC事業部のモバイル開発2023
tatsumi0000
0
350
CUEとKubernetesカスタムオペレータを用いた新しいネットワークコントローラをつくってみた
hrk091
1
300
Featured
See All Featured
Music & Morning Musume
bryan
37
4.7k
WebSockets: Embracing the real-time Web
robhawkes
58
6k
Art Directing for the Web. Five minutes with CSS Template Areas
malarkey
197
10k
Building Flexible Design Systems
yeseniaperezcruz
314
35k
Adopting Sorbet at Scale
ufuk
65
7.8k
GitHub's CSS Performance
jonrohan
1020
430k
What’s in a name? Adding method to the madness
productmarketing
12
1.9k
Optimizing for Happiness
mojombo
365
64k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
217
21k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
10
1.3k
Imperfection Machines: The Place of Print at Facebook
scottboms
254
12k
Atom: Resistance is Futile
akmur
256
24k
Transcript
Using Ruby in a Non-Ruby World
Samuel Giddins Realm CocoaPods Bundler
Show of hands: Who writes Ruby for a living?
Show of hands: Who uses something built in Ruby every
day?
Let’s name some
Those are some great tools! Do you think their utility
is limited to Ruby developers?
No
I write Ruby every day
I write Ruby every day => I am a Rubyist
Let’s look at some of the tools we use: —
rvm/rbenv/chruby — Bundler — Native extensions
Version Managers
For me: $ rbenv versions | wc -l 13 $
ruby -v 2.2.0p0
For others: $ which ruby /usr/bin/ruby $ ruby -v 2.0.0p353
# And be thankful it's not 1.8.7
Can’t you just update to 2.1.5? Not particularly helpful.
Bundler
Bundler Is wonderful.
But most people want to install a tool once and
forget about it.
Yeah, they should use a Gemfile. But they won’t.
So your gem will be polluting their global namespace.
Native Extensions
They’re such a pain.
Compilation as part of the CocoaPods gem install process is
dead. Long live precompiled gems! — CocoaPods 0.27 and improved installation UX
Not everyone needs to have a compiler installed. Or the
Ruby headers. Or a proper build setup.
Not everyone needs to have a compiler installed. Or the
Ruby headers. Or a proper build setup. And they shouldn't need to
In this ‘developer bubble’ there is no sane Ruby environment
unless you at least build your own Ruby, but preferably including one or more of the following tools: homebrew, RVM, rbenv, and many other alternatives.
And Now For The Fun Part
Let’s get positive.
DSLs
Ruby is awesome for building DSLs.
source 'https://github.com/CocoaPods/Specs.git' target 'iOS' do pod 'Realm' pod 'RestKit', git:
'https://github.com/RestKit/RestKit.git' end
It barely even looks like code!
Pod::Specification.new do |s| s.name = 'Realm' s.version = `sh build.sh
get-version`.chomp end
That definitely is starting to seem more like code.
The difference?
BasicObject.instance_eval # the first # vs Kernel.eval # the second
If someone doesn’t realize they’re writing Ruby, you’ve done a
! job.
— Ruby 1.9 hash syntax - ! — Curly brace
procs & lambdas - " — do...end blocks - ! — Symbol parameters - " — def f(*args); end - !
Hide the Ruby out back.
NoMethodError - undefined method `[]' for #<Xcodeproj::Project::Object::PBXFileReference:0x007fcf522734a8> /usr/local/lib/ruby/gems/2.1.0/gems/cocoapods-0.36.0.rc.1/lib/cocoapods/project.rb:186:in `block in
add_file_reference' /usr/local/Cellar/ruby/2.1.3_1/lib/ruby/2.1.0/pathname.rb:266:in `block in each_filename' /usr/local/Cellar/ruby/2.1.3_1/lib/ruby/2.1.0/pathname.rb:266:in `each' /usr/local/Cellar/ruby/2.1.3_1/lib/ruby/2.1.0/pathname.rb:266:in `each_filename' /usr/local/lib/ruby/gems/2.1.0/gems/cocoapods-0.36.0.rc.1/lib/cocoapods/project.rb:184:in `add_file_reference' /usr/local/lib/ruby/gems/2.1.0/gems/cocoapods-0.36.0.rc.1/lib/cocoapods/installer/file_references_installer.rb:168:in `block (2 levels) in add_file_accessors_paths_to_pods_group' /usr/local/lib/ruby/gems/2.1.0/gems/cocoapods-0.36.0.rc.1/lib/cocoapods/installer/file_references_installer.rb:166:in `each' /usr/local/lib/ruby/gems/2.1.0/gems/cocoapods-0.36.0.rc.1/lib/cocoapods/installer/file_references_installer.rb:166:in `block in add_file_accessors_paths_to_pods_group' /usr/local/lib/ruby/gems/2.1.0/gems/cocoapods-0.36.0.rc.1/lib/cocoapods/installer/file_references_installer.rb:162:in `each' /usr/local/lib/ruby/gems/2.1.0/gems/cocoapods-0.36.0.rc.1/lib/cocoapods/installer/file_references_installer.rb:162:in `add_file_accessors_paths_to_pods_group' /usr/local/lib/ruby/gems/2.1.0/gems/cocoapods-0.36.0.rc.1/lib/cocoapods/installer/file_references_installer.rb:103:in `block in add_resources' /usr/local/lib/ruby/gems/2.1.0/gems/cocoapods-0.36.0.rc.1/lib/cocoapods/user_interface.rb:110:in `message' /usr/local/lib/ruby/gems/2.1.0/gems/cocoapods-0.36.0.rc.1/lib/cocoapods/installer/file_references_installer.rb:102:in `add_resources' /usr/local/lib/ruby/gems/2.1.0/gems/cocoapods-0.36.0.rc.1/lib/cocoapods/installer/file_references_installer.rb:38:in `install!' /usr/local/lib/ruby/gems/2.1.0/gems/cocoapods-0.36.0.rc.1/lib/cocoapods/installer.rb:486:in `install_file_references' /usr/local/lib/ruby/gems/2.1.0/gems/cocoapods-0.36.0.rc.1/lib/cocoapods/installer.rb:130:in `block in generate_pods_project' /usr/local/lib/ruby/gems/2.1.0/gems/cocoapods-0.36.0.rc.1/lib/cocoapods/user_interface.rb:49:in `section' /usr/local/lib/ruby/gems/2.1.0/gems/cocoapods-0.36.0.rc.1/lib/cocoapods/installer.rb:128:in `generate_pods_project' /usr/local/lib/ruby/gems/2.1.0/gems/cocoapods-0.36.0.rc.1/lib/cocoapods/installer.rb:96:in `install!' /usr/local/lib/ruby/gems/2.1.0/gems/cocoapods-0.36.0.rc.1/lib/cocoapods/command/project.rb:71:in `run_install_with_update' /usr/local/lib/ruby/gems/2.1.0/gems/cocoapods-0.36.0.rc.1/lib/cocoapods/command/project.rb:101:in `run' /usr/local/lib/ruby/gems/2.1.0/gems/claide-0.8.1/lib/claide/command.rb:312:in `run' /usr/local/lib/ruby/gems/2.1.0/gems/cocoapods-0.36.0.rc.1/lib/cocoapods/command.rb:46:in `run' /usr/local/lib/ruby/gems/2.1.0/gems/cocoapods-0.36.0.rc.1/bin/pod:44:in `<top (required)>' /usr/local/bin/pod:23:in `load' /usr/local/bin/pod:23:in `<main>'
[!] Installation could not proceed because an unexpected object was
found in your project file.
Be Friendly
Sure, these tips are designed to keeps Ruby newcomers happy.
Sure, these tips are designed to keeps Ruby newcomers happy.
But they also make your software much friendlier.
Available now on Speaker Deck. https://speakerdeck.com/segiddins/using-ruby-in-a- non-ruby-world
puts Question.all.map(&:ask?).map(&:answer!)
Samuel Giddins Realm @segiddins