#ruby - 17 May 2018
« Back 1 day Forward 1 day »
[01:37:32] cagomez: I have a CommandFactory class that passes a `command` to a "base command". However, I'm not sure how/where to test the command it passes to the base command. Example here: https://gist.github.com/cagmz/f71fbb54f27e2fb3494f35a9a614a4a3
[01:37:50] cagomez: Specifically, my tests currently don't test https://gist.github.com/cagmz/f71fbb54f27e2fb3494f35a9a614a4a3#file-command_factory-rb-L17-L18
[01:38:51] cagomez: Should I just move those lines into the BaseCommand instance itself? the proc seems kind of gratuitous and I have no real reason to pass a proc into the base command. by doing so, I can test the behavior
[01:47:39] baweaver: Most of the Gang of Four patterns were invented in terms of Java without consideration for anonymous functions
[01:48:14] baweaver: https://github.com/mariofusco/from-gof-to-lambda/tree/master/src/main/java/org/mfusco/fromgoftolambda/examples
[01:52:03] cagomez: I guess it's not strictly a "command". We have a convention of `DoXCommand` because it enforces the SRP
[01:56:07] baweaver: I'd have to see the actual code used but I have a feeling you're making it more complicated than it needs to be.
[04:50:25] baweaver: We can help you learn Ruby, sure, but many people have already written about whether or not it's the right thing for you.
[04:52:34] CuriousMind: I want to learn about them in detail so I understand how the options work and stuff
[04:53:10] baweaver: Either that or look it up on Google for an online version or tutorials around it.
[05:04:03] dminuoso: baweaver: Yes it is. Radar is basically forced to provide a meaningful answer now.
[05:05:52] CuriousMind: I did 'gem install pg' and I was unable to install it. I did 'brew install postgresql' which apparently installed the app but when I do gem list I don't see it. How come?
[05:26:27] domhnall: hi, im looking to use ruby 2.5 while I have 2.4 install. How would I make the switch? Im on FreeBSD...checking documentation also.
[05:29:10] domhnall: hm, something about rvm seems useful. though I installed it but command not available.
[08:46:24] NL3limin4t0r: Do you guys know where the best place is to ask a simple xpath question? I checked the #xpath channel, but that seems to be empty.
[08:49:31] NL3limin4t0r: doc.xpath('//ol[not(ancestor::ol | ancestor::ul)] | //ul[not(ancestor::ol | ancestor::ul)]')
[09:16:25] NL3limin4t0r: This seemed pretty valid xpath: `doc.xpath('some $list in (//ol, //ul) satisfies $list[not(ancestor::ol | ancestor::ul)]')`
[09:17:24] NL3limin4t0r: dminuoso: ty for the link though, I'll need to have a look at that whole page.
[09:33:19] anikras: Hi, anyone knows how can I create a similar htaccess in ruby on rails without apache ?
[09:33:21] CaptainAmari: hi guys, i'm trying to understand a function in ruby, can you help me understand what it does? I did try to google it
[09:34:01] ruby[bot]: dminuoso: I have disassembled your code, the result is at https://eval.in/1005807
[09:53:22] NL3limin4t0r: CaptainAmari: It forwards every call you make on `your_object[attribute] = value` to `yourobject.attribute = value`.
[13:57:31] markand: is there something wrong with the documentation? when you go to the stdlib home you have a different page than modules
[13:57:56] markand: http://ruby-doc.org/stdlib-2.5.1/ -> then selecting a topic like fnctl brings a very different page
[15:03:46] excel_girl: Good morning. Is there a beginner friendly resource for someone who has some python experience? I am looking for a list that names a certain library in Python and names a corresponding library in python.
[15:04:47] havenwood: excel_girl: This doesn't have library info, but it has a quick summary of some differences between Python and Ruby: https://www.ruby-lang.org/en/documentation/ruby-from-other-languages/to-ruby-from-python/
[15:07:19] havenwood: excel_girl: I don't know of a Python/Ruby stdlib comparison but we'd be happy to help here. For gems there are a few resources like:
[15:11:15] excel_girl: I was looking for simple libraries like -- os, subprocess, requests, json, datetime, shutil(for moving files), email(for sending email) and what not
[15:13:28] mnemon: excel_girl: have you looked at the stdlib contents? https://ruby-doc.org/stdlib-2.4.1/
[15:13:29] darix: excel_girl: os/subprocess => popen* and friends. I guess. requests ... depending on what exact use case ... I liked "httpclient", faraday also seems popular, mechanize
[16:49:16] Ericx2x: Can someone take a look at this error? I can't seem to install this rubyracer gem https://imgur.com/a/q8UpdtH
[16:50:35] Ericx2x: The error log it wants me to look into is gibberish: https://imgur.com/a/3mQahZP
[16:53:33] havenwood: ericx2x: If you're using the ruby apt package, make sure the ruby-dev package is installed: sudo apt-get install ruby-dev
[16:59:55] Ericx2x: havenwood, thanks havenwood. I didn't realize rails could rely on node.js with that build essentials command.. still new to rails
[17:05:42] ruby[bot]: Please join #RubyOnRails for Rails questions. You need to be identified with NickServ, see /msg NickServ HELP
[17:06:14] havenwood: ericx2x: Here's a setup guide: https://ryanbigg.com/2014/10/ubuntu-ruby-ruby-install-chruby-and-you
[17:30:01] Ericx2x: Not exactly sure what a JSRuntime is though? Does rails have a JS runtime? I'll have to look it up later
[17:30:43] Ericx2x: Right now I'm just focusing on getting my rails app over to another server and figuring out all the random errors along the way... like this? https://imgur.com/a/lVbj47y
[17:32:12] Ericx2x: Oh, so JS Runtime is what lets you use JS code and that has to be downloaded onto the machine. Got it
[17:37:19] Ericx2x: Sorry to ask another question so soon but what would you do if you got this error? https://imgur.com/a/lVbj47y
[17:42:29] Eiam: you may need to be more specific in your require path, or modify your env variables
[17:47:13] Ericx2x: Thanks for the response Eiam but I don't know what you mean. Where can I be more specific in my require path or modify my env variables? I'll look into this. Sorry if my newbness is annoying :x
[17:47:49] Eiam: so when your code in /home/name/vendor/bundle etc etc is executing, it hits "require kgio_ext"
[17:48:29] Eiam: so you can be more specific about where it is, "require_relative "../blah/kgio_exit" "
[17:48:47] Eiam: or you can ensure that Ruby has more search paths to look in when it tries on its own
[17:50:09] Ericx2x: Sec on that. I've done multiple bundle installs because I'm trying to deploy.. let me see if there is any differences with the types of bundle installs I do
[17:54:53] Ericx2x: so in "vim vendor/bundle/ruby/2.3.0/gems/kgio-2.9.3/lib/kgio.rb" there is on line 21 "require 'kgio_ext'"
[17:55:55] Ericx2x: I need to be more specific on this line Eiam? I don't even know what kgio_ext is or how to ensure it gets required
[18:08:05] rgb-one: I'm running `sass --watch sass/style.sass:css/style.css --compass` and I get `ERROR: Cannot load compass.`, why is this?
[18:18:27] Eiam: yeah if you are doing a bunch of path modifications there is a better solution higher up in the stack
[18:19:14] Ericx2x: I don't really get what that means.. but If you can point me in the direction I'd be willing to figure it out
[18:22:34] Eiam: ericx2x: yeah its a bad thing in general, it makes it less portable. you want environments to control relativeness and search paths usually
[18:23:52] Eiam: then try again, see if that works. it shouldn't matter cause unicorn looks like it requires it already
[21:13:00] tolerablyjake: I'm trying to write a regex that captures is a string starts with "the" and ends in "app"
[21:13:35] tolerablyjake: Does anyone here know a better way to do that? I'm not super great at this sort of thing
[21:16:11] tolerablyjake: apeiros cause I have no idea what i'm doing : ) . I'm trying to tell by the match data if either or matched, if the look behind matches I get an empty string, and I get nil if it doesn't
[21:21:41] tolerablyjake: apeiros sorry, my first question wasn't very clear. I want to know both. The gist has more code that hopefully gives a better idea what I'm shooting for
[21:25:19] tolerablyjake: nice, I like that, a lot clearer. I had just learned about the ? after parens a minute ago
[21:27:16] apeiros: also notice that ^ is not begin of string, but begin of (any) line. \A is begin of string.
[22:02:48] Ericx2x: I have nginx pointing to my rails folder in myapp/public but it won't display anything unless I place an index.html file in there... Is there supposed to be one in there?
[22:07:39] nickjj: it follows the order you place them, so if your upstream doesn't match it will fallback to index.html -- which means if you don't supply your upstream, it won't even know to look for it
[22:39:41] laska: can someone recommend an extensive resource on functional programming in ruby for a novice?
[23:26:30] elomatreb: A new ruby version gets released every Christmas, with bugfix releases as necessary
[23:26:31] hays: just judging by the pattern, looks like minor releases happen in december typically, then there's a release in march and september (mostly)
[23:51:40] havenwood: hays: Use the `# frozen_string_literal: true` magic comment and Stings aren't mutable.