Problems on migrating from Ruby 1.8 to 1.9

Problems on migrating from Ruby 1.8 to 1.9

Problems encountered on migration simfy codebase from ruby 1.8 to 1.9
Talk for @colognerb

60134178a94193fb4b8a28cdb4771440?s=128

elitau

May 16, 2012
Tweet

Transcript

  1. PROBLEMS ON MIGRATING FROM RUBY 1.8 TO 1.9 SEIT 2012

    @hurx github.com/elitau
  2. 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
  3. 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
  4. MD5 • md5 module is gone • instead of MD5

    it is now Digest::MD5
  5. DEBUGGER • https://github.com/cldwalker/debugger • works with 1.9.2 and 1.9.3

  6. 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
  7. 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
  8. CASE SYNTAX • Colons do not work in 1.9 anymore

    • when ‘foo’ : ‘bar’ • when :foo then :bar
  9. 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(‘’)
  10. MORE RESOURCES • http://www.rubyinside.com/19walkthrough/ 19$, 3 hours, Screencast • http://www.google.com/search?q=ruby+1.8+1.9+difference