Skip to content

Instantly share code, notes, and snippets.

@maiha
Last active November 23, 2016 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maiha/541f286ab578a6c46d13886edc05ece6 to your computer and use it in GitHub Desktop.
Save maiha/541f286ab578a6c46d13886edc05ece6 to your computer and use it in GitHub Desktop.
practical migrating guide to crystal-0.20.0 https://crystal-lang.org/2016/11/22/crystal-0.20.0-released.html
#!/usr/bin/env zsh
set -e
# for shards-0.7
rm -rf shard.lock libs
shards update
echo "/lib/" >> .gitignore
# MemoryIO
sed -i "s/MemoryIO/IO::Memory/g" {src,spec}/**/*.cr

ifdef [REMOVED]

  • Use flag? instead.
-ifdef linux
+{% if flag?(:linux) %}

HTTP::Request [CHANGED]

  • The body type is changed from String? to IO?
no overload matches 'Array(String)#<<' with type (HTTP::ChunkedContent | HTTP::Server::Response | HTTP::Server::Response::Output | HTTP::UnknownLengthContent | HTTP::WebSocket::Protocol::StreamIO | IO::ARGF | IO::Delimited | IO::FileDescriptor | IO::Hexdump | IO::Memory | IO::MultiWriter | IO::Sized | JSON::PrettyWriter | OpenSSL::SSL::Socket | String::Builder | Zlib::Deflate | Zlib::Inflate)
-      ary << req.body.not_nil! if req.body
+      ary << req.body.not_nil!.gets_to_end if req.body

crenv

  • update is essential (supported in master branch)

kemal

  • works with 0.17.0

github/maiha

status

  • crc16.cr
  • crt.cr
  • dstat-redis.cr
  • grafana-redis.cr
  • hq.cr
  • jq.cr
  • kafka.cr
  • opts.cr
  • pcap.cr
  • rcm.cr
  • redis-cluster-benchmark.cr
  • redis-cluster.cr
  • redis-protocol.cr
  • redis-tsv.cr
  • shard.cr
  • toml-config.cr
  • traildb.cr
  • try.cr
@asterite
Copy link

@maiha This is not correct:

-      ary << req.body.not_nil! if req.body
+      ary << req.body.not_nil!.to_s if req.body

You should use req.body.not_nil!.gets_to_end

It might work by accident if the body is an IO::Memory, because its to_s returns the string contents, but in the general case you should use gets_to_end

@maiha
Copy link
Author

maiha commented Nov 23, 2016

@asterite Oh, I see. Thanks! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment