#ruby - 31 July 2018
« Back 1 day Forward 1 day »
[00:29:16] chris349: When I run rake db migrate it takes a long time to start up because its loading a bunch of irrelevant code, gems, etc. Is tehre any way to stop this on have db migrate only load the bare minimum to get the job done?
[00:42:28] ciro: chris349: there is a #RubyOnRails channel. Maybe someone could answer your question there. Anyway, I think you would have to tweak your app's Rakefile. Take a look at this: https://rhnh.net/2010/09/07/speeding-up-rails-rake/
[01:10:37] Synthead: I'm using minitest, and I want to ensure that a method gets called without actually calling the method (kinda like expect(instance).to receive(:method) in rspec)
[09:57:19] Bish: http://www.blacktm.com/blog/ruby-on-webassembly just read this article and it sounded interesting to me
[09:57:41] Bish: wouldn't it be super thrilling for rubyist to have ruby inside the browser with ALL it's features?
[09:59:53] Bish: pair that with some virtual dom language for ruby á la react and i think it would be super awesome
[10:11:21] ineb: its a shame indeed. but dont look away from truffle because of this. they are not oracle and doing a good job
[10:11:44] Bish: well, if it is as good that people could see over that licensing model i would certainly notice
[10:13:03] ineb: i just randomly clicked on someone who is answering issues on gh, https://github.com/chrisseaton and he is oracle
[10:13:07] Bish: and if mruby was completely compatible with 2.5 syntax i would already be writing stuff lijet hat
[10:14:37] Bish: yeah, well, my assumption is truffle has to be more than awesome, to be accepted by the community
[10:15:36] Bish: but if mruby was 100% compatible with 2.5 syntax i'd be already writing some sort of automated framework
[10:20:06] Bish: maybe i will just play around and create a web framework with mruby, wil be fun i guess
[12:48:33] imperator: Isn't there a ruby library out there that will take a rest api specification and autogenerate a bunch of classes for you?
[12:57:49] FernandoBasso: I'll say it again. This channel is more instructive than most Ruby books :D
[13:00:02] ineb: fernandobasso: for collections, imperator gave an solution. another way would be collection.drop(N).each
[13:00:27] ineb: fernandobasso: but iterators dont always have a fixed length and therefore could be problematic in this manner
[14:03:39] bsamorim: Hello! Is running `bundle install` as root user and executing the app as another one a bad practice in ruby?
[14:07:57] ineb: bsamorim: almost always yes. cant you install the required gems relative as normal user via bundle install --path vendor/bundle or so?
[14:10:48] bsamorim: ineb: I haven't tried specifing a --path. Without the arg, I get a EACCESS error. I realize that this is fixable by setting up appropriate group membership to my app-running user but, since after root-bundle-installing the app's dependencies, I could exec the app just fine as another user, I wanted to know what exactly was behind this "no-bundler-as-root" rule
[14:12:03] ineb: bsamorim: basically because you are running arbitrary code in root context. gem installation routines can include any thinkable statements and therefore damage your system
[14:14:42] ineb: bsamorim: but you can of course sudo and stuff if your system is configured that way
[17:37:04] havenwood: TJ-: We might be able to give a better suggestion with more context regarding the surrounding code.
[17:37:37] ruby[bot]: havenwood: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `' for nil:NilClass
[17:45:07] tj-: havenwood: yeah, I noticed that, ignore that bit! I was on about the "until (a = b.method) == nil" construct, where b.method() will at some point return nil - My typing was all over the place originally :)
[17:45:50] tj-: havenwood: is it valid to assign and test the result of the assignment in the same statement like that
[17:46:48] brt: trying to compile ruby 2.5.1 for i686 on the latest x86_64 macos version, but I keep running into strange errors, like `error: use of undeclared identifier 'username_completion_function'; did you mean 'rl_username_completion_function'?` despite it being #define’d earlier in the file (readline.c)
[17:48:33] tj-: havenwood: I'm giving myself a crash-course in Ruby to hack vagrant-mutate with minimally invaise patches, so although I'm reading the docs it's a lot to take in all at once
[19:52:34] tj-: If a super-class has a method definition that has the same name as a sub-class instance variable, is it possible for the instance variable name to over-ride the method or are the names essentially different due to the instance variable's @ prefix? I'm looking for a way to avoid duplicating the same code in sub-classes by moving it to the super, but in some sub-classes the 'name' is just a variable
[20:57:48] jrich523: hey guys, using pry to poke at some code and i get an error msg about using a "guests" member, and im confused to as why, if i do a pp kvm, it looks like this https://gist.github.com/jrich523/b572b8d964f3111febb07a0851c001c9
[21:34:39] jrich523: so, i had this to hash method, pods.each(& :hash) which allowed me to see that data
[21:35:30] jrich523: also on the object init there was a @guests = guests... which, doesnt mean it has an accessor... forgot that :-/
[23:12:22] leitz: Style/clarity question. If you have different programs that will use the same class definition; where each program uses some of the classes' built-in methods and some that only that program uses, is it better to let each program extend the class as it needs or to put everything in the base class?
[23:20:28] mzo: sometimes you need to, but you don't just put your application code into the library
[23:23:18] leitz: It provides a very clean and simple interface, and assumes it will be extended. :)
[23:26:48] leitz: The base class is "Person", with a small set of attributes. Different programs need different attributes; one might want "Career" and another "Hair color" and "psychological profile".
[23:33:11] leitz: One is a space merchant game, another makes generic characters for games and fiction, and another stores and updates characters via a web interface. Note that these are being worked on, so "makes" is used loosely.
[23:34:19] leitz: The Person class has and presents basic data. Name, age, statistics (for a a game), gender. Each of the other programs uses that data plus it's own attributes.
[23:35:17] leitz: So the ship game might assign a work role "First officer on the Karava Manoi". The base class doesn't usually have a "work role" attribute.
[23:35:42] leitz: A character generation program just gives base data and lets the user decide what to add.
[23:36:53] mzo: the thing about adding new instance variables to classes is that none of the existing methods know about your new variables
[23:38:38] mzo: if you're extending a class in a dynamically typed programming language and not overriding any of its methods, something is kind of odd
[23:40:58] mzo: it may seem unsatisfactory to recreate a Person class with a few of the same attributes for each of your programs, so i understand the impulse to go for code re-use, but imo you should just copy and paste the class for each program
[23:43:59] leitz: Each iteration pushes me to think better about the design. That's one of the big reasons for staying with code re-use. The other is to push me to learn how to really use objects. I could do this a lot easier with a struct and some methods.