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
Ruby 2.5: What's New and What's Cool
Search
Bryce "BonzoESC" Kerley
January 15, 2018
Programming
0
57
Ruby 2.5: What's New and What's Cool
Miami Ruby Brigade
Monday, January 15, 2018
Bryce "BonzoESC" Kerley
January 15, 2018
Tweet
Share
More Decks by Bryce "BonzoESC" Kerley
See All by Bryce "BonzoESC" Kerley
Ruby in 2020
bryce
1
87
Rails and the Internet of Things
bryce
1
56
It's Not Ruby, But…
bryce
0
43
docker for rubyists
bryce
0
98
Would You Like To Make A Game?
bryce
0
49
WebSockets and ActionCable
bryce
0
77
How I Learned to Stop Worrying and Like RSpec
bryce
0
66
How Do Computers Even Work?
bryce
1
180
Growing Distributed Systems: Abril Pro Ruby
bryce
0
45
Other Decks in Programming
See All in Programming
Piniaの現状と今後
waka292
5
1.5k
【Kaigi on Rails 2024】YOUTRUST スポンサーLT
krpk1900
1
270
Kotlin2でdataクラスの copyメソッドを禁止する/Data class copy function to have the same visibility as constructor
eichisanden
1
160
go.mod、DockerfileやCI設定に分散しがちなGoのバージョンをまとめて管理する / Go Connect #3
arthur1
10
2.4k
ECSのサービス間通信 4つの方法を比較する 〜Canary,Blue/Greenも添えて〜
tkikuc
11
2.3k
CPython 인터프리터 구조 파헤치기 - PyCon Korea 24
kennethanceyer
0
250
讓數據說話:用 Python、Prometheus 和 Grafana 講故事
eddie
0
370
飲食業界向けマルチプロダクトを実現させる開発体制とリアルな現状
hiroya0601
1
410
Progressive Web Apps für Desktop und Mobile mit Angular (Hands-on)
christianliebel
PRO
0
110
Jakarta Concurrencyによる並行処理プログラミングの始め方 (JJUG CCC 2024 Fall)
tnagao7
1
250
WEBエンジニア向けAI活用入門
sutetotanuki
0
310
ピラミッド、アイスクリームコーン、SMURF: 自動テストの最適バランスを求めて / Pyramid Ice-Cream-Cone and SMURF
twada
PRO
10
1.1k
Featured
See All Featured
How to train your dragon (web standard)
notwaldorf
88
5.7k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
355
29k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
167
49k
Building an army of robots
kneath
302
42k
Testing 201, or: Great Expectations
jmmastey
38
7.1k
Bash Introduction
62gerente
608
210k
Docker and Python
trallard
40
3.1k
Adopting Sorbet at Scale
ufuk
73
9k
A better future with KSS
kneath
238
17k
Facilitating Awesome Meetings
lara
49
6.1k
It's Worth the Effort
3n
183
27k
What's new in Ruby 2.0
geeforr
343
31k
Transcript
Ruby 2.5 What's New and What's Cool Miami Ruby Brigade
Monday, January 15, 2018
tl;dr • feature and performance update release • new features
are cool • some stuff is faster • some stdlibs are now default gems • some other bits & bobs have changed
Topics • Intro • Features • Demos • Q&A
https://www.ruby-lang.org/en/news/2017/12/25/ruby-2-5-0-released/
Getting Ruby 2.5 • rbenv • Docker hub • Heroku
• rvm
Running an App? Go for it (With adequate testing)
Maintaining a Library? Know it exists and test with it
do / rescue / end Exception handling in a block
doesn't require begin
https://github.com/bkerley/mastodon/commit/589cdff
Object#yield_self Similar to #tap but it returns the result instead
of the receiver
None
Hash#slice Grabs a sub-hash with the given keys
https://github.com/bkerley/tides_and_currents/commit/bbb8ab78
Hash#transform_keys • Returns a new hash with the keys mapped
to something new
None
Struct.new keyword Struct#new supports keyword arguments now
None
Enumerable#any? #all? #none? #one? threequals Find if members in a
collection threequal some pattern
None
None
Reverse backtraces • Quality of life • On a terminal,
unless you change $stderr, the most recent call is at the bottom instead of a million screens up
None
Topics • Intro • Features • Demos • Q&A
Upgrading Mastodon I decided to make Mastodon work in Ruby
2.5
Mastodon • Twitter-like • Open-source • Federated • Independent nodes
Setup Steps From a new Mastodon checkout on v2.1.3, and
after Development setup steps 1. Update README.md to note that it's a weird research project 2. Remove "< 2.5.0" constraint on Ruby version from Gemfile 3. bundle 4. Some deps also have "< 2.5.0" ruby constraint 5. bundle update
app/models/media_attachment.rb def populate_meta meta = {} file.queued_for_write.each
do |style, file| begin geo = Paperclip::Geometry.from_file file meta[style] = { width: geo.width.to_i, height: geo.height.to_i, size: "#{geo.width.to_i}x#{geo.height.to_i}", aspect: geo.width.to_f / geo.height.to_f, } rescue Paperclip::Errors::NotIdentifiedByImageMagickError meta[style] = {} end end meta end
None
app/models/media_attachment.rb def populate_meta meta = {} file.queued_for_write.each
do |style, file| begin geo = Paperclip::Geometry.from_file file meta[style] = { width: geo.width.to_i, height: geo.height.to_i, size: "#{geo.width.to_i}x#{geo.height.to_i}", aspect: geo.width.to_f / geo.height.to_f, } # rescue Paperclip::Errors::NotIdentifiedByImageMagickError # meta[style] = {} end end meta end
None
app/models/media_attachment.rb def populate_meta meta = {} file.queued_for_write.each
do |style, file| geo = Paperclip::Geometry.from_file file meta[style] = { width: geo.width.to_i, height: geo.height.to_i, size: "#{geo.width.to_i}x#{geo.height.to_i}", aspect: geo.width.to_f / geo.height.to_f, } rescue Paperclip::Errors::NotIdentifiedByImageMagickError meta[style] = {} end meta end
None
https://github.com/bkerley/mastodon/commit/589cdff
tides_and_currents • Code for Miami project • Gets tides and
currents data from NOAA • Quick and dirty ruby scripts
get_stations.rb field_names = %w{geoGroupName stationId lat lon} #
… out_json = doc['stationList'].map do |stn| # … field_names.map do |fn| stn[fn] end end.compact
None
get_stations.rb field_names = %w{geoGroupName stationId lat lon} #
… out_json = doc['stationList'].map do |stn| # … stn.slice(*field_names).values end.compact
None
https://github.com/bkerley/tides_and_currents/commit/bbb8ab78
Topics • Intro • Features • Demos • Q&A
Thanks