PROBLEMS ON MIGRATING
FROM RUBY 1.8 TO 1.9
SEIT 2012
@hurx github.com/elitau
Slide 2
Slide 2 text
ENCODING
• Each and every String needs an Encoding
• # encoding: UTF-8
• http://stackoverflow.com/questions/3291017/how-can-i-avoid-
putting-the-magic-encoding-comment-on-top-of-every-utf-8-
file-in
• https://github.com/m-ryan/magic_encoding
• http://blog.grayproductions.net/articles/
ruby_19s_three_default_encodings
Slide 3
Slide 3 text
LOAD PATHS
• Ruby 1.9 removed “.” from load paths
• It was deemed a "security" risk
• File.expand_path(__FILE__)
• require_relative
• require './filename'
• http://stackoverflow.com/questions/2900370/why-does-
ruby-1-9-2-remove-from-load-path-and-whats-the-alternative
Slide 4
Slide 4 text
MD5
• md5 module is gone
• instead of MD5 it is now Digest::MD5
Slide 5
Slide 5 text
DEBUGGER
• https://github.com/cldwalker/debugger
• works with 1.9.2 and 1.9.3
Slide 6
Slide 6 text
YAML PARSING
• Psych (the new ruby YAML parser) is stricter with syntax
• Fix your YAMLs
• Dirty fix: in config/boot.rb
require 'yaml'
YAML::ENGINE.yamler = 'syck'
• http://stackoverflow.com/questions/4980877/rails-error-
couldnt-parse-yaml
Slide 7
Slide 7 text
PARSEDATE
• Ruby 1.8 has a Parsedate module, gone in 1.9
• use Date.parse instead
• http://stackoverflow.com/questions/4724417/ruby-where-has-
parsedate-gone-in-1-9
Slide 8
Slide 8 text
CASE SYNTAX
• Colons do not work in 1.9 anymore
• when ‘foo’ : ‘bar’
• when :foo then :bar
Slide 9
Slide 9 text
ARRAY.TO_S
• ree-1.8.7-2011.03> [1,2,3].to_s
=> "123"
• 1.9.3p125> [1,2,3].to_s
=> "[1, 2, 3]"
• Do not use implicit conversions
• Better: [1,2,3].join(‘’)
Slide 10
Slide 10 text
MORE RESOURCES
• http://www.rubyinside.com/19walkthrough/
19$, 3 hours, Screencast
• http://www.google.com/search?q=ruby+1.8+1.9+difference