« Back to channel list

#ruby - 17 December 2018

« Back 1 day Forward 1 day »
[00:00:38] cnsvc_: has joined #ruby
[00:04:02] hays: phaul: that apparently breaks my use of it in a class
[00:06:59] hays: phaul: https://dpaste.de/qcDK
[00:08:14] hays: sorry more like this https://dpaste.de/MRgX
[00:11:33] phaul: hays: so you would like to have dp_key_calc in the module as both instance and class methods. One way _not the best_ is to extend the module with self.
[00:11:53] phaul: module DPKeyCalc; extend self; ..; end
[00:12:07] phaul: that would at least make it work
[00:12:31] hays: generally speaking im having a hard time understanding how to modularize my code in rubyoutside a very strict OOP paradigm. maybe that's on purpose
[00:13:41] phaul: Ruby usually lets you modularize and DRY up the code fairly well in my opinion.
[00:13:48] nakuku: has joined #ruby
[00:14:24] phaul: The extend self has the side effect of every instance method becoming class method. If you are happy with that then, go for it.
[00:15:56] hays: generally speaking im having a hard time understanding how to modularize my code in rubyoutside a very strict OOP paradigm. maybe that's on purpose
[00:16:00] hays: ack sorry to repeat
[00:19:58] phaul: I think pulling methods out to Modules to modularize and DRY is generarily a good idea. Many projects follow that design. Most of Rails does. But they call it concerns and they do it with some helpers
[00:21:12] phaul: https://github.com/rails/rails/blob/master/activerecord/lib/active_record.rb
[00:23:45] donofrio: has joined #ruby
[00:25:18] nakuku: Hello guys! I have a architectural question - for some of you probably pretty simple. Take a look :-) https://gist.github.com/naku-i386/9d3ac3d7ff46ebb6e8e6875058273eda
[00:28:22] nakuku: And there will be some shared business logic, but i think two services are fine dont you think? And shared business logic should then reside in its own service and can be used in both of these services.
[00:31:03] MasterAsia: has joined #ruby
[00:34:01] donofrio: has joined #ruby
[00:45:56] Lytol: has joined #ruby
[00:48:59] graphene: has joined #ruby
[01:03:28] mads2: has joined #ruby
[01:05:23] mboekhoff: What do people here think of Roda?
[01:10:04] nakuku: mboekhoff: Never used it. I know my friend extraced parts of a huge app to roda and saw dramatical performance gain.
[01:10:23] nakuku: But that's not surprising i guess :D
[01:15:37] jcalla: has joined #ruby
[01:19:09] hutch: has joined #ruby
[01:25:37] arescorpio: has joined #ruby
[01:38:59] tiff: has joined #ruby
[01:41:59] nchambers: has joined #ruby
[01:57:40] bambanx: has joined #ruby
[02:00:29] yokel: has joined #ruby
[02:14:09] tiff: has joined #ruby
[02:27:57] kapil____: has joined #ruby
[02:29:40] ansraliant: has joined #ruby
[02:35:16] themsay: has joined #ruby
[02:38:03] nchambers: has joined #ruby
[02:45:37] carbone5: has joined #ruby
[02:54:14] carbone5: has joined #ruby
[02:56:08] MasterAsia: has joined #ruby
[03:01:50] tiff: has joined #ruby
[03:07:41] Swyper: has joined #ruby
[03:16:04] carbone5: has joined #ruby
[03:26:50] carbone5: has joined #ruby
[03:52:01] spacesuitdiver: has joined #ruby
[03:58:21] Emmanuel_Chanel: has joined #ruby
[04:01:31] orbyt_: has joined #ruby
[04:02:27] cnsvc_: has joined #ruby
[04:08:56] JoshS: has joined #ruby
[04:09:07] braincrash: has joined #ruby
[04:16:03] roshanavand1: has joined #ruby
[04:25:01] pavelz: has joined #ruby
[04:50:09] hutch: has joined #ruby
[04:51:23] KrzaQ: let's say I have n = 4; what do I .send to n to assign to it? n.send(:=, 42) doesn't work
[04:51:39] KrzaQ: I'm trying to generate methods for yesterday's advent of code riddle
[04:52:02] KrzaQ: it seems all other operators work like that, but not this one
[04:54:19] leftylink: that sounds like `become` in Smalltalk, but I'm not convinced `become` exists in Ruby
[04:54:51] leftylink: note that a `send` is going to be sent to the object representing `4` not `n`, so I'd be surprised if a `send` has the power to change the binding
[04:55:03] KrzaQ: oh, so that's how it works
[04:55:19] KrzaQ: no wonder it doesn't have the power to do this
[04:55:27] KrzaQ: any idea how I can approach this, though?
[04:58:12] leftylink: hmm. ok, so I just found that `ruby -e 'a = 5; binding.local_variable_set(:a, 100); puts a'` prints 100, so that is one possible? (https://ruby-doc.org/core-2.4.0/Binding.html)
[04:58:23] leftylink: s/one possible/one possible way of making something happen/
[04:58:47] leftylink: may not be as clean as hoped for though
[04:58:56] leftylink: sec, today's advent is starting
[04:59:20] KrzaQ: hm, will look after day 17 is done, thx
[05:08:54] Freshnuts: has joined #ruby
[05:25:03] tiff: has joined #ruby
[05:53:22] dionysus69: has joined #ruby
[06:12:10] rippa: has joined #ruby
[06:14:36] elphe: has joined #ruby
[06:15:20] conta: has joined #ruby
[06:25:23] tiff: has joined #ruby
[06:28:12] roshanavand: has joined #ruby
[06:29:19] za1b1tsu: has joined #ruby
[06:33:24] stooj: has joined #ruby
[06:35:57] dbz: has joined #ruby
[06:39:27] Renich: has joined #ruby
[06:39:56] Renich: has joined #ruby
[06:40:17] endemic: has joined #ruby
[06:57:06] serard: has joined #ruby
[07:05:36] saTchymoto: has joined #ruby
[07:07:41] burgestrand: has joined #ruby
[07:11:42] KeyJoo: has joined #ruby
[07:12:02] aupadhye: has joined #ruby
[07:12:54] MasterAsia: has joined #ruby
[07:15:57] cnsvc_: has joined #ruby
[07:18:12] KrzaQ: welp, so I even made top 100 with Ruby
[07:20:12] serard: has joined #ruby
[07:20:15] neuraload: has joined #ruby
[07:23:47] KrzaQ: leftylink: actually, I think I don't need the binding to be replaced, basically I'm doing: https://gist.github.com/KrzaQ/a60b5e23ec84806ac768b1ca0fdb9a4d
[07:24:15] KrzaQ: I need something like a.ignore_arg(b) that returns b
[07:24:21] KrzaQ: I don't think there's something like that, though
[07:25:50] KrzaQ: I guess I can cheat a little and add noop to the Integer class
[07:32:59] leftylink: ah right. yeah far as I can tell it'd have to be smething like that
[07:33:40] KrzaQ: ok, I can live with that for an aoc problem
[07:34:31] KrzaQ: or I could make the function generator check if it's being passed a symbol or a proc/lambda/whatever callable
[07:34:57] serard_: has joined #ruby
[07:41:59] \void: has joined #ruby
[07:45:42] aufi: has joined #ruby
[07:49:13] KrzaQ: Eh, I'll leave it be
[07:49:29] KrzaQ: I won't be able to make much shorter, if any, and I don't want the readability to hurt too badly
[07:50:30] KrzaQ: That's how it looks now: https://github.com/KrzaQ/AdventOfCode2018/blob/master/solutions/day16/main.rb
[08:01:19] mboekhoff: has joined #ruby
[08:06:09] serard_: has joined #ruby
[08:08:24] JoshS: has joined #ruby
[08:20:42] za1b1tsu: has joined #ruby
[08:26:08] dbz: has joined #ruby
[08:27:28] serard: has joined #ruby
[08:33:14] tiff: has joined #ruby
[08:44:17] keden: has joined #ruby
[08:51:46] mikecmpbll: has joined #ruby
[08:53:25] nowhere_man: has joined #ruby
[08:56:04] ByronJohnson: has joined #ruby
[08:57:17] roshanavand: has joined #ruby
[09:00:03] tiff: has joined #ruby
[09:07:45] za1b1tsu: has joined #ruby
[09:14:45] Sylario: has joined #ruby
[09:15:57] stooj: has joined #ruby
[09:18:54] clemens3: has joined #ruby
[09:24:12] phaul: has joined #ruby
[09:30:57] phaul: KrzaQ: there are mutable types, and there are non mutable types. Integer is not mutable. It boils down to the interpreter optimizing the normal object behavour out and using actual numbers rather than object pointers.
[09:36:50] dbz: has joined #ruby
[09:47:02] venmx: has joined #ruby
[09:52:03] ellcs: has joined #ruby
[09:55:15] vondruch: has joined #ruby
[09:58:50] keden: has joined #ruby
[10:06:11] dbz: has joined #ruby
[10:06:23] serard: has joined #ruby
[10:06:43] za1b1tsu: has joined #ruby
[10:17:18] Milos: has joined #ruby
[10:26:51] blackmesa: has joined #ruby
[10:27:15] cnsvc_: has joined #ruby
[10:27:40] clemens3_: has joined #ruby
[10:40:26] ellcs: has joined #ruby
[10:55:44] Bish: has joined #ruby
[10:57:38] roshanavand: has joined #ruby
[11:01:12] dinfuehr: has joined #ruby
[11:06:40] conta: has joined #ruby
[11:08:29] Azure: has joined #ruby
[11:11:06] dirceu: has joined #ruby
[11:20:17] aupadhye: has joined #ruby
[11:26:16] nakuku: has joined #ruby
[11:28:11] nakuku: Can unit test hit the database? It only contains repository.update call with some parameters. Should i call it a "test" and go home. Or i need to mock the thing to call it "unit test" and write integration test to confirm it
[11:43:25] kidPalooma: has joined #ruby
[11:44:12] kidPalooma: Hello, how do I generate a random sequence of lowercase letters in ruby? It needs to be only letters and lowercase
[11:48:49] ellcs: has joined #ruby
[11:49:42] phaul: &>> ([*?a .. ?z]+[*?0..?9]).sample(10).join
[11:49:47] rubydoc: # => "gn548yqok0" (https://carc.in/#/r/5t0r)
[11:50:53] phaul: oop, I don't know why I read numbers and letters
[11:51:25] phaul: &>> [*?a .. ?z].sample(10).join
[11:51:27] rubydoc: # => "wskzoeyrpf" (https://carc.in/#/r/5t0v)
[11:53:35] Guest61854: has joined #ruby
[11:58:24] lucasb: has joined #ruby
[12:05:20] horst: has joined #ruby
[12:07:12] kidPalooma: thanks phaul
[12:09:03] phaul: some would argue that we should use 'a' instead of ?a (they are the same), but I have nothing against the ? notation
[12:10:49] kidPalooma: I don't mind it either
[12:14:00] aufi: has joined #ruby
[12:25:45] lxsameer: has joined #ruby
[12:28:40] za1b1tsu: has joined #ruby
[12:30:47] deathwishdave: has joined #ruby
[12:35:39] keden: has joined #ruby
[12:41:56] jhass: phaul: well that solution might not be what they want as it doesn't allow for reoccurence of any letter and thus limits the space of possible sequences quite a bit
[12:42:07] jhass: also do you know why ?a is a thing? :P
[12:43:26] phaul: &>> [?a, ?b].sample(10).join
[12:43:26] rubydoc: # => "ba" (https://carc.in/#/r/5t1y)
[12:43:41] phaul: hm. I admit that's not what I expected.
[12:43:59] phaul: my solution is wrong then
[12:44:08] phaul: jhass: why is ?a a thing?
[12:45:16] jhass: because before ruby 1.9 String#[] used to return the codepoint, and so did ?a then allowing for a quick way to check if a particular character is at a particular position in a string
[12:46:00] jhass: with 1.9 String#[] started to return a single character string and thus ?a was updated to represent that too to not break existing code in a subtle way
[12:46:21] jhass: but at the same time that change made the syntax quite obsoelete, which is why many frown on it
[12:46:45] AJA4350: has joined #ruby
[12:47:41] phaul: jhass: do you have a quick one liner for their question?
[12:48:56] jhass: I guess I'd gobble together Array.new and sample, so CHARSET = [*'a'..'z']; Array.new(10) { CHARSET.sample }.join
[12:50:26] jhass: or just "".yield_self {|s| 10.times { s << CHARSET.sample } }
[12:51:14] jhass: either is really pretty tbh
[12:51:19] jhass: eh, isn't
[12:53:13] jhass: usually those requirements come from generating some kind of opaque ID which you often can do quite nicely with an idea modulo some large prime and base36'ing the result
[12:53:32] jhass: with an ID I mean, dunno what's wrong with me today
[12:54:42] jhass: so it looks random to the user but knowing the prime you can go back in constant time
[12:57:22] cnsvc_: has joined #ruby
[12:57:40] roshanavand: has joined #ruby
[12:59:08] phaul: interesting that they decided to implement #sample this way, as I am speculating it's actually more difficult to ensure choosing unique indices, and moreover we could already get this by doing #shuffle.take(10)..
[13:01:04] InfinityFye: has joined #ruby
[13:02:29] jhass: I actually love it, I needed that behaviour more often than the other
[13:02:47] jhass: and it's much harder to reimplement efficiently
[13:03:18] jhass: .shuffle.take just breaks down once your input collection is big
[13:04:03] phaul: i see. So it's there for performance reasons
[13:04:54] jhass: well I can only speculate but I would on more commonly useful and harder to do efficient compared to reimplementing the other behaviour efficiently
[13:06:07] go|dfish: has joined #ruby
[13:07:30] jottr: has joined #ruby
[13:10:03] DTZUZO: has joined #ruby
[13:15:37] al2o3-cr-tmp: has joined #ruby
[13:19:31] paranoicsan: has joined #ruby
[13:23:35] marz_d`ghostman: has joined #ruby
[13:35:32] beef_erikson: has joined #ruby
[13:45:12] cow[moo]: has joined #ruby
[13:57:25] marz_d`ghostman: I'm using the sqlite3 gem, Is it possible to like flush a statement so I could like create a table and then insert data in one SQLite3::Database.open?
[13:58:07] marz_d`ghostman: Like inside a SQLite3::Database.open(file) . .. I'm creating a table then pushing data. I'd like to push the creation of the table first. Is that possible though?
[13:58:43] darix: marz_d`ghostman: what makes you think it hasnt happened instantly?
[14:01:41] marz_d`ghostman: darix: cause I when I do a get query, no records are returned, tried to manually query it via irb and sqlite3 on cli
[14:02:20] darix: you need to provide a script for reproducer
[14:08:22] marz_d`ghostman: darix: So, I've created a initialize.rb to run first before my main script for database population: e21d499b15ddb9bf05e6030facdec7b8
[14:11:47] darix: marz_d`ghostman: should the hash like string at the end be an url maybe?
[14:12:35] marz_d`ghostman: darix: what do you mean?
[14:14:24] darix: see your last line
[14:15:39] cnsvc_: has joined #ruby
[14:17:28] marz_d`ghostman: darix: the INSERT line?
[14:18:07] marz_d`ghostman: darix: Oh I'm sorry: https://gist.github.com/marzdgzmn/e21d499b15ddb9bf05e6030facdec7b8
[14:18:38] cow[moo]: has joined #ruby
[14:19:02] darix: and line 21 triggers an error?
[14:19:14] marz_d`ghostman: darix: It doesn't trigger any error though
[14:20:12] marz_d`ghostman: darix: it run fine, but when my tests run it invokes an error because the inserted data aren't there. Tried to manually run a select query in `irb` and sqlite3 cli, and the records aren't there
[14:21:48] darix: your script works here creates 2 tables and then inserts into 1
[14:21:55] graphene: has joined #ruby
[14:22:02] darix: and the data is there
[14:24:59] darix: i commented on your gist
[14:25:35] darix: a very glarring lack of openSUSE/SUSE There :P
[14:27:58] jcalla: has joined #ruby
[14:28:16] darix: opensuse package for 2.6.0~rc2 submitted
[14:30:41] marz_d`ghostman: doesn't work on mine though, we have the same exact script. the tables are there but not the data
[14:30:46] alan_w: has joined #ruby
[14:35:12] kapil____: has joined #ruby
[14:37:13] roshanavand: has joined #ruby
[14:38:48] polishdub: has joined #ruby
[14:43:53] graphene: has joined #ruby
[14:43:56] deathwishdave: has joined #ruby
[14:44:16] tuor: has joined #ruby
[14:46:40] Rapture: has joined #ruby
[14:49:06] gnufied: has joined #ruby
[14:58:10] rprimus: has joined #ruby
[14:58:14] cpruitt: has joined #ruby
[15:01:34] marz_d`ghostman: darix: I'm not sure if it because of the versions, but db.commit semms to have fixed it
[15:01:41] marz_d`ghostman: db.commit before the inserts
[15:03:07] venmx: has joined #ruby
[15:03:45] darix: marz_d`ghostman: for me it was ruby 2.5.3 + ruby2.5-rubygem-sqlite3-1.3.13-1.11.x86_64
[15:06:05] chouhoulis: has joined #ruby
[15:10:13] marz_d`ghostman: I'm using ruby 2.4 though, and I was wrong, it still isn't working lol
[15:10:54] spiette: has joined #ruby
[15:20:02] Inline: has joined #ruby
[15:22:18] Emmanuel_Chanel: has joined #ruby
[15:24:15] eb0t: has joined #ruby
[15:28:07] maryo: has joined #ruby
[15:33:05] EminenceHC: has joined #ruby
[15:35:05] marz_d`ghostman: darix: Tried running in in its own script, and it seems to work. But when I require it inside the spec_helper, it doesn't. Is there something in spec_helper or rspec that is conflicting with it?
[15:35:51] aufi: has joined #ruby
[15:37:18] elphe: has joined #ruby
[15:37:25] cow[moo]: has joined #ruby
[15:37:40] darix: maybe they block commits
[15:42:38] cpruitt: I'm sure this is some kind of pre-caffeine fog, but I'm having an issue with `require`. If I `puts File.expand_path('../../../02_karate_chop/karate_chop.rb', __FILE__)` I'll get /Users/username/Dev/code_kata/ruby/02_karate_chop/karate_chop.rb
[15:43:34] cpruitt: If I use require instead of puts I get a LoadError but the file path is different: /Users/username/Dev/code_kata/02_karate_chop/karate_chop.rb (note the absence of /ruby/)
[15:43:54] cpruitt: Am I missing something here?
[15:44:10] jhass: exact same command to run in both cases?
[15:44:27] cpruitt: I'm literally just editing the file & changing puts to require
[15:44:52] jhass: try require_relative instead
[15:44:55] cpruitt: Even tried assigning the path to a variable & using that for both. Different outputs
[15:45:30] cpruitt: jhass: Yeah, I can do that, but I'd kinda like to know why it's changing. Maybe rspec is doing something? It's at the top of a spec file
[15:46:02] jhass: given it's "ruby" that vanishes I wouldn't even rule out require doing something there
[15:46:19] jhass: anyway, what you're doing there is require_relative's job, let it do its work
[15:47:40] cpruitt: Oh shoot.... I found the problem. self.moron == true
[15:49:34] jhass: I'd still urge you to use require_relative ;)
[15:50:18] cpruitt: I wasn't looking closely enough at the stack trace. Got so caught up on the error being the same that I didn't notice that one error was coming from one file and one from a different file with a nearly identical name.
[15:50:53] cpruitt: & yes, I've edited to use require_relative. Thanks.
[15:50:53] rubydoc: did not understand that, parser error @ char position 0
[15:51:11] jobewan: has joined #ruby
[15:51:34] phaul: I should make some changes.. I know it's annoying.
[15:51:42] zipace: has joined #ruby
[15:52:41] akem: has joined #ruby
[15:53:22] h0h0h0: has joined #ruby
[15:54:10] nowhere_man: has joined #ruby
[16:00:20] akem: has joined #ruby
[16:07:57] cnsvc_: has joined #ruby
[16:12:14] graphene: has joined #ruby
[16:23:14] mostlybadfly: has joined #ruby
[16:27:03] marz_d`ghostman: With sqlite3 gem, why does results_as_hash return {"pre_cmd_result"=>"Failed", 0=>"Failed"} two hashes for one result?
[16:27:54] davidw: has joined #ruby
[16:31:06] conta: has joined #ruby
[16:33:16] conta1: has joined #ruby
[16:40:26] cd: has joined #ruby
[16:41:25] hutch: has joined #ruby
[16:50:08] blackmesa: has joined #ruby
[16:55:30] krawchyk: has joined #ruby
[16:56:01] yorickpeterse: has joined #ruby
[16:57:31] code_zombie: has joined #ruby
[16:58:13] cd: has joined #ruby
[16:58:44] orbyt_: has joined #ruby
[16:59:53] graphene: has joined #ruby
[16:59:57] akaiiro: has joined #ruby
[17:04:11] \void: has joined #ruby
[17:05:37] hiroaki: has joined #ruby
[17:05:55] graphene: has joined #ruby
[17:07:55] Fusl: has joined #ruby
[17:11:06] darkhanb: has joined #ruby
[17:15:16] uplime: has joined #ruby
[17:25:11] graphene: has joined #ruby
[17:27:00] Eiam: has joined #ruby
[17:28:17] Eiam: I was recently playing around with using sentinel style values to indicate intent rather than nil/empty and one of the things I found cumbersome was when you use a value like :no_value instead of leaving it nil, that operations like .any? treat :no_value as true, but nil as false
[17:28:23] Eiam: which makes things get messy real fast
[17:29:12] Eiam: because then you are having to check for ==true (if your options are true, false or :no_value)
[17:29:20] zipace: has joined #ruby
[17:29:52] Eiam: is the safest path forward there to wrap those into a small struct to not expose the bool directly either?
[17:30:36] dbz: has joined #ruby
[17:32:59] dbz_: has joined #ruby
[17:37:06] quipa: has joined #ruby
[17:37:17] dbz: has joined #ruby
[17:38:35] roshanavand: has joined #ruby
[17:40:46] nowhere_man: has joined #ruby
[17:50:43] Dreamer3: has joined #ruby
[18:06:56] chouhoulis: has joined #ruby
[18:10:08] johnny56: has joined #ruby
[18:25:16] cagomez: has joined #ruby
[18:25:57] cagomez: has joined #ruby
[18:26:37] cagomez: has joined #ruby
[18:27:11] cagomez: has joined #ruby
[18:27:48] cagomez: has joined #ruby
[18:28:26] cagomez: has joined #ruby
[18:39:11] serard: has joined #ruby
[18:40:22] cnsvc_: has joined #ruby
[18:41:57] reber: has joined #ruby
[18:57:57] cthulchu: has joined #ruby
[19:00:24] havenwood: Eiam Sentinel Enumerable refinements? ¯\_(ツ)_/¯ https://gist.github.com/havenwood/1017d387dc468d069a6060c79e3becd6
[19:01:32] impermanence: has joined #ruby
[19:01:48] impermanence: has joined #ruby
[19:01:48] Eiam: you basically just forced :no_value to also become falsey which is basically more lines of code to "if value == true" else "now its falsey"
[19:05:38] Xiti: has joined #ruby
[19:07:31] dbugger_: has joined #ruby
[19:11:03] orbyt_: has joined #ruby
[19:13:38] pavelz: has joined #ruby
[19:13:53] havenwood: Eiam: This reminds me of a recent Rich Hickey talk, Maybe Not: https://youtu.be/YR5WdGrpoug
[19:15:15] havenwood: Eiam: I'm not seriously suggesting reimplementing Enumerable. I think that pattern is tough to pull off in Ruby, since what is falsey is hardcoded.
[19:15:36] serard_: has joined #ruby
[19:16:13] Eiam: thats what im finding, but I really wanted to not rely on the absence of a value to mean something specific
[19:16:17] Eiam: the code is just.. awful
[19:16:29] Eiam: that may be a reflection on its author however
[19:17:15] Eiam: oh clojure con god
[19:17:29] Eiam: my old manager became a clojure nut, never shuts up about it now
[19:18:18] r29v: has joined #ruby
[19:18:30] serard__: has joined #ruby
[19:18:34] impermanence: has joined #ruby
[19:19:20] conta: has joined #ruby
[19:19:42] Eiam: watching
[19:23:14] r29v: has joined #ruby
[19:40:55] krawchyk_: has joined #ruby
[20:00:17] hiroaki: has joined #ruby
[20:08:30] graphene: has joined #ruby
[20:09:38] krawchyk: has joined #ruby
[20:18:40] hiroaki: has joined #ruby
[20:19:02] hutch: has joined #ruby
[20:22:59] graphene: has joined #ruby
[20:26:54] gix: has joined #ruby
[20:30:50] serard: has joined #ruby
[20:37:10] Eiam: havenwood: if I understand what hes said correctly its basically "Solving this is a language problem and none of them have great solutions here are some things I'm poking at or proposing"
[20:37:46] sameerynho: has joined #ruby
[20:43:29] MasterAsia: has joined #ruby
[20:46:12] havenwood: Eiam: My main takeaway was when you change your level of certainty about whether there'll be a value, you shouldn't have to change all the code dealing with that value.
[20:46:47] Eiam: yes, I agree with that sentiment
[20:46:54] Eiam: how do I get it in Ruby? =)
[20:47:00] havenwood: Kotlin does that nicely with its nullable types: https://kotlinlang.org/docs/reference/null-safety.html
[20:47:35] graphene: has joined #ruby
[20:54:30] Eiam: nullable types doesn't address the fundamental disconnect between does null mean no value or does it mean never assigned?
[20:59:41] dbz: has joined #ruby
[21:01:13] havenwood: Eiam: https://twitter.com/richhickey/status/1038065826824441856
[21:02:22] hutch: has joined #ruby
[21:02:32] havenwood: Eiam: Rich Hickey agrees!
[21:06:48] SeepingN: has joined #ruby
[21:07:00] graphene: has joined #ruby
[21:10:21] graphene: has joined #ruby
[21:12:07] orbyt_: has joined #ruby
[21:12:30] havenwood: Eiam: An aside, but a pattern I've seen for undefined is: undefined = Object.new
[21:13:01] havenwood: Eiam: (So you don't get a possible symbol collision with :no_value being a value type of thing.)
[21:13:32] Eiam: Im importing data, I map that data to either I know this value is true, I know this value is false, or I dont know if this value is true or false
[21:18:00] graphene: has joined #ruby
[21:19:27] havenwood: Eiam: So `nil` is both the placeholder 'no value yet' and also the uncertain 'value maybe this or that'?
[21:23:30] venmx: has joined #ruby
[21:30:09] hutch: has joined #ruby
[21:33:14] Eiam: well, I don't allow nils, so an empty state is set to :no_value
[21:33:26] Eiam: its just handling that no_value is fairly annoying in Ruby itself
[21:33:58] Eiam: a false means "I know the answer, and its false" a true means "I know the answer, and its true" and :no_value means I don't know if this is true or false.
[21:38:15] themsay: has joined #ruby
[21:39:18] cnsvc_: has joined #ruby
[21:40:08] themsay: has joined #ruby
[21:42:45] WA9ACE: has joined #ruby
[21:52:38] hutch: has joined #ruby
[22:05:01] zapata: has joined #ruby
[22:08:26] hutch: has joined #ruby
[22:10:51] nowhere_man: has joined #ruby
[22:12:03] tiff: has joined #ruby
[22:12:05] venmx: has joined #ruby
[22:12:43] leftylink: (this comment is not productively helpful to the discussion): Ah, so we can think of it as a tri-state variable... which would be https://thedailywtf.com/articles/What_Is_Truth_0x3f_
[22:17:09] brandonkal: has joined #ruby
[22:18:33] elphe: has joined #ruby
[22:37:44] tiff: has joined #ruby
[22:41:28] hutch: has joined #ruby
[22:45:16] dachi_: has joined #ruby
[22:46:10] ivanskie: has joined #ruby
[22:46:35] dachi_: I have not new to Ruby, but this time I have to make a wrapper around some enterprise software API. I was asked to design it with some clever and original pattern.
[22:46:45] dachi_: Do you have any recommendations?
[22:46:53] dachi_: I *am not new..
[22:47:06] dachi_: Sorry misspelled.
[22:48:02] jthomas: has joined #ruby
[22:48:58] blackmesa: has joined #ruby
[22:50:49] SeepingN: checkered pattern is best
[22:58:48] hutch: has joined #ruby
[23:01:42] za1b1tsu: has joined #ruby
[23:09:24] za1b1tsu: has joined #ruby
[23:11:54] cthulchu: has joined #ruby
[23:12:02] Eiam: clever and original pattern for an enterprise API... I dunno something just doesn't feel right with that statement but I cannot quite put my finger on it
[23:12:49] Eiam: dachi_: implement it all via method_missing. Its not original at all, at least not in Ruby. I'd argue its cleverness
[23:17:09] Eiam: havenwood: feels like we talked ourselves into a circle of everyone agrees its not great and here we are
[23:17:41] go|dfish: has joined #ruby
[23:18:10] hutch: has joined #ruby
[23:18:45] havenwood: dachi_: For an api framework, I'd recommend Roda. It's great for intermediary dsls.
[23:19:32] dachi_: Eiam: thanks. havenwood I'll check that out, great
[23:20:31] dachi_: SeepingN: thank you too
[23:20:57] Eiam: i feel like only one of those people were actually helpful
[23:21:24] havenwood: dachi_: http://roda.jeremyevans.net/
[23:21:40] Eiam: and roda is like sinatra! how is that promoting any clever or original pattern!
[23:21:41] dachi_: No, why I'll think about all of these
[23:22:04] havenwood: dachi_: Roda is just a routing tree on top of Rack, but you can then cherry pick from these plugins to compose the framework you nened: https://github.com/jeremyevans/roda/tree/master/lib/roda/plugins
[23:24:59] dachi_: Sounds interesting, I'm checking that out
[23:26:09] dachi_: Yes, that looks nice. I've heard about Roda, before but didn't look into that
[23:26:29] dachi_: In my case I don't need routing at all. I might asked a question not the right way
[23:26:47] dachi_: I'm going to write a lib that will talk with an API
[23:26:49] havenwood: What do you need? What does this API do?
[23:26:57] tiff: has joined #ruby
[23:27:35] dachi_: and this has to be done kind of ... 'best way' .. as I was told. So, I started to look for best design ideas
[23:28:27] dachi_: So, a lib would just expose methods for talking with really huge web server with net/http
[23:28:40] dachi_: And it has to be designed in some fashionable way ...
[23:29:04] havenwood: dachi_: So you're writing an HTTP client SDK to consume an API?
[23:29:13] dachi_: Like, it might have a beautiful dsl, etc..
[23:29:35] dachi_: right, that's correct.
[23:31:15] dachi_: I had done such thing couple of times before, but all in standard way
[23:33:18] dachi_: I don't know, I suppose I'll try looking at lots of repos on github, compare their style, and come up with something that could stand out
[23:33:50] dachi_: Will take a lot of time though. that's why I asked, maybe I'd get a quick idea,
[23:34:04] dachi_: But probably this question sounds unclever : | So leave it
[23:34:09] dachi_: And thanks people.
[23:38:50] Fernando-Basso: has joined #ruby
[23:44:04] havenwood: dachi_: Here's a sheet I maintain comparing Ruby HTTP clients: https://docs.google.com/spreadsheets/d/1vPlk6nMIFa3sI5ISl7zZ5r6lDNpVQX6Jxi3ksXCyVbs/edit?usp=sharing
[23:45:01] havenwood: dachi_: Is your client going to be used as a gem by multiple apps?
[23:45:07] dachi_: havenwood: nice thanks
[23:45:19] FernandoBasso: has joined #ruby
[23:45:59] havenwood: dachi_: I often use HTTP.rb or Typhoeus, but Faraday can also be nice if your SDK might be used by apps themselves using different HTTP clients.
[23:46:27] havenwood: Change a setting, swap the underlying client to match your stack.
[23:46:29] dachi_: I used Faraday for last projects, yea I like it a lot
[23:47:06] havenwood: dachi_: Ca you do a GraphQL endpoint on the server end? :P
[23:47:26] dachi_: no, I don't have permission to amend server...
[23:48:09] havenwood: dachi_: And your SDK is going to be used as a library in apps consuming the server API?
[23:48:44] dachi_: hm, It's so interesting to read 'pure ruby impelementations' from your spreadsheet. Not for this project, generally, never looked at these carefully
[23:49:20] dachi_: yes.. It's like .. It's for developers who would like to talk with that huge server easily
[23:49:24] havenwood: yeah, HTTPClient and Excon are both nice
[23:50:29] ellcs: has joined #ruby
[23:50:38] havenwood: dachi_: I think an idiomatic interface that's as simple as it can be is the nicest thing.
[23:51:25] havenwood: dachi_: Really nice to add value with tuned throttling to match the server or automatic retries and exponential backoff.
[23:51:40] dachi_: havenwood: yes probably. I'll just have to write code very carefully and that's it in theory, i guess
[23:52:13] druonysus: has joined #ruby
[23:53:27] havenwood: dachi_: If the API isn't nice, adding proper errors, resolving inconsistent naming and such at the SDK level can be a big win.
[23:54:21] havenwood: dachi_: PS - I'd call what you're writing an SDK, just because libraries that wrap APIs get called SDKs these days for whatever reason.
[23:55:16] dachi_: agree about errors and naming
[23:55:46] dachi_: yea, I've some old repo tagged with ruby-sdk, just checked :|
[23:56:53] dachi_: just took a glance, that's not very well written :p will need to work harder
[23:57:29] dachi_: https://github.com/dachinat/nextcloud