« Back to channel list

#ruby - 18 January 2019

« Back 1 day
[00:01:56] chouhoulis: has joined #ruby
[00:07:26] chouhoulis: has joined #ruby
[00:12:57] chouhoulis: has joined #ruby
[00:13:05] hutch: has joined #ruby
[00:18:31] chouhoulis: has joined #ruby
[00:22:00] AJA4351: has joined #ruby
[00:24:06] chouhoulis: has joined #ruby
[00:25:44] jaddison: has joined #ruby
[00:27:21] hutch: has joined #ruby
[00:29:36] chouhoulis: has joined #ruby
[00:35:10] xrexeon: has joined #ruby
[00:35:11] chouhoulis: has joined #ruby
[00:35:55] bmurt: has joined #ruby
[00:44:21] irdr: has joined #ruby
[00:52:17] armatechnicos: has joined #ruby
[00:56:17] AJA4351: has joined #ruby
[01:02:27] hutch: has joined #ruby
[01:08:09] bmurt: has joined #ruby
[01:17:13] hutch: has joined #ruby
[01:25:34] uplime: has joined #ruby
[01:27:54] hutch: has joined #ruby
[01:30:18] ansraliant: has joined #ruby
[01:30:38] perique: has joined #ruby
[01:31:34] nertzy: has joined #ruby
[01:51:24] Azure|dc: has joined #ruby
[01:51:36] jottr_: has joined #ruby
[01:51:48] bmurt: has joined #ruby
[01:52:55] DTZUZO_: has joined #ruby
[01:53:01] cthulchu_: has joined #ruby
[01:55:25] ogotai_: has joined #ruby
[01:55:47] noboruma_: has joined #ruby
[01:56:06] ramfjord: has joined #ruby
[01:56:14] _phaul: has joined #ruby
[01:57:33] wolfshappen_: has joined #ruby
[01:59:03] irdr_: has joined #ruby
[02:00:46] lambarena: has joined #ruby
[02:02:25] Paraxial: has joined #ruby
[02:06:23] xrexeon: has joined #ruby
[02:07:34] GodFather: has joined #ruby
[02:08:02] dhollinger: has joined #ruby
[02:08:30] leah2: has joined #ruby
[02:09:20] t0xik: has joined #ruby
[02:33:00] tdy: has joined #ruby
[02:42:35] uplime: has joined #ruby
[02:42:50] orbyt_: has joined #ruby
[02:54:48] sanscoeur: has joined #ruby
[02:56:14] jaddison: has joined #ruby
[02:56:26] jottr_: has joined #ruby
[03:11:20] hutch: has joined #ruby
[03:12:23] esrse: has joined #ruby
[03:37:31] houhoulis: has joined #ruby
[03:47:14] ramfjord: has joined #ruby
[04:09:12] DTZUZO_: has joined #ruby
[04:09:33] braincrash: has joined #ruby
[04:16:28] sanscoeur: has joined #ruby
[04:20:54] tdy: has joined #ruby
[04:30:11] _whitelogger: has joined #ruby
[04:35:42] kapil____: has joined #ruby
[04:38:41] brandonkal: has joined #ruby
[04:41:00] brandonkal: has left #ruby: ()
[04:45:25] sauvin: has joined #ruby
[04:48:45] dante: has joined #ruby
[04:55:37] themsay: has joined #ruby
[04:58:05] \void: has joined #ruby
[05:05:32] jottr_: has joined #ruby
[05:19:50] fanta7531: has joined #ruby
[05:22:30] duderonomy: has joined #ruby
[05:22:33] themsay: has joined #ruby
[05:26:26] tdy: has joined #ruby
[05:51:48] paranoicsan: has joined #ruby
[05:52:48] Puffball: has joined #ruby
[05:53:42] conta: has joined #ruby
[06:16:09] themsay: has joined #ruby
[06:21:56] conta: has joined #ruby
[06:23:28] marmotini: has joined #ruby
[06:24:19] themsay: has joined #ruby
[06:29:00] venmx: has joined #ruby
[06:31:35] tdy: has joined #ruby
[06:49:53] dellavg_: has joined #ruby
[06:55:27] powerbit: has joined #ruby
[07:05:38] Nicmavr: has joined #ruby
[07:06:23] jottr_: has joined #ruby
[07:08:27] aupadhye: has joined #ruby
[07:13:46] Avinash: has joined #ruby
[07:24:34] cgfbee: has joined #ruby
[07:30:09] Fusl: has joined #ruby
[07:30:28] Avinash: has joined #ruby
[07:32:28] makara: has joined #ruby
[07:34:12] makara: Beginner Q: i have a method: def index_for ( words, word )
[07:34:44] makara: I invoke it with: index_for ( %w{ Mary had a little lamb }, "little" )
[07:35:00] makara: and get the error: SyntaxError: unexpected ')', expecting end-of-input
[07:37:05] tbuehlmann: makara: remove those spaces before/after ( and )
[07:39:33] makara: tbuehlmann: no difference
[07:40:09] conta: has joined #ruby
[07:40:18] makara: index_for (["Mary", "had", "a", "little", "lamb"], "little")
[07:40:23] tbuehlmann: the following will not raise an error: def index_for(words, word); end; index_for(%w{Mary had a little lamb}, "little")
[07:40:40] aufi: has joined #ruby
[07:41:01] makara: tbuehlmann: ok gotcha
[07:44:32] n13z: has joined #ruby
[07:57:10] _whitelogger: has joined #ruby
[08:10:51] prestorium: has joined #ruby
[08:13:14] Cyrus: has joined #ruby
[08:13:57] clemens3: has joined #ruby
[08:19:44] za1b1tsu: has joined #ruby
[08:20:11] clemens3_: has joined #ruby
[08:25:21] za1b1tsu: I want to assign a constant to module/class https://pastebin.com/mGGKcevh
[08:25:22] ruby[bot]: za1b1tsu: we in #ruby do not like pastebin.com, it loads slowly for most, has ads which are distracting and has terrible formatting. Please use https://gist.github.com
[08:25:41] za1b1tsu: but it seems I cannot do this, anyway around this?
[08:26:56] _phaul: swap the order of the code
[08:28:07] Avinash: has joined #ruby
[08:28:39] phaul: za1b1tsu: works fine if the module comes first
[08:29:47] za1b1tsu: so if I split them into files, I should make sure the helpers get required first
[08:29:57] phaul: pretty much
[08:29:59] za1b1tsu: this does not seem like good practice, right?
[08:32:23] phaul: it depends on what you are doing. making the code dependent on require order is not good practise. means that you have strong coupling between the things in those files
[08:33:25] phaul: but if they are strongly coupled mmaybe they are always required together. maybe expose a single top level file that outside world can require and that requires the former two in the right order
[08:37:41] za1b1tsu: I see, thank you
[08:43:11] paranoicsan: has joined #ruby
[08:48:03] phaul: za1b1tsu: or thinking about it. you could just require the ones that needs the other in that file :) simples ...
[08:56:01] tdy: has joined #ruby
[09:00:13] tdy: has joined #ruby
[09:07:22] jottr_: has joined #ruby
[09:07:37] RedNifre: has joined #ruby
[09:10:53] Emmanuel_Chanel: has joined #ruby
[09:12:19] jordanm: has joined #ruby
[09:13:50] mikecmpbll: has joined #ruby
[09:20:00] G: has joined #ruby
[09:30:03] ellcs: has joined #ruby
[09:30:38] jottr_: has joined #ruby
[09:34:38] Guest55233: has joined #ruby
[09:35:03] nowhere_man: has joined #ruby
[09:35:24] mister_solo: has joined #ruby
[09:41:28] mikecmpbll: how come it doesn't matter whether i extend or include, here? https://gist.github.com/mikecmpbll/f1468f69ed04002a7ec6c8672dbf7fab
[09:41:50] mikecmpbll: has left #ruby: ("inabit.")
[09:41:53] mikecmpbll: has joined #ruby
[09:44:05] mikecmpbll: has joined #ruby
[09:44:11] mikecmpbll: textual went weird.
[09:46:30] paranoicsan: has joined #ruby
[09:54:09] GodFather: has joined #ruby
[10:00:30] blackmesa1: has joined #ruby
[10:01:32] venmx: has joined #ruby
[10:06:11] Avinash: has joined #ruby
[10:12:49] marmotini_: has joined #ruby
[10:49:43] blackmesa1: has joined #ruby
[11:00:16] reber: has joined #ruby
[11:04:16] arquebus: has joined #ruby
[11:11:56] olspookishmagus: has joined #ruby
[11:37:47] snk: has joined #ruby
[11:42:42] RougeR: has joined #ruby
[11:44:59] RedNifre: has joined #ruby
[11:48:54] Aqo: has joined #ruby
[11:56:44] paranoicsan: has joined #ruby
[12:04:39] akem: has joined #ruby
[12:06:00] al2o3-cr: has joined #ruby
[12:08:15] phaul: al2o3-cr: just found a bug in ruby[bot] , wanna see?
[12:12:29] AJA4350: has joined #ruby
[12:15:05] Avinash: has joined #ruby
[12:20:27] phaul: ok.. now Im getting confused.
[12:20:39] phaul: the bug was:
[12:20:46] phaul: ast>> `testing`
[12:20:47] ruby[bot]: phaul: I have parsed your code, the result is at https://eval.in/1078899
[12:21:08] phaul: which is obviously wrong.
[12:21:44] phaul: but seems that RubyVM::AbstractSyntaxTree also doesn't handle Kernel#` well
[12:24:08] phaul: &>> RubyVM::AbstractSyntaxTree.parse("`testing`")
[12:24:09] rubydoc: # => #<RubyVM::AbstractSyntaxTree::Node:SCOPE@1:0-1:9> (https://carc.in/#/r/6156)
[12:24:31] phaul: &>> pp RubyVM::AbstractSyntaxTree.parse("`testing`")
[12:24:31] rubydoc: # => (SCOPE@1:0-1:9 tbl: [] args: nil body: (XSTR@1:0-1:9 "testing")) ...check link for more (https://carc.in/#/r/6157)
[12:25:28] ramfjord: has joined #ruby
[12:25:40] phaul: maybe XSTRING is backticked string?
[12:26:24] blackmesa1: has joined #ruby
[12:29:18] phaul: ACTION expected to see method call
[12:31:17] RougeR: does anyone know how to dynamically include modules in ruby
[12:31:21] RougeR: im doing some metaprogramming
[12:31:39] RougeR: i.e klass = Object.const_get(type)
[12:31:50] RougeR: klass.include(FooModule)
[12:31:55] RougeR: something like that
[12:33:52] phaul: RougeR: sounds reasonable to me, what's the issue?
[12:36:39] al2o3-cr: phaul: why is it parsing like this? pp Ripper.sexp(%q`testing `testing`)
[12:37:42] al2o3-cr: &>> require'ripper'; Ripper.sexp("`testing`")
[12:37:44] rubydoc: # => [:program, [[:xstring_literal, [[:@tstring_content, "testing", [1, 1]]]]]] (https://carc.in/#/r/615f)
[12:38:01] al2o3-cr: i don't understand.
[12:38:15] RougeR: phaul, im not quite sure
[12:38:18] RougeR: is that the way of doing it.
[12:40:48] al2o3-cr: &>> Ripper.sexp(%(testing `testing`))
[12:40:49] rubydoc: # => uninitialized constant Ripper (NameError) (https://carc.in/#/r/615h)
[12:40:58] al2o3-cr: &>> require'ripper';Ripper.sexp(%(testing `testing`))
[12:40:59] rubydoc: # => [:program, [[:command, [:@ident, "testing", [1, 0]], [:args_add_block, [[:xstring_literal, [[:@tstri ...check link for more (https://carc.in/#/r/615i)
[12:41:04] sarink: has joined #ruby
[12:41:49] Avinash: has joined #ruby
[12:41:58] phaul: al2o3-cr: it's an acient old bug in ruby[bot] that rubydoc has inherited
[12:42:55] phaul: https://github.com/phaul/yarr/blob/evaluate/lib/evaluator.rb#L20 <- the bug
[12:44:34] al2o3-cr: that explains why. ;)
[12:53:18] phaul: but that shows that ripper agrees with rubyvm, it's an xtrsing. neither does method call to Kernel#`
[12:53:27] phaul: &ri Kernel#`
[12:53:27] rubydoc: https://ruby-doc.org/core-2.6/Kernel.html#method-i-60
[12:54:54] al2o3-cr: yeah, i see that.
[12:57:39] al2o3-cr: how about with %x()
[12:59:14] phaul: maybe at the instruction sequence level...
[12:59:32] lubekpl: has joined #ruby
[12:59:49] al2o3-cr: yeah, true.
[13:13:57] bmurt: has joined #ruby
[13:17:17] phaul: ok. here's a challange. given a string '`' using sub, susbtitute ` with \`.
[13:20:48] jottr_: has joined #ruby
[13:22:12] al2o3-cr: phaul: sub(s, '\\\`')
[13:23:01] wildermind: has joined #ruby
[13:25:03] xrexeon: has joined #ruby
[13:25:57] xrexeon: has joined #ruby
[13:31:44] phaul: yeah. this is sooo broken. to_json also replaces \ with \\ when sending the request up. And on the server side you end up with %q`\\\\`testing`\\\\` which is again broken
[13:32:21] phaul: &>> require 'json'; '\\'.to_json
[13:32:22] rubydoc: # => "\"\\\\\"" (https://carc.in/#/r/615m)
[13:33:07] al2o3-cr: &>> s = "`"; puts s.sub(s, '\\\`')
[13:33:09] rubydoc: # => \` ...check link for more (https://carc.in/#/r/615n)
[13:34:37] phaul: yes that's correct
[13:35:18] phaul: ah. I shouldn''t look at the json serialized number of \ because the server surely desireilizes it!
[13:35:47] phaul: so confusing :)
[13:35:59] al2o3-cr: and probably change the delimiters to %q to make it less confusing.
[13:37:43] al2o3-cr: phaul: you can also use String#dump for that instead of requiring json.
[13:38:27] Avinash: has joined #ruby
[13:39:23] phaul: json is called on a hash, the hash has the string
[13:40:52] al2o3-cr: ah, thought it was directly on a string.
[13:41:45] phaul: I'm just gonna push a refactor + specs + fixes in a second... let's see if this works.. /me fingers Xed
[13:46:19] rubydoc: has joined #ruby
[13:46:30] phaul: &ast>> `testing`
[13:46:31] rubydoc: I have parsed your code, the result is at https://carc.in/#/r/615u
[13:47:59] RougeR: yeah this is what i was doing
[13:48:02] RougeR: https://dpaste.de/ExhF
[13:48:36] RougeR: so i want to overwrite the initialize and configure methods with those from a module or class.
[13:48:45] RougeR: i.e CopyFromS3
[13:49:21] RougeR: so S3storage is just a middle class
[13:51:59] phaul: but include won't work there as the module is above the class in the ancestry
[13:52:15] phaul: prepend instead of include
[13:52:19] RougeR: yeah ive seen that.
[13:52:29] RougeR: i tried prepend as well. didnt seem to work in irb
[13:52:47] RougeR: also what do you reckon of this way of doing it?
[13:52:53] RougeR: as opposed to a typical factory
[13:54:52] al2o3-cr: phaul: yay, but wouldn't just changing the delimiters to %q be easier :P
[13:55:27] al2o3-cr: yeah but you're using %q``
[13:55:52] al2o3-cr: it could be %q() %q|| %q** anything but `
[13:55:52] phaul: ok, maybe Im misunderstanding you
[13:56:17] phaul: let me show you the template string its using
[13:56:59] phaul: https://github.com/phaul/yarr/blob/evaluate/config/yarr_sample.yml#L48
[13:57:38] phaul: isn't it the same issue though? whatever delim Im using I need escape logic for the user code if it contains the delim?
[13:58:19] RougeR: https://stackoverflow.com/questions/27542099/is-it-possible-to-include-module-per-object-in-rubyhttps://stackoverflow.com/questions/27542099/is-it-possible-to-include-module-per-object-in-ruby
[13:58:26] RougeR: trying to implement this in pry
[13:59:11] al2o3-cr: phaul: oh, i see now why you're doing it this way.
[14:00:50] phaul: RougeR: you can include a module of the singleton_class of the object I guess
[14:00:58] phaul: let me try that..
[14:01:06] RougeR: https://dpaste.de/GnGo
[14:02:03] RougeR: and yeah see the example for what im trying to acomplish
[14:02:18] RougeR: or i could add them in to the class with metaprogramming, but would then have too remove them after
[14:02:34] RougeR: adding them into the instance of the class means i can just throw it away after the task is complete
[14:02:51] al2o3-cr: RougeR: foo.singleton_class.prepend Bar
[14:02:56] phaul: https://gist.github.com/791068846bffc49195620fb43dd62cb2
[14:03:20] RougeR: okay thats interesting. let me undestand whats going on there n try it
[14:03:38] phaul: or prepend, as al2o3-cr did, depending on which method you want to win
[14:04:12] RougeR: i want the module method to overwrite the class methods
[14:04:30] phaul: then prepend
[14:07:37] RougeR: both seem to work
[14:07:42] RougeR: let me look at whats going on
[14:08:00] phaul: ACTION afk
[14:08:09] RougeR: ACTION nods
[14:11:41] al2o3-cr: RougeR: your way also works.
[14:13:20] jarlopez: has joined #ruby
[14:13:28] jarlopez: In RSpec, is there a way to catch/inspect the _second_ call to a particular function of an object?
[14:15:14] gix: has joined #ruby
[14:16:19] RougeR: you want to see whats happening jarlopez or you want to add it to a test?
[14:16:22] RougeR: both can be done
[14:18:39] jarlopez: RougeR: Running a test, I want to ensure that the arguments to the second invocation contain a specific value
[14:19:01] Inline: has joined #ruby
[14:20:04] jarlopez: What I wrote so far is `expect(theObj).to receive(:the_func)` followed by the same thing with a `do |the, args| <assertions on args> end`
[14:23:12] Puffball: has joined #ruby
[14:25:37] ramfjord: has joined #ruby
[14:26:05] d^sh_: has joined #ruby
[14:37:33] jcalla: has joined #ruby
[14:37:54] phaul: al2o3-cr: ah, because the module is included in between the class and the singleton class. makes sense
[14:38:57] phaul: jarlopez: what sort of assertions on the args?
[14:39:12] phaul: maybe you just need .with not a block
[14:40:34] RougeRR: has joined #ruby
[14:41:56] rippa: has joined #ruby
[14:42:56] blackmesa1: has joined #ruby
[14:43:02] jarlopez: phaul: I'm running this: `expect(theArgHash).to include('the_key')`
[14:48:03] marmotini: has joined #ruby
[14:48:05] jottr_: has joined #ruby
[14:48:10] phaul: there is hash_including https://relishapp.com/rspec/rspec-mocks/v/3-8/docs/setting-constraints/matching-arguments
[14:49:20] phaul: for the multiple receives : https://relishapp.com/rspec/rspec-mocks/v/3-8/docs/basics/spies
[14:52:18] Avinash: has joined #ruby
[14:54:25] Rapture: has joined #ruby
[14:56:01] Cthulu201: has joined #ruby
[14:57:25] Dbugger: has joined #ruby
[14:58:19] gnufied: has joined #ruby
[14:59:36] orbyt_: has joined #ruby
[15:04:38] zapata_: has joined #ruby
[15:07:19] Pillus: has joined #ruby
[15:09:58] queip: has joined #ruby
[15:14:23] phaul: jarlopez: https://gist.github.com/9c919bb9b2dd4810d62e21f8c3f0ed4b took me a while :)
[15:16:26] bmurt: has joined #ruby
[15:17:07] marmotini: has joined #ruby
[15:18:35] jarlopez: phaul: Many thanks! For certain reasons I'm forced to use `expect_any_instance_of(...)`, which apparently doesn't chain with `.ordered`
[15:25:33] RougerRR_: has joined #ruby
[15:28:59] al2o3-cr: well i never knew scrypt was in openssl.
[15:29:59] up|ime: sometimes not knowing things about openssl is a blessing ;)
[15:30:07] marmotini: has joined #ruby
[15:30:25] jacksop: has joined #ruby
[15:33:27] al2o3-cr: &list scrypt
[15:33:28] rubydoc: OpenSSL::KDF.scrypt
[15:33:43] al2o3-cr: i tell you what that is a handy bot.
[15:50:19] jaddison: has joined #ruby
[15:50:40] uplime: has joined #ruby
[15:52:47] jordanm: has joined #ruby
[15:54:24] conta1: has joined #ruby
[16:05:25] skryking: has joined #ruby
[16:11:07] loincloth: has joined #ruby
[16:23:58] TheBetrayer: has joined #ruby
[16:27:10] Xiti: has joined #ruby
[16:27:23] davidw: has joined #ruby
[16:30:19] ericboehs: has joined #ruby
[16:31:19] TheBetrayer: has joined #ruby
[16:33:16] chouhoulis: has joined #ruby
[16:33:56] chouhoulis: has joined #ruby
[16:34:48] jaddison: has joined #ruby
[16:37:18] TheBetrayer: has joined #ruby
[16:37:46] bmurt: has joined #ruby
[16:38:52] kenichi: has joined #ruby
[16:40:17] CrazyEddy: has joined #ruby
[16:48:21] porg: has joined #ruby
[16:48:23] hutch: has joined #ruby
[16:50:56] bmurt: has joined #ruby
[16:57:28] mjolnird: has joined #ruby
[17:00:54] perique: has joined #ruby
[17:04:29] lfish: has joined #ruby
[17:09:41] themsay: has joined #ruby
[17:12:58] lfish_: has joined #ruby
[17:15:30] lfish_: Hello, what does the "on _ do" sequence do in a ruby on rails? What quick tutorial do you recommend to start understanding things?
[17:15:49] ruby[bot]: Please join #RubyOnRails for Rails questions. You need to be identified with NickServ, see /msg NickServ HELP
[17:20:25] \void: has joined #ruby
[17:21:12] TheBetrayer: has joined #ruby
[17:24:39] themsay: has joined #ruby
[17:26:40] TheBetrayer: has joined #ruby
[17:32:17] RedNifre: has joined #ruby
[17:35:21] sarink: has joined #ruby
[17:41:03] bmurt: has joined #ruby
[17:41:04] RougeRR: has joined #ruby