#ruby - 07 May 2019
« Back 1 day Forward 1 day »
[07:43:43] marz_d`ghostman: What's the best way to mock a object that is connected to an external service that will be my source of data for the app?
[12:50:47] ruby[bot]: Bish: # => undefined method `iso8601' for Time:Class (NoMethodError) ...check link for more (https://eval.in/1103737)
[12:50:56] ruby[bot]: Bish: # => wrong number of arguments (given 0, expected 1) (ArgumentError) ...check link for more (https://eval.in/1103738)
[12:53:52] ruby[bot]: Bish: # => "2019-05-07T12:53:52.0727331890000000000000000000000000000000000000000000000000000000000000000000000 ...check link for more (https://eval.in/1103745)
[12:55:23] Bish: well.. it doesn't make sense, but the Time instance also has a iso8601 method that takes a parameter
[13:33:41] ep4sh2k__: Hi! Could you tell me, which analog to Python virtualenv can I use? I tried for RVM but it need to install some new packages on server (libffi-devel, readline-devel, sqlite-devel) - but i cant do it
[13:37:40] adam12: ep4sh2k__: I can't speak in depth of this since I normally use bundler on the server but `gem` supports a --user-install argument
[13:37:54] adam12: ep4sh2k__: And if you set GEM_HOME to a path you control, gem will honour it and install there.
[13:39:00] adam12: ep4sh2k__: There's the gem_home tool that automates setting $GEM_HOME and $PATH for you. https://github.com/postmodern/gem_home
[13:39:28] adam12: ep4sh2k__: Oh I see. In that case, your options are either use a version manager like chruby/rbenv, or just manually build it.
[13:40:00] adam12: ep4sh2k__: Actually, I just re-read your issue and I see what you're talking about now. You need system packages installed.
[13:41:28] adam12: ep4sh2k__: Well, installing those -devel packages won't hurt anything, since they are just headers.
[13:43:03] adam12: ep4sh2k__: Outside of that, maybe you could get by with the CentOS SIG for Ruby, depending on the Ruby version. I'm not sure they are shipping 2.6 but I believe 2.5 is shipping. https://lists.centos.org/pipermail/centos-announce/2018-June/022919.html
[13:51:11] adam12: ep4sh2k__: Correct. The libraries are likely already installed, and binary installed packages (using yum/dnf) don't need the headers when installing since they're already compiled and linked.
[14:53:20] havenwood: WSL 2 looks promising for Ruby on Windows now that it'll have full system call compatibility rather than a translation layer. https://devblogs.microsoft.com/commandline/announcing-wsl-2/
[14:53:42] adam12: havenwood: I'm excited for it, tho I'm not sure how I'll adjust to not developing on FreeBSD
[14:56:05] adam12: havenwood: tbh I'm more excited about the console. I'm using wsltty which is .. fine, but they're all mostly lackluster.
[14:56:30] havenwood: looks like they already have a closed issue for FreeBSD support: https://github.com/Microsoft/WSL/issues/1783
[15:00:35] havenwood: "I would recommend you just run a BSD environment in a container on top of WSL, which is already executing at near-native speed. Let qemu handle the syscall translations."
[15:04:36] adam12: I wish BSDs weren't so often overlooked. I've started a project to nightly test a bunch of Ruby gems with C extensions just to try to see which ones use Linuxisms and cause breakages.
[15:11:55] havenwood: That's a great thing to track. It reminds me a bit of TruffleRuby's gem compatibility checker: https://www.graalvm.org/docs/reference-manual/compatibility/
[15:13:41] havenwood: It'd be awesome to be able to check a Gemfile.lock and see if the gems tests are green on Linux, Windows, the BSDs, macOS, etc.
[15:17:40] adam12: I can't say I blame the gem authors. CI for FreeBSD/OpenBSD/whatever has always been a bit of a unicorn, since you can't use Docker to test them.
[15:18:55] englosh: The beginning of an error: "file:1: syntax error, ...". Is it possible to change "file" to something else in the error message within the Ruby file?
[15:22:07] adam12: englosh: Are you requiring or loading that file from somewhere? or calling it directly.
[15:24:29] englosh_: I could gsub every `file:\d+:in` instance by that what I want but there's the chance that actual code in the error message will be replaced as well
[15:25:47] adam12: englosh_: I'm not sure if Ruby calls Kernel.load for `ruby ARGV` but if it does, you could _bleh_ monkeypatch load.
[15:26:24] adam12: englosh_: ruby -e 'begin; load "file.rb"; rescue LoadError; abort "oh noes"; end'
[15:27:08] adam12: englosh_: if you can get "oh noes" out of that, then you could probably work backwards. Find out if there's an exception being raised and see if you can change the formatting.
[15:27:35] englosh_: putting `module Kernel def load puts "hi" end end` in the file and running does nothing
[15:37:20] havenwood: englosh_: There's no super simple way to change a filename. $FILENAME and ARGF.filename aren't settable. Why do you want to change the name in the error output?
[15:37:50] englosh_: because I don't like it. I use a REPL API and it doesn't let me change the file name
[15:40:24] havenwood: englosh_: I don't quite follow. What REPL API are you using? Do you have a terminal or it's a direct Ruby REPL?
[15:43:04] havenwood: englosh_: Ah, yeah - that's tough - since the API is reading from STDIN it's showing that as the filename.
[15:50:49] adam12: zenspider: Not sure if you're around? but curious to know if there's a better place to start experimenting with mt6 outside of the branch on your personal repo.