#ruby - 09 November 2018
« Back 1 day Forward 1 day »
[02:26:15] havenwood: On modern Ruby, `chomp: true` is a nifty addition: File.readlines('json', chomp: true)
[03:05:15] stalactit: this may interest people in this channel https://www.elttam.com.au/blog/ruby-deserialization/
[03:05:37] stalactit: it releases the first public universal gadget chain to achieve arbitrary command execution for Ruby 2.x
[04:49:03] marz_d`ghostman: Pertaining instance variable, I've seen people assign values to instance variables then create a attr_reader with the same name as the instance variable so they can refer to the instance variable without '@'. How does that work and what's the advantage of doing it?
[06:10:42] marz_d`ghostman: I'm trying to override a subject inside an inner context. However, it appears that the variable inside the inner context which is suppose to be local inside the context is overriding the subject outisde of the context.
[09:32:34] Cork: when on is defining a method_missing; is it possible when calling super (cause it isn't handled) to have the stacktrace show the original location?
[10:03:43] marz_d`ghostman: when doing tests in rsped for your class method do you put each method test via describe under one whole describe 'Class'?
[10:13:45] tbuehlmann: I'm usually doing this: RSpec.describe SomeClass do; describe '.some_class_method' do; <examples here>; end ; end
[10:15:26] phaul: marz_d`ghostman: sometimes. My main rule of thumb is that it has to produce sensible description of the test when all fragments (descibe, context, it, expect) are pasted
[10:18:50] marz_d`ghostman: phaul: I'm trying to test each method of my class. So basically I have Rspec.describe Class then describe '#method'. However, my problems is I want to create a subject for each method is that even possible? I tried it but it appears that the subjects overrides each other
[10:20:22] marz_d`ghostman: phaul: Yeah. Also, when testing, I want to terminate after an expect is met. How do I do that? so it won't go on and continue the entire script
[10:22:23] phaul: you can tell rspec which example to run on the command line, then it runs a single example
[10:23:53] phaul: otherwise RSpec runs all examples. There are further options to track and retry only last failing example for instance
[10:34:20] phaul: random rambling: I think the `context' concept in rspec is broken. it's just an alias to describe afaik, but to me a context is much more. A context is like a concern to a class, we should be able to mix in any number and combination of contexts, in a flat manner, not deep embeding them into each other..
[10:35:01] phaul: but.. ppl are already think rspec is complex enough and hard to understand as it is :)
[10:48:15] ruby[bot]: Bish: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `' for nil:NilClass
[10:50:06] Daneel: i would like to do this in ruby https://gitlab.adullact.net/adullact/puppet-gitlabrunner/blob/master/lib/facter/gitlabrunners.rb#L14
[11:48:52] phaul: Bish: I did a bit of background research, and I came to the conclusion that I agree with you. === is semantically broken, because Object implements it and makes a promise that == implies ===. Then overriding implementations completely disregard super
[13:10:17] phaul: yeah, it breaks polymorphism. Class is almost like an Object but not quite. The way out is not to define === for Object, but then you get NoMethod === errors from case statements, which can also be confusing for someone who just starts off with ruby
[13:24:29] Bish: start by displaying a list of items, then add a form( u know those from php right? ), then save it
[13:25:24] biberao: https://www.codeconquest.com/wp-content/uploads/Ruby-Cheat-Sheet-by-CodeConquestDOTcom.pdf
[14:31:58] Tohm3: Hey Guys, I'm New To Ruby And The Rails Environment. I've Been Google'n "Ruby On Rails App Templates". Like With LAMP Environments And Gradle Where You Can Take A Prebuilt Template And Just Edit It A Bit. But I Can't Find Any, Do These Even Exist On Rails?
[14:52:41] mnemon: Tohm3: you can find complete applications in github and such. but Gradle and Rails are pretty different.
[15:43:26] Tohm3: I've Looked Into A Few On Github, But I'm Starting To Realize Ruby Isn't Great With Different Versions. If The App Is Built In 2.3 And I'm Using 5.2 It's A Nightmare And None Of Those Let Me Just Run A Build Command And Start A Server. I Always Run Into 1Million Errors
[15:49:01] Tohm3: phaul: I'm Sorry If It Seems That Way, I'm Just New To Ruby And I'm Sharing My Experience With It So Far And Try'n To See How I Can Use It That's Similar To The Other Environments I've Used
[15:51:29] Tohm3: I've Run Into A Lot Of Version Issues With Try'n To Get Github Repos Built On Ruby Running And I Don't Know If It's Just Stupidity On My Part Or If It's Designed That Way. It's Just My Impression.
[15:54:44] leitz: Tohm3, most of the Ruby I've done in version 2.x and greater seems to work okay, though newer versions add stuff.
[15:55:28] leitz: If you're just trying to learn, does the OS come with a version of Rails and Ruby? They will be old, and if you try to install gems and use github repositories you'll have issues.
[15:55:48] leitz: But if you can just start with the basics, it's pretty fun. Well, Ruby is. Not sure about Rails.
[16:04:17] Tohm3: Thanks Guys. I Guess I Have Been Working Backwards. But TBH It's Kinda How I've Learned Everything I Know Up Till Now, Lol
[16:04:57] Tohm3: I Guess I'll Just Have To Take A More Traditional Role With Ruby. Thanks For The Insight
[16:14:50] leitz: Tohm3, it sort of depends. The issue isn't Ruby, exactly, but trying to mix your sources.
[16:15:30] leitz: It took me a while to like Ruby (and to put up with some of the gruff here) but once I got into it I was hooked. I've only moved away because I'm on a new career that isn't Ruby based.
[16:35:29] leitz: havenwood, i couldn't remember that one. Jeremy impresses me, though that doesn't take much.
[20:33:58] ruby[bot]: Bish: I'm terribly sorry, I could not evaluate your code because of an error: NoMethodError:undefined method `' for nil:NilClass
[21:10:27] rubydoc: # => private method `rand' called for 1..5:Range (NoMethodError) (https://carc.in/#/r/5h3x)
[21:10:43] rubydoc: # => undefined method `sample' for 1..5:Range (NoMethodError) (https://carc.in/#/r/5h3z)
[21:10:49] rubydoc: # => [[0, 2, 5, 4, 1], , [2, 4], [3, 1, 0, 4], [4, 2, 3, 5, 0], [1, 5, 3]] (https://carc.in/#/r/5h40)
[22:02:02] aarkerio: I mean, I have this method: params.require(:data).require(:name, :email, :password)
[22:03:32] aarkerio: something like: fields = action_name == "signup" ? [:name, :email, :password] : [:email, :password]
[22:05:30] nchambers: it takes a variable number of symbols right? you could just do something like: fields = [:email, :password]; fields << :name if action_name == "signup"; params.require(*fields)
[22:31:49] al2o3-cr: &>> ([*?a..?z,*' ']*'').unpack('x11aX8ax7ax7aX4ax0ax7aX23ax16aX18ax19aX3aX16aX4ax12aX14a')*''
[22:40:12] al2o3-cr: but i suppose it could be, you know what i've never thought about doing it this way.