Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ruby 2.5: What's New and What's Cool

Ruby 2.5: What's New and What's Cool

Miami Ruby Brigade
Monday, January 15, 2018

Bryce "BonzoESC" Kerley

January 15, 2018

Transcript

41 slides
  1. 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
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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
  7. tides_and_currents • Code for Miami project • Gets tides and

    currents data from NOAA • Quick and dirty ruby scripts
  8. 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
  9. get_stations.rb field_names = %w{geoGroupName stationId lat lon} 
 
 #

    …
 
 out_json = doc['stationList'].map do |stn| # … 
 stn.slice(*field_names).values
 end.compact

More Decks by Bryce "BonzoESC" Kerley

Other Decks in Programming