« Back to channel list

#ruby - 20 February 2018

« Back 1 day Forward 1 day »
[00:00:03] banisterfiend: otherwise you gotta look at the method body to konw there's a block bring passed which can be missed easily enough
[00:00:20] dminuoso: And at that time you might as well call the block directly to make code flow easier to follow. :)
[00:00:35] dminuoso: The performance benfit only seems to apply to stdlib writers I think.
[00:00:48] nowhere_man: has joined #ruby
[00:01:01] dminuoso: banisterfiend: o/ by the way.
[00:01:12] dminuoso: banisterfiend: How do I debug pry doing not the right thing spontaneously?
[00:01:23] banisterfiend: dminuoso what do you mean? what happened?
[00:02:23] iceskins[m]: `foo is aliased as bar` `foo has an alias of bar` `bar is aliased as foo`
[00:02:46] cagomez: sounds reasonable
[00:02:55] iceskins[m]: Sorry `bar is aliased to foo`
[00:03:19] dminuoso: banisterfiend: Well, I rather frequently manage to break the pager so badly..
[00:03:35] banisterfiend: lol how does it break? any screenshot?
[00:04:15] dminuoso: None at hand, but usually printing imperial shittons of things in Rails seems to frequently screw up the prompt permanently
[00:04:24] jenrzzz: has joined #ruby
[00:04:24] jenrzzz: has joined #ruby
[00:04:41] craysiii: switch to metric :P
[00:05:26] banisterfiend: dminuoso hmm, weird, maybe try 'tty sane'
[00:05:42] banisterfiend: err, stty sane
[00:06:12] dminuoso: banisterfiend: Mm fair enough Ill keep it in mind
[00:06:35] banisterfiend: dminuoso i guess some control chars are affecting the tty
[00:06:45] banisterfiend: or the pager is somehow breaking it
[00:06:48] alfiemax: has joined #ruby
[00:07:00] banisterfiend: never excperiencd it before :)
[00:07:34] dminuoso: Well lets just say I have some bad habits that result in me always forgetting the trailing `;`
[00:08:21] banisterfiend: are you the guy i spoke to the other night about that new pry-doc feature?
[00:08:24] banisterfiend: bad memory sorry
[00:08:30] dminuoso: unless mine is as bad as yours
[00:08:47] banisterfiend: doubt it, i was a stoner in college
[00:08:53] dminuoso: Whatever the feature is, I upvote it.
[00:09:02] dminuoso: Sounds good.
[00:09:20] dminuoso: Well that new pry-doc feature.
[00:09:27] banisterfiend: the one you know nothing about? :P
[00:11:06] jenrzzz_: has joined #ruby
[00:11:15] cagomez: has joined #ruby
[00:11:53] bigblind: has joined #ruby
[00:13:15] n0m4d1c: has joined #ruby
[00:13:43] schneide_: has joined #ruby
[00:15:24] arescorpio: has joined #ruby
[00:16:34] karapetyan: has joined #ruby
[00:22:49] gary_: has joined #ruby
[00:23:35] alfiemax: has joined #ruby
[00:31:19] jcarl43: has joined #ruby
[00:34:40] dskon: has joined #ruby
[00:36:08] beauby: has joined #ruby
[00:36:37] alfiemax: has joined #ruby
[00:36:44] hndk: has joined #ruby
[00:37:39] ghormoon: has joined #ruby
[00:39:14] Gary_B: has joined #ruby
[00:45:48] bmurt: has joined #ruby
[00:51:08] kapil___: has joined #ruby
[00:51:11] RougeR: has joined #ruby
[00:53:04] gary: has joined #ruby
[00:56:58] workmad3: has joined #ruby
[00:57:54] hoylemd: has left #ruby: ()
[01:11:03] alfiemax: has joined #ruby
[01:18:24] chocoelho: has joined #ruby
[01:30:28] gary_: has joined #ruby
[01:31:37] ghormoon: has joined #ruby
[01:40:15] RougeR: has joined #ruby
[01:40:16] RougeR: has joined #ruby
[01:49:11] gary: has joined #ruby
[01:49:18] alfiemax: has joined #ruby
[01:52:03] m27frogy: has joined #ruby
[01:52:17] snath: has joined #ruby
[01:54:13] milardovich: has joined #ruby
[01:54:15] n0m4d1c: has joined #ruby
[01:55:03] n0m4d1c_: has joined #ruby
[01:56:24] gary_: has joined #ruby
[01:57:10] RougeR: has joined #ruby
[02:01:25] Gary_B: has joined #ruby
[02:06:17] alfiemax: has joined #ruby
[02:06:33] drewmcmillan: has joined #ruby
[02:08:01] char_var[buffer]: has joined #ruby
[02:14:53] jenrzzz: has joined #ruby
[02:17:11] tvw: has joined #ruby
[02:17:21] Gary_B: has joined #ruby
[02:22:58] alfiemax: has joined #ruby
[02:26:28] Gary_B: has joined #ruby
[02:36:20] beauby: has joined #ruby
[02:38:33] jenrzzz: has joined #ruby
[02:38:33] jenrzzz: has joined #ruby
[02:39:05] Gary_B: has joined #ruby
[02:47:47] gary: has joined #ruby
[02:49:58] Rodya_: has joined #ruby
[02:50:21] auv: has joined #ruby
[02:57:17] workmad3: has joined #ruby
[02:58:31] apricant_: has joined #ruby
[02:59:08] bigblind: has joined #ruby
[02:59:24] drewmcmillan: has joined #ruby
[03:00:08] cadillac_: has joined #ruby
[03:00:13] gary_: has joined #ruby
[03:01:58] hlmjr: has joined #ruby
[03:14:30] kies: has joined #ruby
[03:15:32] wilbert: has joined #ruby
[03:16:06] Azure: has joined #ruby
[03:17:13] bigblind: has joined #ruby
[03:18:08] Asher: has joined #ruby
[03:18:57] alfiemax: has joined #ruby
[03:21:15] milardovich: has joined #ruby
[03:22:10] morenoh149: has joined #ruby
[03:22:18] ecuanaso: has joined #ruby
[03:23:50] ramfjord: has joined #ruby
[03:26:06] darkhanb: has joined #ruby
[03:26:43] Asher: has joined #ruby
[03:31:45] alfiemax: has joined #ruby
[03:43:31] elcontrastador: has joined #ruby
[03:43:54] DTZUZO: has joined #ruby
[03:45:22] Rodya_: has joined #ruby
[03:48:18] alfiemax: has joined #ruby
[03:50:33] govg: has joined #ruby
[03:52:28] Rodya_: has joined #ruby
[03:53:24] skweek: has joined #ruby
[03:58:29] c0ncealed: has joined #ruby
[04:01:34] alfiemax: has joined #ruby
[04:05:39] Rodya_: has joined #ruby
[04:11:34] bigblind: has joined #ruby
[04:15:05] hndk: has joined #ruby
[04:16:11] morenoh149: has joined #ruby
[04:18:14] alfiemax: has joined #ruby
[04:25:15] trautwein: has joined #ruby
[04:31:12] alfiemax: has joined #ruby
[04:31:40] morenoh149: has joined #ruby
[04:33:31] Exuma: has joined #ruby
[04:34:19] kapil___: has joined #ruby
[04:36:38] beauby: has joined #ruby
[04:47:04] rexan: has joined #ruby
[04:49:49] rexan: has joined #ruby
[04:51:19] orbyt_: has joined #ruby
[04:51:24] nadir: has joined #ruby
[04:53:32] gary: has joined #ruby
[04:56:26] alfiemax: has joined #ruby
[04:57:44] workmad3: has joined #ruby
[04:58:38] gix-: has joined #ruby
[05:00:48] shakes: has joined #ruby
[05:07:53] MyMind: has joined #ruby
[05:10:02] gary_: has joined #ruby
[05:11:28] alfiemax: has joined #ruby
[05:16:56] morenoh149: has joined #ruby
[05:19:14] kies: has joined #ruby
[05:21:32] PaulCapestany: has joined #ruby
[05:32:49] GinoMan: has joined #ruby
[05:36:06] beauby: has joined #ruby
[05:37:14] mtkd: has joined #ruby
[05:40:54] whipperSnapper: has joined #ruby
[05:54:02] kies: has joined #ruby
[05:59:47] Matthew1: has joined #ruby
[06:07:06] bigblind: has joined #ruby
[06:07:56] hndk: has joined #ruby
[06:08:43] schneide_: has joined #ruby
[06:09:07] anisha: has joined #ruby
[06:11:30] alfiemax: has joined #ruby
[06:12:27] morenoh149: has joined #ruby
[06:16:24] gary: has joined #ruby
[06:27:18] rabajaj: has joined #ruby
[06:28:06] ptx0: has joined #ruby
[06:32:44] raynold: has joined #ruby
[06:33:18] LocaMocha: has joined #ruby
[06:35:21] cadillac_: has joined #ruby
[06:42:29] Pisuke: has joined #ruby
[06:45:58] jenrzzz: has joined #ruby
[06:46:02] nfsnobody: has joined #ruby
[06:47:31] Voxxit: has joined #ruby
[06:57:13] howdoi: has joined #ruby
[06:58:13] workmad3: has joined #ruby
[07:01:33] apeiros: has joined #ruby
[07:03:49] mrBen2k2k2k_____: has joined #ruby
[07:06:25] morenoh149: has joined #ruby
[07:13:49] mtkd: has joined #ruby
[07:15:00] morenoh149: has joined #ruby
[07:20:06] conta: has joined #ruby
[07:27:49] roshanavand: has joined #ruby
[07:32:12] mtkd: has joined #ruby
[07:34:05] Rodya_: has left #ruby: ("Leaving...")
[07:42:13] guardianx: has joined #ruby
[07:44:15] Dimik: has joined #ruby
[07:45:19] andikr: has joined #ruby
[07:46:19] minimalism: has joined #ruby
[07:49:05] eckhardt: has joined #ruby
[07:51:58] apeiros: has joined #ruby
[07:55:56] Cope: has joined #ruby
[07:56:46] xfbs: has joined #ruby
[07:57:26] Cope: Hi... I've not done any Ruby for 2.5+ yrs; new mac; new job: are chruby, ruby-install, rbenv etc still things? What's the current recommended way to install and manage Rubies on a mac?
[07:58:26] tAn: has joined #ruby
[07:58:30] Exuma: has joined #ruby
[07:59:41] amatas: has joined #ruby
[07:59:43] dminuoso: Cope: ruby-install/chruby
[07:59:47] n008f4g_: has joined #ruby
[07:59:54] dminuoso: Cope: You can skip the latter if you dont need multiple versions.
[08:00:10] dminuoso: But you can also build it from source yourself, there's really not much to it.
[08:00:31] dminuoso: Cope: Though since high sierra you get a relatively new and recent version of Ruby that is fine.
[08:00:41] dminuoso: So you dont have to if you dont want to.
[08:01:28] dminuoso: It's some 2.3 version I think
[08:01:31] kies: has joined #ruby
[08:01:45] dminuoso: Though keep in mind that 2.4 introduced API breaking changes for basically every native extension out there.
[08:01:46] TomyWork: has joined #ruby
[08:01:59] dminuoso: So that's a good reaason to not stick with the macOS supplied Ruby.
[08:02:57] bigblind: has joined #ruby
[08:02:57] Cope: yep the stuff I'm working on is 2.4
[08:03:16] Cope: ok great, thanks dminuoso
[08:04:58] kapil___: has joined #ruby
[08:10:33] morenoh149: has joined #ruby
[08:10:58] yohji: has joined #ruby
[08:11:49] jnyw: has joined #ruby
[08:15:22] schneide_: has joined #ruby
[08:25:11] claudiuinberlin: has joined #ruby
[08:29:12] gary: has joined #ruby
[08:30:07] phenom: has joined #ruby
[08:31:45] __semper__: has joined #ruby
[08:33:35] aufi: has joined #ruby
[08:34:37] milardovich: has joined #ruby
[08:36:17] aupadhye: has joined #ruby
[08:36:24] aufi_: has joined #ruby
[08:39:26] gary_: has joined #ruby
[08:40:57] clemens3: has joined #ruby
[08:41:00] tvw: has joined #ruby
[08:49:20] Gary_B: has joined #ruby
[08:53:14] Gnut: has joined #ruby
[08:53:53] mtkd: has joined #ruby
[08:56:38] whipperSnapper: has left #ruby: ()
[08:57:15] bigblind: has joined #ruby
[08:58:36] workmad3: has joined #ruby
[08:58:49] gary: has joined #ruby
[09:00:26] ecuanaso: has joined #ruby
[09:00:55] reber: has joined #ruby
[09:02:16] jnollette: has joined #ruby
[09:04:35] morenoh149: has joined #ruby
[09:06:59] meinside: has joined #ruby
[09:10:17] maufart__: has joined #ruby
[09:11:24] gary_: has joined #ruby
[09:12:42] marr: has joined #ruby
[09:14:16] beauby: has joined #ruby
[09:20:43] alfiemax: has joined #ruby
[09:21:14] dvdingus: has joined #ruby
[09:21:21] alex``: has joined #ruby
[09:22:48] milardovich: has joined #ruby
[09:23:03] rgr: has joined #ruby
[09:25:34] dionysus69: has joined #ruby
[09:28:57] Gary_B: has joined #ruby
[09:32:31] Mike11: has joined #ruby
[09:32:46] guille-moe: has joined #ruby
[09:36:50] aufi_: has joined #ruby
[09:42:43] Serpent7776: has joined #ruby
[09:44:23] anisha_: has joined #ruby
[09:45:02] guardian: I have text file in which I have "groups of lines separated by an empty line". Is there an idiomatic way of converting that into an array of arrays of strings?
[09:48:20] alfiemax: has joined #ruby
[09:49:54] ecuanaso: has joined #ruby
[09:52:46] tbuehlmann: guardian: like this? https://gist.github.com/tbuehlmann/4395e2c94d7b83348f035124a7269017
[09:54:23] gary: has joined #ruby
[09:55:34] guardian: sounds like it
[09:56:07] guardian: now the file weights 3GB, this is the output from the fdupes tool, maybe I shouldn't load all that into memory :D
[09:56:55] al2o3-cr: guardian: use IO.foreach
[09:57:31] Beams: has joined #ruby
[09:58:35] morenoh149: has joined #ruby
[10:00:26] guardian: well File.read('dupes.txt') doesn't work...
[10:00:31] guardian: but the error is cryptic
[10:00:32] guardian: Errno::EINVAL (Invalid argument @ io_fread - dupes.txt)
[10:00:49] guardian: I thought I messed the file name but File.exists?('dupes.txt') returns true
[10:00:51] InfinityFye: has joined #ruby
[10:01:00] mello: has joined #ruby
[10:02:27] drewmcmillan: has joined #ruby
[10:03:17] maufart__: has joined #ruby
[10:05:29] Gnut: has joined #ruby
[10:06:01] guardian: thanks al2o3-cr and tbuehlmann, IO.foreach('dupes.txt', "\n\n") { |lines| lines.split } works for me. It gives me an array of strings at each top level iteration
[10:07:16] gary_: has joined #ruby
[10:07:41] nadir: has joined #ruby
[10:08:14] RougeR: has joined #ruby
[10:13:37] dn`: has joined #ruby
[10:14:14] Megamosaren: has joined #ruby
[10:14:38] Sylario: has joined #ruby
[10:14:44] alfiemax: has joined #ruby
[10:16:18] dvdingus: has joined #ruby
[10:16:19] Gary_B: has joined #ruby
[10:17:43] al2o3-cr: yw guardian
[10:18:45] jenrzzz: has joined #ruby
[10:19:53] alfiemax: has joined #ruby
[10:23:16] aufi_: has joined #ruby
[10:25:28] Gary_B: has joined #ruby
[10:30:31] Gary_B: has joined #ruby
[10:32:02] pskosinski: has joined #ruby
[10:34:25] workmad3: has joined #ruby
[10:35:35] Gary_B: has joined #ruby
[10:45:26] Gary_B: has joined #ruby
[10:46:32] hayden___: has joined #ruby
[10:52:39] morenoh149: has joined #ruby
[10:53:58] bigblind: has joined #ruby
[10:55:24] milardovich: has joined #ruby
[10:58:39] mtkd: has joined #ruby
[11:00:40] shinnya: has joined #ruby
[11:04:03] yohji: has joined #ruby
[11:07:03] gary: has joined #ruby
[11:13:53] jaruga: has joined #ruby
[11:20:36] gary_: has joined #ruby
[11:26:05] Cavallari: has joined #ruby
[11:29:59] RougeR: has joined #ruby
[11:30:00] RougeR: has joined #ruby
[11:30:20] Gary_B: has joined #ruby
[11:30:36] alicefloyd: has joined #ruby
[11:30:43] alicefloyd: has left #ruby: ()
[11:30:44] ldnunes: has joined #ruby
[11:31:00] morenoh149: has joined #ruby
[11:31:23] dvdingus: has joined #ruby
[11:34:18] alfiemax: has joined #ruby
[11:35:23] chridal: I have a 'server' that I've implemented, that's basically a for loop polling AWS SQS. I want to be able to test this with RSpec. If I start my server by running the `server` method, though, I'm not really able to stop it without doing CTRL-c
[11:35:43] chridal: while loop **
[11:36:27] chridal: So my question is; how should I go about controlling this? I probably need some sort of wrapper around the whole thing, that will allow me to stop and start the server or something? A new thread?
[11:37:23] chridal: I will have to daemonize this at some point, and I really dont' want to mess too much with PID files etc.
[11:37:59] devil_tux: has joined #ruby
[11:42:34] Psybur_: has joined #ruby
[11:44:31] amatas_: has joined #ruby
[11:45:23] leitz: has joined #ruby
[11:46:59] mikecmpbll: has joined #ruby
[11:47:23] quobo: has joined #ruby
[11:48:44] bigblind: has joined #ruby
[11:48:54] konsolebox: has joined #ruby
[11:53:00] alfiemax: has joined #ruby
[11:55:55] konsolebox: has joined #ruby
[11:56:15] Gary_B: has joined #ruby
[11:56:31] marr: has joined #ruby
[11:57:27] ecuanaso: has joined #ruby
[11:58:18] nowhereman_: has joined #ruby
[11:59:24] AJA4350: has joined #ruby
[12:05:40] _aeris_: has joined #ruby
[12:06:55] gary: has joined #ruby
[12:07:30] bigblind: has joined #ruby
[12:10:00] alfiemax: has joined #ruby
[12:12:16] gary_: has joined #ruby
[12:15:28] alfiemax: has joined #ruby
[12:16:09] jokke: has joined #ruby
[12:16:42] TheBrayn: has joined #ruby
[12:16:44] drewmcmillan: has joined #ruby
[12:17:33] Gary_B: has joined #ruby
[12:17:48] ineb: has joined #ruby
[12:17:58] konsolebox: has joined #ruby
[12:19:28] dcluna: has joined #ruby
[12:21:05] karapetyan: has joined #ruby
[12:22:19] goatish: has joined #ruby
[12:22:34] karapetyan: has joined #ruby
[12:25:59] milardovich: has joined #ruby
[12:26:49] Gary_B: has joined #ruby
[12:27:28] phenom: has joined #ruby
[12:33:16] S007: has joined #ruby
[12:39:53] Gary_B: has joined #ruby
[12:40:28] phenom: has joined #ruby
[12:42:59] Psybur: has joined #ruby
[12:43:06] ogres: has joined #ruby
[12:44:27] TheBrayn: has joined #ruby
[12:44:34] Papierkorb: has joined #ruby
[12:44:38] Papierkorb: has left #ruby: ("Konversation terminated!")
[12:47:37] jokke: has joined #ruby
[12:49:19] za1b1tsu: has joined #ruby
[12:54:37] DTZUZO: has joined #ruby
[12:56:46] konsolebox: has joined #ruby
[12:59:23] synthroid: has joined #ruby
[13:00:52] Cavallari1: has joined #ruby
[13:01:23] gary: has joined #ruby
[13:02:50] _aeris_: has joined #ruby
[13:04:19] konsolebox: has joined #ruby
[13:04:56] n0m4d1c: has joined #ruby
[13:06:40] jeffreylevesque: has joined #ruby
[13:10:49] gary_: has joined #ruby
[13:12:20] jtroseme: has joined #ruby
[13:15:10] jeffreylevesque_: has joined #ruby
[13:18:45] konsolebox: has joined #ruby
[13:18:59] vutral|kali: has joined #ruby
[13:18:59] vutral|kali: has joined #ruby
[13:19:26] drewmcmillan: has joined #ruby
[13:23:04] milardovich: has joined #ruby
[13:23:46] govg: has joined #ruby
[13:24:02] John_Ivan: has joined #ruby
[13:24:03] John_Ivan: has joined #ruby
[13:25:15] memo1: has joined #ruby
[13:27:37] Gary_B: has joined #ruby
[13:27:45] ldepandis: has joined #ruby
[13:32:37] Gary_B: has joined #ruby
[13:33:24] dinfuehr: has joined #ruby
[13:35:02] cagomez: has joined #ruby
[13:36:09] clemens3: has joined #ruby
[13:38:28] chmurifree: has joined #ruby
[13:39:21] bngsudheer: has joined #ruby
[13:40:06] bngsudheer: Can I ask a question about installing ruby gem?
[13:42:50] ecuanaso: has joined #ruby
[13:43:26] Gary_B: has joined #ruby
[13:48:49] dminuoso: bngsudheer: Yes.
[13:49:33] bmurt: has joined #ruby
[13:49:36] leitz: Beats asking a question about asking a question. We seem to be a questionable lot...
[13:50:18] RougeR: has joined #ruby
[13:57:07] cagomez: has joined #ruby
[14:00:39] lesce: has joined #ruby
[14:02:23] drewmcmillan: has joined #ruby
[14:04:38] gary: has joined #ruby
[14:08:10] jcalla: has joined #ruby
[14:11:46] sidx64: has joined #ruby
[14:13:14] cdg: has joined #ruby
[14:13:50] gary_: has joined #ruby
[14:14:23] milardovich: has joined #ruby
[14:14:27] ecuanaso: has joined #ruby
[14:15:19] FrostCandy: has joined #ruby
[14:15:49] FrostCandy: I'm trying to create a hash with an array of hash's (objects) in it - https://gist.github.com/anonymous/c895d328d1d8684c37308d7f5ae8353f
[14:15:51] bogdan: has joined #ruby
[14:16:22] FrostCandy: Is that the right way to write it?
[14:18:55] konsolebox: has joined #ruby
[14:19:15] cadillac_: has joined #ruby
[14:19:43] tobiasvl: FrostCandy: did you try it?
[14:20:35] FrostCandy: ya it seems to work but i'm trying to send it in an http::post which I guess can't seem to send the data field as an array
[14:20:58] FrostCandy: request.set_form_data(d) fails i think
[14:21:03] FrostCandy: i'l have to look into it
[14:21:43] chridal: I'm trying to stub out a class (RestClient) in RSpec. Is it possible to 'replace' the RestClient for that file (which is deeply nested beneath this call), or do I have to do dependency injection?
[14:22:01] Cavallari1: has joined #ruby
[14:22:15] beauby: has joined #ruby
[14:22:17] chridal: I'd rather not inject the dependency, because I'm doing an integration test, and the use of RestClient is 4-5 files away from my current call
[14:22:49] LocaMocha: has joined #ruby
[14:24:49] cagomez: has joined #ruby
[14:26:59] sagax: has joined #ruby
[14:27:00] bmurt: has joined #ruby
[14:27:12] sagax: please help,
[14:27:30] tbuehlmann: chridal, you can stub constants with rspec: https://relishapp.com/rspec/rspec-mocks/v/3-7/docs/mutating-constants/stub-defined-constant
[14:27:50] sagax: how i can see what methods be exports when i require some package?
[14:28:13] FrostCandy: tobiasvl: Ah set_form_data doen't handle nested hashes.
[14:28:18] sagax: example, when require "open-uri" we have method "open"
[14:28:50] sagax: but how to i see all methods who was exports from package?
[14:30:17] rwb: has joined #ruby
[14:31:58] karapetyan: has joined #ruby
[14:34:33] vondruch: has joined #ruby
[14:36:26] vondruch: has joined #ruby
[14:37:32] desperek: has joined #ruby
[14:39:19] Gary_B: has joined #ruby
[14:39:33] bogdan: has joined #ruby
[14:44:16] pastorinni: has joined #ruby
[14:45:10] Cope: has joined #ruby
[14:47:48] Megamos: has joined #ruby
[14:52:29] beauby: has joined #ruby
[14:57:16] Gary_B: has joined #ruby
[14:59:10] beauby_: has joined #ruby
[15:01:32] milardovich: has joined #ruby
[15:04:42] jeffreylevesque: has joined #ruby
[15:06:49] gary: has joined #ruby
[15:07:38] xfbs: has joined #ruby
[15:08:57] jeffreylevesque_: has joined #ruby
[15:09:19] HeikkiG: has joined #ruby
[15:09:35] rippa: has joined #ruby
[15:09:44] HeikkiG: good day, does anyone know whether ruby's standard library has a function to tell if a unicode codepoint belongs to number group?
[15:11:16] k0mpa: has joined #ruby
[15:12:19] moei: has joined #ruby
[15:12:27] Rapture: has joined #ruby
[15:12:51] adlerdias: has joined #ruby
[15:14:49] apeiros: HeikkiG: might work with regex and \p character classes
[15:15:11] gary_: has joined #ruby
[15:16:21] apeiros: please tell whether it works. I'm actually curious. I think it'd be \p{N}
[15:16:27] troys: has joined #ruby
[15:17:09] HeikkiG: works well indeed!
[15:19:03] regedit_: has joined #ruby
[15:20:16] Cope: has joined #ruby
[15:22:29] Gnut: has joined #ruby
[15:24:07] schneide_: has joined #ruby
[15:25:07] Gary_B: has joined #ruby
[15:27:50] Megamos: has joined #ruby
[15:28:54] bmurt: has joined #ruby
[15:30:43] chouhoulis: has joined #ruby
[15:30:49] cadillac_: has joined #ruby
[15:32:25] mikecmpb_: has joined #ruby
[15:34:17] Gary_B: has joined #ruby
[15:37:15] apricant: has joined #ruby
[15:37:23] halt: has joined #ruby
[15:37:27] chrisarcand: has joined #ruby
[15:37:52] S007: has joined #ruby
[15:39:45] gizmore: has joined #ruby
[15:40:29] CyberShadow: has joined #ruby
[15:44:26] OyoKooN: has joined #ruby
[15:45:11] GinoMan: has joined #ruby
[15:45:14] krawchyk: has joined #ruby
[15:50:07] Megamos: has joined #ruby
[15:51:50] Gary_B: has joined #ruby
[15:51:55] CyberShadow: has left #ruby: ()
[15:53:06] beauby: has joined #ruby
[15:57:00] Gary_B: has joined #ruby
[15:57:11] Mike11: has joined #ruby
[15:59:56] banisterfiend: has joined #ruby
[16:00:36] schneide_: has joined #ruby
[16:05:07] dinfuehr: has joined #ruby
[16:10:10] gary: has joined #ruby
[16:10:18] John_Ivan: has joined #ruby
[16:10:18] John_Ivan: has joined #ruby
[16:12:42] dviola: has joined #ruby
[16:13:58] apeiros__: has joined #ruby
[16:15:09] gary_: has joined #ruby
[16:19:33] jaruga: has joined #ruby
[16:19:58] mikecmpbll: has joined #ruby
[16:22:08] devil_tux: has joined #ruby
[16:26:40] ogres: has joined #ruby
[16:27:13] Puffball: has joined #ruby
[16:29:05] nadir: has joined #ruby
[16:29:36] mtkd: has joined #ruby
[16:29:53] jeffreylevesque: has joined #ruby
[16:31:12] Megamosaren: has joined #ruby
[16:32:19] Gary_B: has joined #ruby
[16:33:47] milardovich: has joined #ruby
[16:37:24] snath: has joined #ruby
[16:37:49] banisterfiend: has joined #ruby
[16:38:48] snath: has joined #ruby
[16:40:04] cagomez: has joined #ruby
[16:40:29] Gary_B: has joined #ruby
[16:40:56] krawchyk: has joined #ruby
[16:42:37] DTZUZO: has joined #ruby
[16:51:08] Gary_B: has joined #ruby
[16:52:31] troys: has joined #ruby
[16:53:43] beauby: has joined #ruby
[16:57:47] sumobob: has joined #ruby
[17:03:56] drewmcmillan: has joined #ruby
[17:06:21] apeiros: has joined #ruby
[17:06:47] drewmcmillan: has joined #ruby
[17:07:12] krawchyk: has joined #ruby
[17:09:09] gary: has joined #ruby
[17:09:57] ecuanaso: has joined #ruby
[17:11:19] lesce: has joined #ruby
[17:11:38] krawchyk: has joined #ruby
[17:12:18] schneide_: has joined #ruby
[17:12:36] jcarl43: has joined #ruby
[17:12:37] riotjoe: has joined #ruby
[17:15:37] adlerdias: has left #ruby: ()
[17:17:19] tomphp: has joined #ruby
[17:21:05] chouhoulis: has joined #ruby
[17:22:11] chouhoul_: has joined #ruby
[17:23:24] chouhoul_: has joined #ruby
[17:23:52] gary_: has joined #ruby
[17:24:19] chouhoul_: has joined #ruby
[17:25:03] adlerdias: has joined #ruby
[17:25:27] chouhoul_: has joined #ruby
[17:25:58] amatas_: has joined #ruby
[17:26:31] chouhoulis: has joined #ruby
[17:26:34] d5sx43: has joined #ruby
[17:27:04] s2013: has joined #ruby
[17:27:46] riotjones: has joined #ruby
[17:27:46] chouhoul_: has joined #ruby
[17:27:53] safetypin: has joined #ruby
[17:28:25] delaz: has joined #ruby
[17:28:37] delaz: has left #ruby: ()
[17:28:44] chouhoul_: has joined #ruby
[17:28:57] amatas_: has joined #ruby
[17:29:43] n0m4d1c: has joined #ruby
[17:29:53] chouhoul_: has joined #ruby
[17:30:59] chouhoul_: has joined #ruby
[17:32:03] chouhoulis: has joined #ruby
[17:32:54] darkhanb: has joined #ruby
[17:33:09] chouhoul_: has joined #ruby
[17:34:19] chouhoul_: has joined #ruby
[17:34:31] rrutkowski: has joined #ruby
[17:34:32] guacamole: has joined #ruby
[17:34:32] guacamole: has joined #ruby
[17:34:40] chouhoul_: has joined #ruby
[17:34:53] amatas_: has joined #ruby
[17:35:07] cadillac_: has joined #ruby
[17:36:39] mynamei5: has joined #ruby
[17:36:50] mynamei5: has joined #ruby
[17:38:13] dionysus69: has joined #ruby
[17:38:29] rrutkowski: has joined #ruby
[17:39:50] s3nd1v0g1us: has joined #ruby
[17:45:49] Gary_B: has joined #ruby
[17:46:09] n008f4g_: has joined #ruby
[17:46:56] orbyt_: has joined #ruby
[17:47:41] bmurt: has joined #ruby
[17:50:00] despai: has joined #ruby
[17:50:01] rrutkowski: has joined #ruby
[17:50:19] clemens3: has joined #ruby
[17:51:04] sanscoeur: has joined #ruby
[17:51:56] sanscoeur: has joined #ruby
[17:52:42] cagomez: has joined #ruby
[17:53:30] mynamei5: has joined #ruby
[17:54:40] alfiemax: has joined #ruby
[17:55:56] banisterfiend: has joined #ruby
[17:56:45] despai: has joined #ruby
[17:56:54] bngsudheer: has left #ruby: ("Leaving")
[18:00:43] gary: has joined #ruby
[18:01:37] bngsudheer: has joined #ruby
[18:05:14] guacamole: has joined #ruby
[18:05:14] guacamole: has joined #ruby
[18:07:27] mynamei5: has joined #ruby
[18:08:56] xenops: has joined #ruby
[18:12:44] hdb2: has joined #ruby
[18:15:31] hdb2: hello - new to ruby, I am trying to open a file using whatever editor the user has set in their env. I came up with system("#{ENV['EDITOR']}, file) from google, but this throws an error. can someone point me in the right direction?
[18:16:59] drewmcmillan: has joined #ruby
[18:17:41] hdb2: it appears that I can call the editor by name, e.g. system('vi', foo) but I'd like to generalize it
[18:20:56] zmo: hdb2 - you need to have the $EDITOR env variable set up before you run your script
[18:21:04] zmo: it's often the case, but it's not always the case
[18:23:11] workmad3: has joined #ruby
[18:24:08] guille-moe: has joined #ruby
[18:24:44] elomatreb: And it needs to be exported of course, try just debug printing ENV and see if it's there at all
[18:25:03] karapetyan: has joined #ruby
[18:25:05] hdb2: zmo: understood. if I have that variable set (say, in my .bashrc), is system what I need to use to open the file with $EDITOR or something else?
[18:25:24] dminuoso: ACTION does some smalltalk with elomatreb
[18:25:33] dminuoso: ACTION sends elomatreb :hi
[18:26:02] zmo: hdb2 - launch irb
[18:26:06] dminuoso: ACTION sends elomatreb :launch_nukes
[18:26:11] zmo: and then run system(ENV['EDITOR'])
[18:26:13] zmo: and you'll see
[18:26:24] mcr1: has joined #ruby
[18:26:41] sameerynho: has joined #ruby
[18:26:45] elomatreb: dminuoso: :pew_pew
[18:28:17] hdb2: zmo: I'll dig into that - thank you for the help!
[18:28:28] eckhardt: has joined #ruby
[18:29:32] sumobob: has joined #ruby
[18:29:44] zmo: damn… rails is driving me crazy… I'm running it in docker-compose, I do docker-compose --build up -d, it's working fine, but if I do docker-compose run web rails generate migration fubar, shits hits the fan saying about one of my deps: 'Could not find kaminari-core-1.1.1 in any of the sources' but it's there and the code works, bloody !@#$
[18:30:24] zkv: has joined #ruby
[18:30:44] dminuoso: zmo: That does not sound too surprising.
[18:30:47] dminuoso: zmo: Can you share your Dockerfile?
[18:31:30] Lytol: has joined #ruby
[18:34:13] zmo: https://gitlab.com/zeloce/zeloce-backend/snippets/1699903
[18:34:38] ramfjord: has joined #ruby
[18:34:57] zmo: sounds like that URL won't work
[18:35:01] zmo: even if I checked public
[18:35:22] zmo: let me repost
[18:35:28] sameerynho: has joined #ruby
[18:35:32] 17SAAQ7S9: has joined #ruby
[18:37:32] zmo: that one should be public https://gitlab.com/snippets/1699905
[18:38:47] gary_: has joined #ruby
[18:39:34] alex``: Is there a built-in method to pick entries from hash?
[18:39:54] zmo: alex`` - what you mean?
[18:39:55] alex``: Reduce a hash from some entries
[18:40:09] zmo: Hash#filter ?
[18:40:36] zmo: I think it's Hash#select
[18:40:37] dminuoso: alex``: .to_a.select.to_h
[18:40:42] zmo: or something like that
[18:40:54] alex``: Something like
[18:40:55] dminuoso: But I guess
[18:40:59] alex``: node = self.class.send(:new, self.class.pick(hash, :identifier, :value))
[18:40:59] dminuoso: Hash#select does that
[18:41:02] zmo: (too much python)
[18:41:09] dminuoso: &ri Hash#selecft
[18:41:10] `derpy: No results
[18:41:11] dminuoso: &ri Hash#select
[18:41:11] `derpy: http://ruby-doc.org/core-2.4.1/Hash.html#method-i-select
[18:41:13] alex``: def self.pick hash, *values
[18:41:15] alex``: hash.select do |key, value|
[18:41:17] alex``: values.include? value
[18:41:25] havenwood: alex``: Do you know the keys you're looking for?
[18:41:27] alex``: Hash#select is too verbose
[18:41:34] dminuoso: ACTION pokes havenwood
[18:41:37] dminuoso: ACTION stabs havenwood
[18:41:50] alex``: I would like something like Hash#pick([key]...)
[18:41:55] havenwood: alex``: https://docs.ruby-lang.org/en/2.5.0/Hash.html#method-i-slice
[18:42:19] zmo: alex`` - so you want a select on values?
[18:42:38] alex``: I want call a method with named parameters
[18:42:44] alex``: node = self.class.send(:new, self.class.pick(hash, :identifier, :value))
[18:43:25] havenwood: {a: 100, b: 200, c: 300}.slice(:b, :a) #=> {:b=>200, :a=>100}
[18:43:26] havenwood: {a: 100, b: 200, c: 300}.values_at(:b, :a) #=> [200, 100]
[18:43:26] tAn: has joined #ruby
[18:43:29] alex``: so node = new(identifier: hash[:identifier], value: hash[:value])
[18:43:50] alex``: havenwood: That slice!
[18:44:39] alex``: By the way, if I had to create helpers methods, like this one, where to put them?
[18:44:54] alex``: I have a Node class in lib/node.rb
[18:45:21] alex``: It is best to put at the bottom after `private`?
[18:45:24] alex``: or a new file
[18:46:10] zmo: dminuoso - why did you ask about the Dockerfile? any hint there?
[18:46:12] alex``: and if a new file, how to organize the code
[18:46:20] alex``: zmo: = guyzmo?
[18:46:24] anjen: has joined #ruby
[18:46:44] dminuoso: zmo: Oh sorry didnt see you already posted it.
[18:46:51] zmo: alex`` - indeed
[18:46:56] zmo: dminuoso - no problem :)
[18:47:29] zmo: alex`` = alex` ? :)
[18:48:40] havenwood: alex``: Sure, you can always define a private method that acts as a function with the hash as the first argument. Other options include extracting it to a module with module_function, or using a refinement.
[18:48:46] alfiemax: has joined #ruby
[18:49:26] dminuoso: zmo: You need an additional layer I think.
[18:49:35] havenwood: alex``: Just avoid globally m̶o̶n̶k̶e̶y̶ freedom patching the core class of Hash.
[18:49:43] zmo: dminuoso - what do you mean?
[18:49:45] dminuoso: zmo: The topmost layer does not have the bundle installed.
[18:49:51] dminuoso: Since that's your RUN command
[18:50:16] dminuoso: Or.. Im not 100% sure about this. But I think it might not work.
[18:50:28] alex``: havenwood: Yep I was tempted to do def Hash.pick or something
[18:50:42] dminuoso: zmo: Nevermind, Im not quite clear headed.
[18:50:57] alex``: but figured it was a bad idea as it can conflict with the code of other
[18:51:00] zmo: uhuh ok
[18:51:19] baweaver: >> def foo(key:,value:) "#{key}: #{value}"end;hash={key:1,value:2};foo(**hash) # :D
[18:51:20] ruby[bot]: baweaver: # => "1: 2" (https://eval.in/959765)
[18:52:01] dminuoso: zmo: So let me just ask this. Why are you trying to generate a migration inside the docker container at all?
[18:52:37] havenwood: alex``: A refinement lets you safely limit the scope of such a change.
[18:52:43] dminuoso: zmo: (The reason I got confused is because I thought you actually ran "bundle install" as your CMD since it was at the bottom. Then pure mimicry just repeated RUN.
[18:52:51] dminuoso: Which confused me slightly.
[18:53:09] baweaver: Refinements are weapons of a more civilized age
[18:53:25] dminuoso: ACTION hands baweaver his lightrefinement
[18:53:50] dminuoso: baweaver: Outside this channel Ive yet to see them anywhere.
[18:54:01] baweaver: (honestly same here)
[18:54:10] dminuoso: They are like flipflop. We all itch to use it but nobody seems to know what it is.
[18:54:23] kapil___: has joined #ruby
[18:54:31] zmo: dminuoso - well, it's all working fine, except when I run a rails command where it complains I don't have a dependency installed
[18:54:32] GinoMan: has joined #ruby
[18:55:01] bmurt: has joined #ruby
[18:55:01] zmo: dminuoso - ah, missed your question
[18:55:09] dminuoso: zmo: that means its not picking up the bundle. its possible the binstub might not work depending on the further details of your docker container
[18:55:17] dminuoso: zmo: try running it through `bundle exec`
[18:55:31] zmo: dminuoso - well, TBH, it's because it's how I've been told how to do it
[18:55:50] zmo: and because I don't have the rails stuff configured configured the same locally
[18:55:52] dminuoso: zmo: Just out of curiousity, try running `bundle exec rails ...` instead of raw `rails`
[18:55:58] dminuoso: Somehow I expect that to work.
[18:56:29] dminuoso: zmo: If that works, add a "rehash" CMD.
[18:56:51] dminuoso: See if that allows the rails binstub to function
[18:57:17] GinoMan: has joined #ruby
[18:57:20] dminuoso: Or just live with `bundle exec`
[18:57:29] zmo: docker-compose exec web bundle rails generate migration
[18:57:30] zmo: does not work
[18:57:46] dminuoso: zmo: It's `bundle exec rails generate migrationz`
[18:57:47] dminuoso: zmo: It's `bundle exec rails generate migration`
[18:58:28] dminuoso: zmo: essentially when you run `rails` commands inside a bundler directory, the binstub detects it, and ends up doing something similar anyway.
[18:58:29] zmo: you mean outside of the docker ?
[18:58:41] dminuoso: docker-compose exec web bundle exec rails generate migration
[18:58:51] dminuoso: you were missing the "exec" command for "bundler" there
[18:58:55] dvdingus: has joined #ruby
[18:59:01] zmo: double exec
[18:59:12] dminuoso: One is for docker-compose, the other is for `bundler` ;)
[18:59:20] zmo: too many execs :)
[18:59:32] dminuoso: zmo: That being said, is there a reason you generate migrations inside a docker container?
[18:59:36] zmo: ok, with the too many execs, still same issue
[18:59:47] zmo: it's because my local environment is not configured
[19:00:03] zmo: and I'm not even running the same ruby outside of the docker than from within
[19:00:07] jamesaxl: has joined #ruby
[19:00:09] zmo: (maybe I should upgrade, though)
[19:00:14] dminuoso: zmo: so what?
[19:00:27] dminuoso: zmo: just generate the migration outside, and then rebuild from that layer
[19:00:35] zmo: and it's also because it's how I've been told to do stuff, and it was working up until now
[19:00:38] milardovich: has joined #ruby
[19:00:48] havenwood: alex``: https://gist.github.com/havenwood/a69cf958f5bc42b3200f14a91543c1bc
[19:01:01] havenwood: alex``: That's an example of backporting Hash#slice with a refinement.
[19:01:28] drewmcmillan: has joined #ruby
[19:01:46] alex``: havenwood: What is for back-porting?
[19:02:17] dminuoso: zmo: I wonder, what does your docker-compose.yml look like?
[19:02:26] havenwood: alex``: Hash#slice was introduced in Ruby 2.5. If you'd like to implement it yourself, that's ^ an example of how to do it with refinements.
[19:02:48] alex``: Always use the Ruby head version :p
[19:03:07] sameerynho: has joined #ruby
[19:05:25] alex``: havenwood: You know the Ruby equivalent of JavaScript to construct hash from variable names?
[19:05:59] alex``: In JS: a = 1; b = 2; { a, b }; # => { a: 1, b: 2 }
[19:09:26] amatas_: has joined #ruby
[19:09:58] dnewkerk: has joined #ruby
[19:10:09] gary: has joined #ruby
[19:11:35] zmo: dminuoso - https://gitlab.com/snippets/1699918
[19:11:52] dnewkerk_: has joined #ruby
[19:13:48] baweaver: Nope, Ruby doesn't have a concept of object (hash) destructuring or assignment
[19:13:53] dminuoso: zmo: The more I look at this the more Im confused. `bundle exec run` should work
[19:14:09] dminuoso: zmo: *docker-compose run bundle exec rails
[19:14:37] baweaver: ACTION grabs black magic grimoire
[19:15:35] memo1: has joined #ruby
[19:16:19] cdg: has joined #ruby
[19:16:48] nowhere_man: has joined #ruby
[19:16:57] dnewkerk_: has joined #ruby
[19:17:14] karapetyan: has joined #ruby
[19:17:25] havenwood: >> a = 1; b = 2; %i{a b}.select { |key| binding.local_variable_defined?(key) }.map { |key| [key, binding.local_variable_get(key)] }.to_h
[19:17:26] ruby[bot]: havenwood: # => {:a=>1, :b=>2} (https://eval.in/959781)
[19:17:34] erlend: has joined #ruby
[19:17:39] zmo: ok I don't get rails at all
[19:17:45] zmo: dminuoso - I'm not sure what I've done
[19:17:47] zmo: but now it's working
[19:17:50] bougyman: I get it. That's why I don't use it.
[19:18:32] zmo: bougyman - well, I heritated this project six months back, and everyday has been a struggle
[19:18:51] dnewkerk: has joined #ruby
[19:19:52] dminuoso: bougyman: Hah.
[19:19:52] zmo: and because I did not know rails originally, I considered I did not know enough, but 6 months later, I just know it's rails.
[19:20:01] dminuoso: bougyman: The more I understand Rails, the less I use it.
[19:20:38] mcr1: has joined #ruby
[19:20:42] zmo: I'm currently rewriting most of the controller stuff with DRY and Trailblazer, and I'm exposing it all as grape API
[19:20:52] WA9ACE: I end up building from the ground up with sinatra, then normally by the 2-3 month mark I've built my own padrino on top of Sinatra
[19:21:21] zmo: WA9ACE - I'm coming from python+flask, so I totally hear you
[19:21:38] WA9ACE: I like Flask too
[19:23:50] dminuoso: zmo: Trailblazer is really great :)
[19:23:57] dminuoso: zmo: Which of their libraries are you using?
[19:24:41] dminuoso: WA9ACE: I found too much time in Rails is spend figuring magic DSL, filters, magic callbacks, more DSL - and then some more to accomplish goals
[19:24:48] dminuoso: When instead you could have just written code to solve the problem.
[19:24:51] zmo: dminuoso - I'm still discovering, so it's only the basics
[19:25:01] despai: has joined #ruby
[19:25:24] claudiuinberlin: has joined #ruby
[19:25:38] dminuoso: zmo: No I meant like, are you using cells? formular? operation? representable?
[19:25:39] WA9ACE: dminuoso I don't disagree, however at the moment I'm bootstrapping a new rails app for work with devise and activeadmin
[19:25:41] zmo: mostly the raw trailblazer stuff (step/success/failure) and the formal validation API (which I think is from DRY)
[19:25:45] WA9ACE: took all of 30 minutes
[19:27:13] konos5_: has joined #ruby
[19:27:44] zmo: well, the tragedy in my code is that I inherited it as it was like 6kLOC, with a huge schema (about 13 tables) some with 5× n-ary associations
[19:28:01] zmo: and NOT A SINGLE FSCKING BL**DY TEST !@#$
[19:28:15] WA9ACE: I feel for you there
[19:28:28] zmo: and I knew very little of ruby and rails
[19:28:30] mikecmpbll: has joined #ruby
[19:28:33] WA9ACE: sometimes I feel like people started with rails and never learned how to normalize a schema
[19:28:59] riotjoe: has joined #ruby
[19:29:31] zmo: so I spent like 4 months trying to stop the bleeding, and now I'm preparing for the future, which means rewriting everything through trailblazer
[19:29:48] zmo: dminuoso - about trailblazer, I think it's only operations
[19:29:50] apeiros: ACTION drops "polymorphic association", waits for WA9ACE' reaction
[19:30:39] apeiros: zmo: 13 tables isn't even close to huge. sorry.
[19:30:52] WA9ACE: there's also that ^
[19:31:13] WA9ACE: last large product I worked on (Play framework/Scala) was 56 tables
[19:31:22] zmo: it's all relative
[19:31:36] banisterfiend: has joined #ruby
[19:31:46] zmo: for a simple booking system it's huge
[19:31:54] zmo: it should be half of that
[19:31:55] krawchyk: has joined #ruby
[19:32:07] apeiros: "unnecessarily big/complex" then
[19:32:26] apeiros: and yes. rarely seen software which isn't.
[19:32:28] zmo: apeiros - you're loosing the frustration of the exageration
[19:32:39] zmo: s/of the/in the/
[19:32:45] apeiros: I save it for the big bang
[19:32:47] zmo: and s/loosing/losing/
[19:33:05] apeiros: and exaggeration ;-)
[19:33:37] zmo: I guess I should call it a day
[19:33:45] apeiros: what a week…
[19:33:56] zmo: (though, it really takes two g ? oO)
[19:33:58] WA9ACE: apeiros polymorphic associations...
[19:34:10] zmo: (learned a thing today)
[19:34:32] cadillac_: has joined #ruby
[19:34:49] apeiros: ( https://pics.onsizzle.com/what-a-week-huh-its-tuesday-mood-3778251.png )
[19:35:06] mtkd: has joined #ruby
[19:35:17] tomlazar: has joined #ruby
[19:35:33] morenoh149: has joined #ruby
[19:36:05] zmo: apeiros - lol, it got filtered
[19:36:15] WA9ACE: a smart man learns from his own mistakes, a wise man learns from the mistakes of others
[19:36:32] WA9ACE: people using polymorphic associations will learn from the former
[19:36:34] apeiros: and idiots think they make no mistakes
[19:36:56] yxhuvud: 56 tables? large? heh.
[19:36:57] apeiros: of course, I'm the exception 🤪
[19:37:17] WA9ACE: `rescue ApeirosEx => e`
[19:37:46] apeiros: what do you want to do with my Ex?
[19:37:48] Cope: has joined #ruby
[19:38:03] WA9ACE: when people say "ace why don't you write tests?" I just tell them I don't write bugs
[19:38:05] WA9ACE: only features
[19:38:23] WA9ACE: nice little bitey bug shaped features
[19:38:31] apeiros: you're tame.
[19:38:38] WA9ACE: just kidding, I write tests
[19:38:45] WA9ACE: sometimes
[19:38:52] apeiros: I push them against the wall, elbow in their throat: "WHAT?!? Are you saying my code was buggy?!?"
[19:39:10] WA9ACE: I was going for the Bob Ross style
[19:39:12] zmo: tests are for loosers
[19:39:16] WA9ACE: we only make happy little bugs
[19:39:19] dminuoso: tests are for people without type checkers.
[19:39:46] apeiros: ACTION writes far too few tests :(
[19:39:51] Rapture: has joined #ruby
[19:39:58] WA9ACE: ah yes, because we've never written bugs in statically typed languages
[19:44:54] alfiemax: has joined #ruby
[19:45:17] apeiros: oy banisterfiend
[19:45:20] banisterfiend: apeiros have you ever written tests for stuff that touches the file system? what's your approach?
[19:45:22] banisterfiend: i'm struggling
[19:45:50] apeiros: banisterfiend: actually I have
[19:45:52] apeiros: 2 approaches
[19:46:01] banisterfiend: my approach has been rewriting the class so that it can deal with a super minimal number of files, writing those to a temp folder, and then explicitly checking the file system
[19:46:07] banisterfiend: but those aren't strictly unit tests
[19:46:08] apeiros: there's fakefs/mockfs (not sure about the name anymore)
[19:46:29] apeiros: and the other approach was that I used a directory within the test-dir
[19:46:54] Cope_: has joined #ruby
[19:47:11] apeiros: but the latter only works if you can restrict your stuff to relative paths
[19:47:30] zmo: anyway, calling it a day
[19:47:49] zmo: thank you 🙌
[19:47:52] zmo: ACTION &
[19:48:29] banisterfiend: apeiros how flakey is fakefs though?
[19:48:51] apeiros: been a while since I used it, and that wasn't much either
[19:49:16] banisterfiend: i'm finding it kinda difficult, and *really* dont want to stub out FileUtils and the 'system' call, heh
[19:49:48] gary_: has joined #ruby
[19:54:25] tlazar: has joined #ruby
[19:55:36] Megamosaren: has joined #ruby
[19:55:59] ramfjord: has joined #ruby
[19:56:41] alex``: has joined #ruby
[20:00:26] nadir: has joined #ruby
[20:00:30] yorickpeterse: has joined #ruby
[20:01:57] ramfjord: has joined #ruby
[20:05:27] shinnya: has joined #ruby
[20:08:58] ramfjord: has joined #ruby
[20:10:16] lesce: has joined #ruby
[20:12:54] despai: has joined #ruby
[20:14:59] ramfjord: has joined #ruby
[20:17:45] nopolitica: has joined #ruby
[20:18:01] Cope: has joined #ruby
[20:19:05] cthulchu: has joined #ruby
[20:19:38] lesce: has joined #ruby
[20:20:50] ramfjord: has joined #ruby
[20:22:57] quobo: has joined #ruby
[20:26:12] sumobob: has joined #ruby
[20:26:46] ramfjord: has joined #ruby
[20:27:34] gary: has joined #ruby
[20:27:41] SynSynack: has joined #ruby
[20:28:22] Dimik: has joined #ruby
[20:28:24] tvw: has joined #ruby
[20:31:10] ineb: i used fakefs once but ended up with using tmpdirs for fs related tests
[20:32:25] jenrzzz: has joined #ruby
[20:33:31] yqt: has joined #ruby
[20:34:07] Exuma: has joined #ruby
[20:37:52] lesce: has joined #ruby
[20:38:24] orbyt_: has joined #ruby
[20:38:33] chmurifree: has joined #ruby
[20:41:13] despai: has joined #ruby
[20:44:36] Brandonc123: has joined #ruby
[20:45:19] gary_: has joined #ruby
[20:48:00] xfbs: has joined #ruby
[20:48:06] jeffreylevesque_: has joined #ruby
[20:49:15] milardovich: has joined #ruby
[20:51:00] Brandonc123: has joined #ruby
[20:51:19] baweaver: banisterfiend: I found binding_of_caller
[20:51:26] baweaver: and I tried to do something very bad with it
[20:51:42] banisterfiend: yeah it allows some very naughty stuff
[20:51:53] baweaver: Think Javascript: const {a, b} = {a: 1, b: 2}
[20:51:58] baweaver: .....in Ruby
[20:52:20] baweaver: Still trying to get it to work, but will gist what I have so far
[20:52:23] bmurt: has joined #ruby
[20:52:29] baweaver: sets(:a, :b) < {a: 1, b: 2}
[20:52:53] banisterfiend: oh yeah i htink i get it
[20:52:59] baweaver: https://gist.github.com/baweaver/b03dfa78473439cb3ef3af506e9a4d68
[20:53:07] darkhanb: has joined #ruby
[20:53:07] banisterfiend: but i dont htink those locals will last right?
[20:53:18] baweaver: nope, they get lined out
[20:53:20] n008f4g_: has joined #ruby
[20:53:26] baweaver: Was trying to see if I could find a way around that
[20:53:34] banisterfiend: so you probably have to define methods in the caller scope
[20:53:36] banisterfiend: which is kinda nasty
[20:53:38] baweaver: short of ivar/accessors
[20:53:52] baweaver: I don't think it's entirely possible
[20:54:06] banisterfiend: what about: a,b = foo({a: 1, b: 2})
[20:54:09] banisterfiend: would that work?
[20:54:18] banisterfiend: or the locals still aren't dfeined i guess?
[20:54:32] baweaver: problem is mapping local a to hash :a
[20:54:52] banisterfiend: this would work though
[20:54:54] baweaver: because if that were the case then just: a, b = hash.slice(:a, :b)
[20:55:34] banisterfiend: or more like: a,b = hash.values_at(:a, :b)
[20:55:51] banisterfiend: you might have to something janky with bytecode?
[20:56:00] baweaver: I mean one _could_ just add a transpilation layer.
[20:56:04] baweaver: yeah, or that
[20:56:06] banisterfiend: i havne't messe dmuch with it, but perhaps something related to InstructionSequences
[20:56:07] delaz: has joined #ruby
[20:56:16] apeiros: ACTION hits banisterfiend with a transpiler
[20:56:16] baweaver: short of futzing the VM I don't think it can be done
[20:56:23] apeiros: whoops, sorry, wrong target!
[20:56:28] apeiros: ACTION hits baweaver with a transpiler
[20:56:58] baweaver: I'll have to look into InstrucitonSequences
[20:57:04] baweaver: anyone have some good reads around that?
[20:57:07] delaz: has left #ruby: ()
[20:57:16] Cope_: has joined #ruby
[20:58:23] guacamole: has joined #ruby
[20:58:24] guacamole: has joined #ruby
[20:58:33] baweaver: either that or I should read into the lexer and see if I can add that into the tokenization
[20:58:44] hdb2: has joined #ruby
[21:00:11] bijan_: has joined #ruby
[21:00:52] Gary_B: has joined #ruby
[21:01:46] cdg: has joined #ruby
[21:01:55] reber: has joined #ruby
[21:02:39] brewops: has joined #ruby
[21:03:47] brewops: has left #ruby: ()
[21:04:08] guacamole: has joined #ruby
[21:04:08] guacamole: has joined #ruby
[21:04:31] lesce: has joined #ruby
[21:07:31] sidx64: has joined #ruby
[21:08:07] eckhardt: has joined #ruby
[21:09:18] mtkd: has joined #ruby
[21:11:45] cthulchu_: has joined #ruby
[21:12:58] vutral|kali: has joined #ruby
[21:12:58] vutral|kali: has joined #ruby
[21:18:36] sumobob: has joined #ruby
[21:19:50] darkhanb: has joined #ruby
[21:20:23] sammi`_: has joined #ruby
[21:21:06] lesce: has joined #ruby
[21:21:10] bmurt: has joined #ruby
[21:22:02] SeepingN: has joined #ruby
[21:29:32] mistergibson: has joined #ruby
[21:30:31] AgentVenom: has joined #ruby
[21:31:06] eckhardt: has joined #ruby
[21:31:30] sanscoeur: has joined #ruby
[21:32:22] Cope: has joined #ruby
[21:32:22] jenrzzz: has joined #ruby
[21:32:23] jenrzzz: has joined #ruby
[21:32:30] pastorinni: has joined #ruby
[21:32:36] workmad3: has joined #ruby
[21:34:44] tAn: has joined #ruby
[21:36:32] cdg_: has joined #ruby
[21:39:09] eckhardt_: has joined #ruby
[21:40:12] lesce: has joined #ruby
[21:40:36] gary: has joined #ruby
[21:40:51] synthroid: has joined #ruby
[21:41:43] AndBobsYourUncle: has joined #ruby
[21:42:52] mikecmpbll: has joined #ruby
[21:43:03] riotjones: has joined #ruby
[21:44:43] milardovich: has joined #ruby
[21:45:06] willmichael: has joined #ruby
[21:45:09] jenrzzz: has joined #ruby
[21:45:09] jenrzzz: has joined #ruby
[21:46:46] banisterfiend: has joined #ruby
[21:47:05] workmad3: has joined #ruby
[21:47:05] willmichael: has joined #ruby
[21:47:55] willmichael: has joined #ruby
[21:48:20] willmichael: has joined #ruby
[21:48:21] jeffreylevesque: has joined #ruby
[21:50:38] sumobob: has joined #ruby
[21:55:55] lesce: has joined #ruby
[21:57:25] Cope_: has joined #ruby
[21:57:35] garyserj: has joined #ruby
[21:58:47] ledestin: has joined #ruby
[21:59:51] garyserj: is it true that in ruby, a class is a constant, or is that rubbish? somebody told me that a class is a constant. I also found a book on google books that says "in ruby, a class is an object. The name of a class is a constant that points to an object"
[22:02:08] jenrzzz_: has joined #ruby
[22:04:02] apeiros: garyserj: a class is not a constant, it's an object. but almost all classes are referenced by a constant.
[22:04:48] apeiros: >> defined? Array
[22:04:49] ruby[bot]: apeiros: # => "constant" (https://eval.in/959832)
[22:04:58] apeiros: >> Array.is_a?(Object)
[22:05:00] ruby[bot]: apeiros: # => true (https://eval.in/959833)
[22:05:43] apeiros: you're however not required to have a class be referenced by a constant:
[22:06:06] apeiros: >> my_foo = Class.new do def say_hi; "hi there!"; end; end; my_foo.new.say_hi
[22:06:07] ruby[bot]: apeiros: # => "hi there!" (https://eval.in/959834)
[22:06:23] apeiros: >> my_foo = Class.new do def say_hi; "hi there!"; end; end; my_foo.is_a?(Class)
[22:06:25] ruby[bot]: apeiros: # => true (https://eval.in/959835)
[22:06:47] apeiros: garyserj: does that answer your question?
[22:07:18] garyserj: i'll have to note down what you're saying and think about it, to fully understand it, but yes.
[22:07:20] hahuang65: has joined #ruby
[22:07:32] garyserj: I can't see how a class can be a constant anyway so if you says it's not, that's fine!
[22:07:50] apeiros: constants are a type of variable
[22:08:00] apeiros: variables and objects don't mix. they are different categories of things.
[22:08:10] apeiros: variables reference objects. they themselves aren't objects.
[22:08:51] apeiros: Constant, $global, @instance, @@class, local - those are the 5 types of variables ruby provides. all of them can reference objects.
[22:09:33] apeiros: however, you don't need variables to have objects. take this code: `"hello".upcase` - no variable in there. the string "hello" is called a literal, because it's literally in the code.
[22:10:50] garyserj: is it possible that a class name is a constant?
[22:11:06] garyserj: i know you can't change a class name
[22:11:30] apeiros: colloquially speaking, yes. i.e. if you mean by that "using a constant to reference a class". most classes are that way, and the `class Foo` syntax only works that way.
[22:12:06] apeiros: being pedantic, I'd say the class name is a string, as that's what Class#name returns. and it may or may not be related to the constant used to reference the class.
[22:12:28] apeiros: e.g. `Array` is a constant referencing the core Array class.
[22:12:47] garyserj: apeiros: ok so that's the case with Ruby, is it the case with other languages like C# or Java?
[22:12:57] apeiros: other languages work differently.
[22:12:59] garyserj: 'cos i've never run into that in C# or Java.. it seems peculiar to Ruby.
[22:13:19] apeiros: and I think neither in C# nor Java are classes objects
[22:13:24] garyserj: that's right
[22:13:51] apeiros: classes being objects makes a lot of things pretty easy, though. it means you can pass them around like anything else.
[22:14:01] weaksauce: can you monkeypatch in those languages?
[22:14:09] apeiros: >> def create_instance(from_class); from_class.new; end; create_instance(Array)
[22:14:10] ruby[bot]: apeiros: # => [] (https://eval.in/959836)
[22:15:10] garyserj: is there any method I can call on Array that proves that Array is a constant referencing a class, and not the class itself?
[22:15:24] garyserj: or is there any method that I can pass Array to that proves that ARray is a constant referencing a class and not the class itself?
[22:15:47] apeiros: garyserj: objects do not know which variables reference them. if you think about it, that wouldn't make much sense.
[22:16:11] jenrzzz: has joined #ruby
[22:16:12] jenrzzz: has joined #ruby
[22:16:12] garyserj: okay so forget calling a method on Array to show it
[22:16:13] apeiros: and it makes no sense either to query whether Array is a constant. you *know* from the code you've written.
[22:16:16] garyserj: but how about when passing Array to a method?
[22:16:27] garyserj: can the method show me that Array is a constant?
[22:16:31] apeiros: what makes sense is querying an object whether it is a class
[22:16:36] apeiros: >> Array.is_a?(Class)
[22:16:37] ruby[bot]: apeiros: # => true (https://eval.in/959837)
[22:16:40] apeiros: >> Array.class
[22:16:48] garyserj: yes I can accept that the object is a class
[22:16:52] ruby[bot]: apeiros: # => Class (https://eval.in/959838)
[22:16:57] garyserj: What I want is some proof in the language, that Array is a constant
[22:17:02] timmow: has joined #ruby
[22:17:10] apeiros: that makes no sense
[22:17:28] apeiros: it's a syntax rule that constants start with an uppercase letter.
[22:17:43] apeiros: so if you read/write code you *see* it. there's no point in asking the language.
[22:18:03] apeiros: >> defined? Array # you can still do that. but as said, it makes no sense in the context you're asking
[22:18:04] garyserj: is it a constant identifier?
[22:18:05] ruby[bot]: apeiros: # => "constant" (https://eval.in/959839)
[22:18:25] apeiros: 23:07 apeiros: constants are a type of variable
[22:18:39] gary: has joined #ruby
[22:18:44] garyserj: identifier is the general term. an identifier can be a constant or a variable.
[22:18:50] garyserj: in computer science anyway, afaik.
[22:19:00] s2013: has joined #ruby
[22:19:01] apeiros: identifier is a vague term meaning wildly different things to different people.
[22:19:18] garyserj: can you give me an example? i've never heard it used differently to how i've known it to be used.
[22:20:01] apeiros: tell me what kinds of identifiers you know in ruby
[22:20:14] garyserj: I don't know ruby well enough but I could give you example in a language like c#
[22:20:33] apeiros: so there it starts already…
[22:20:40] garyserj: what do you mean?
[22:21:13] garyserj: even compilers use the term identifier. like "unknown identifier".
[22:21:21] garyserj: which i think pascal would say.
[22:21:22] apeiros: ok. yes, constants are identifiers.
[22:21:34] jenrzzz: has joined #ruby
[22:26:53] jeffreylevesque: is `make` a ruby command?
[22:27:19] WA9ACE: make a build tool
[22:27:24] WA9ACE: not specific to ruby
[22:27:30] WA9ACE: it's been around probably twice as long as ruby has
[22:27:31] jeffreylevesque: what do i need to install to have `make build`
[22:27:36] WA9ACE: what platform?
[22:27:45] jeffreylevesque: but, i want to generalize it
[22:27:50] jeffreylevesque: so it can be run on linux too
[22:28:01] jeffreylevesque: i'm writing a script to install rancher-compose
[22:28:51] garyserj: What is the difference between the object Array, and the object Array.new ?
[22:28:53] WA9ACE: sorry, last time I did Ruby on Windows that wasn't under the WSL it was absolute hell
[22:28:55] jeffreylevesque: ah ok i think linux already has `make`?
[22:29:08] jeffreylevesque: so, i just need a workaround for windows
[22:29:14] WA9ACE: jeffreylevesque it depends
[22:29:28] guacamole: has joined #ruby
[22:29:28] guacamole: has joined #ruby
[22:29:28] WA9ACE: some debian platforms you'll need to do `sudo apt install build-essentials` or similar
[22:29:30] garyserj: jeffreylevesque: cygwin would very likely have 'make'
[22:29:46] garyserj: but you'd need linux and maybe 'c' skills to use make.
[22:29:52] WA9ACE: with Fedora it's `sudo dnf groupinstall "C Development Tools and Libraries"
[22:29:54] garyserj: linux=linux skills
[22:29:55] apeiros: garyserj: Array is the class, Array.new is an instance of that class, an actual Array
[22:29:56] jeffreylevesque: if install cygwin, so i have to use a special shell terminal window to use the command?
[22:30:28] garyserj: jeffreylevesque: perhaps you won't have to. The vast majority of cygwin commands maybe all even, I can use from regular cmd
[22:30:35] jenrzzz: has joined #ruby
[22:30:35] jenrzzz: has joined #ruby
[22:30:59] garyserj: jeffreylevesque: If they have an EXE extension they work outside of cygwin. Very few commands you can run from the cygwin shell don't have an EXE extension
[22:31:47] garyserj: for example ssh.exe can run from outside cygwin shell not just inside cygwin shell.. but a weird case, one of the view commands that only runs inside the cygwin shell and not outside of it, is ssh-copy-id which notably has no exe extension!
[22:31:57] dogweather: has joined #ruby
[22:32:05] jeffreylevesque: i'm installing cygwin
[22:32:17] jeffreylevesque: i hope that doesn't mean i have to run their special shell window
[22:32:24] garyserj: i told you it doesn't
[22:32:37] garyserj: but if you do you'll have access to bash.
[22:33:09] garyserj: of course, if you want to use their commands from cmd.exe then make sure c:\cygwin\bin and wherever it installs its commands, is in your path.
[22:33:54] garyserj: apeiros: So a class is an object, and an instance of a class is an object?
[22:34:49] apeiros: but classes are the only type of objects which can create instances. modules can have instances by proxy (via including them into a class, and instantiating that class)
[22:36:29] bmurt: has joined #ruby
[22:36:37] jolamb: has left #ruby: ("WeeChat 1.9.1")
[22:46:47] goatish: has joined #ruby
[22:50:28] orbyt_: has joined #ruby
[22:50:56] gary_: has joined #ruby
[22:51:49] cthulchu_: has joined #ruby
[22:53:21] jnyw: has joined #ruby
[22:53:43] suhdood: has joined #ruby
[22:54:12] garyserj: So can is there some objectid that I can see within the Array class name?
[22:55:01] garyserj: constants and variables, have a value, right?
[22:55:14] vutral|kali: has joined #ruby
[22:55:14] vutral|kali: has joined #ruby
[22:55:23] garyserj: and if that value is a reference to an object, then I want to see that reference.
[22:55:59] Psybur: has joined #ruby
[22:55:59] Psybur: has joined #ruby
[22:56:43] jenrzzz: has joined #ruby
[22:56:43] jenrzzz: has joined #ruby
[22:57:58] garyserj: also.. so ok, a class is an object. and the name of a class is a constant. Is it true that the name of a class, is not an object? And is it true that a constant is not an object?
[23:01:56] dminuoso: garyserj: Names of classes are not constants
[23:02:11] dminuoso: garyserj: It's rather that a constant can hold an object (reference)
[23:02:26] dminuoso: class Foo; end; is roughtly equivalent to: Foo = Class.new
[23:02:29] ecuanaso: has joined #ruby
[23:02:53] dminuoso: Which means you can place a class object into anything.
[23:02:59] dminuoso: >> a = Class.new; p a
[23:03:00] ruby[bot]: dminuoso: # => #<Class:0x41741c24> ...check link for more (https://eval.in/959844)
[23:03:26] weaksauce: garyserj when you create a class with class Foo it's just running code to create an object that is the class template. you can attach methods to that class object with def or self.something. you can also call arbitrary code inside class(which is how rails works a lot of the magic.)
[23:03:32] dminuoso: garyserj: and constants are indeed not objects
[23:03:42] weaksauce: >> class Foo; puts "hello"; end
[23:03:43] ruby[bot]: weaksauce: # => hello ...check link for more (https://eval.in/959845)
[23:04:03] dminuoso: garyserj: As for the last question: Ruby maintains a constant table in each class/module object
[23:04:08] dminuoso: they are basically like instance variables
[23:04:12] dminuoso: but a bit more exposed
[23:04:47] dminuoso: weaksauce: you cant attack methods to objects.
[23:05:37] weaksauce: sure you can. singleton methods
[23:05:44] dminuoso: weaksauce: they are still regular methods.
[23:05:56] dminuoso: weaksauce: it's just that the class they are defined on is a different one.
[23:06:35] dminuoso: def a.foo; ... end can basically be rewitten as: a.singleton_class.send(:define_method, :foo) { ... }
[23:07:13] dminuoso: weaksauce: Likewise `class <<` opens a singelton class for anything, and sets it as the default definee
[23:07:15] dminuoso: which is why
[23:07:23] dminuoso: class << a; def foo; end; end
[23:07:23] cdg: has joined #ruby
[23:07:31] dminuoso: def a.foo; end;
[23:07:33] dminuoso: are the same thing
[23:08:39] cthulchu: has joined #ruby
[23:09:14] kapil___: has joined #ruby
[23:09:24] guacamole: has joined #ruby
[23:09:24] guacamole: has joined #ruby
[23:09:30] jeffreylevesque: has joined #ruby
[23:11:31] Azure: has joined #ruby
[23:11:58] garyserj: dminuoso: well if a class name isn't a constant then there's no mystery there 'cos ruby is the same as c# in that regard
[23:12:01] garyserj: so that's good
[23:12:35] dminuoso: garyserj: its just that the class builder syntax `class Foo; ...; end` only functions with constants (and it adds slightly different semantics than what I wrote).
[23:12:47] garyserj: apeiros did write "<apeiros> e.g. `Array` is a constant referencing the core Array class."
[23:12:57] dminuoso: garyserj: Yup. It lies inside Object.
[23:13:07] dminuoso: So Array is actually short for Object::Array
[23:13:28] dminuoso: (Since if you remember, constants reside in modules/classes. all of them)
[23:13:37] dminuoso: constants cant exist anywhere else.
[23:13:57] duleja_: has joined #ruby
[23:13:59] garyserj: So is 'Array' a constant, or a Class?
[23:14:09] dminuoso: It's foremost a constant.
[23:14:18] garyserj: So are you saying it's both?
[23:14:20] dminuoso: garyserj: Whether it actually is a class depends on whether someone was naughty and redefined it.
[23:14:28] garyserj: assuming they didn't redefine it then
[23:14:28] dminuoso: 00:12 garyserj | apeiros did write "<apeiros> e.g. `Array` is a constant referencing the core Array class."
[23:14:43] garyserj: so it IS a constant
[23:14:56] dminuoso: Array is a constant that references the core Array class.
[23:15:12] Guest_: has joined #ruby
[23:15:14] dminuoso: But neither do classes have to be referred to constants, nor do all constants reference classes.
[23:15:22] dminuoso: But neither do classes have to be referred to by constants, nor do all constants reference classes.
[23:15:38] garyserj: If I say class Abc {......} Then is Abc a constant?
[23:16:01] Guest_: hi dminuoso can i ask simple question about ruby here? I tried to post 2 minutes ago as different name though
[23:16:55] dminuoso: guest_: Sure.
[23:16:58] Guest_: i would like to know how can i use only strings when initializing objects ini ruby. So lets say i create a custom class and i want to pass only strings in the initialize method so if a fixnum is passed i do not want this object to be created
[23:17:01] dminuoso: garyserj: Yes.
[23:17:11] garyserj: dminuoso: and is Abc a class name?
[23:17:25] Guest_: I am not sure how can i define what types initialize method will receive?
[23:17:27] dminuoso: garyserj: Abc becomes a constant inside Object that happens to refer to a newly created class object.
[23:17:45] dminuoso: guest_: And also Ruby baptizes the object, so that it happens to have the name :Abc
[23:17:53] sanscoeur: has joined #ruby
[23:18:09] garyserj: dminuoso: OK but is Abc a class name if I do class Abc {}?
[23:18:18] dminuoso: garyserj: Ruby has no concept of class names.
[23:18:26] sumobob: has joined #ruby
[23:18:37] garyserj: So is it wrong to say Abc is the name of a class?
[23:18:48] dminuoso: garyserj: Depends on your perspective really.
[23:18:48] garyserj: if i've done class Abc { }
[23:19:03] dminuoso: garyserj: I dont like it because its technically irrelevant.
[23:19:14] vutral|kali: has joined #ruby
[23:19:14] vutral|kali: has joined #ruby
[23:19:19] garyserj: well, you said Names of classes are not constants.
[23:19:19] dminuoso: garyserj: Abs is a constant that refers to a class that identifies itself as :Abs
[23:19:23] Guest_: thank you for the answer dminuoso but i am not sure that I am following you
[23:19:40] dminuoso: guest_: Dont mind me, misttabbed
[23:20:09] dminuoso: guest_: usually dont you dont inspect types in ruby because.. well reasons.
[23:20:22] Guest_: yes i know
[23:20:25] Guest_: that is why i am here :)
[23:20:32] Cope: has joined #ruby
[23:20:42] dminuoso: 00:17 guest_ | I am not sure how can i define what types initialize method will receive?
[23:20:47] dminuoso: Welcome to singly typed languages.
[23:20:59] dminuoso: There are some tricks you can do
[23:21:04] Guest_: i wanted to see if there is a way to do this? So to just limit constructor to use strings?
[23:21:49] Guest_: I would know how to do this in Java though...
[23:22:07] dminuoso: guest_: Like I said, Ruby is singly typed.
[23:22:42] dminuoso: Testing for string explicitly is kind of a lie since strictly speaking anyone can violate it by monkey patching String, or they can fit it by satisfying your interface.
[23:22:48] RougeR: has joined #ruby
[23:22:56] Guest_: i follow you
[23:23:23] Guest_: i just want to see if i can limit initialize to use certain types
[23:23:33] Guest_: but it seems that in ruby you can't do this
[23:24:05] dminuoso: guest_: You can but its considered non idiomatic. Ruby folks are not big fans of types and decide to rigorously test type correctness in tests by testing every code path in their programs.
[23:24:11] Guest_: you can check before initialize method i guess but I wanted to know if i can just do this check in the initialize method itself
[23:24:15] dminuoso: Or they forego tests and have brittle software.
[23:24:32] eam: guest_: you can do any check you like and raise ArgumentError
[23:25:05] instrud: has joined #ruby
[23:25:15] Guest_: i just wish to check if lets say i do this User.new("something") that if "something" is not a string, do not create an object
[23:25:29] Guest_: can i do this check in initialize method in User class?
[23:25:30] dminuoso: guest_: well you can simply raise an exception
[23:25:45] Guest_: but object will be created? no?
[23:25:47] dminuoso: guest_: Yeah. you cant directly block the object creation though.
[23:26:00] dminuoso: guest_: yes because by the time initialize is called the object has already been constructed on the heap
[23:26:01] eam: you can raise before the object is returned to the caller
[23:26:17] eam: I suspect this is what he's really after
[23:26:17] dminuoso: oh yeah that should kill the object
[23:26:27] dminuoso: eam: what he's really after is a sound type system
[23:26:31] eam: well :D
[23:26:41] Guest_: sound type system?
[23:26:48] dminuoso: *a type system
[23:26:50] eam: class Audio
[23:27:22] Guest_: i am not sure how i can forbid object from creating if type is not string
[23:27:32] dminuoso: guest_: just throw in the initialize method
[23:27:34] Guest_: can you give some example of initialize method in this case?
[23:27:40] dminuoso: and by throw I mean raise.
[23:27:48] dminuoso: but I guess in the end they are the same thing.
[23:28:18] eam: guest_: consider: def initialize(arg); raise unless arg.respond_to? :to_str
[23:28:58] dminuoso: class ILoveEam; def to_str; raise "funny error"; end; end
[23:29:09] eam: or raise ArgumentError.new("arg must be stringy")
[23:29:33] zkv: has joined #ruby
[23:29:34] gary: has joined #ruby
[23:29:39] dminuoso: curiously no matter how much you restrict me - if need be Ill unpack fiddle to bypass all your checks!
[23:29:41] eckhardt: has joined #ruby
[23:29:56] dminuoso: eam: tell me
[23:30:07] eam: hey, input validation is a good idea limits notwithstanding
[23:30:08] dminuoso: does baweaver do puns in reallife too all day long?
[23:30:08] Guest_: you rock sir
[23:30:15] eam: dminuoso: oh god yes
[23:31:39] eam: guest_: a distinction here is using duck typing (has :to_str) vs class inheritance since it's more ruby-ish. You're concerned if the object knows how to become a String more than if the object is actually a String
[23:32:27] Guest_: why i just never thought to raise and exception?
[23:32:29] Guest_: so simple...
[23:32:49] jenrzzz: has joined #ruby
[23:32:49] jenrzzz: has joined #ruby
[23:33:04] milardovich: has joined #ruby
[23:33:42] Guest_: I wish you guys all best! thanks for this
[23:34:03] Guest_: feeling shamed not to think something as easy as this by myself though... hah i must go to sleep
[23:36:04] eam: ACTION glances at the clock, can't sleep yet ...
[23:38:08] chouhoulis: has joined #ruby
[23:38:12] dminuoso: eam: Although one doesnt have to exclude the other.
[23:38:14] karapetyan: has joined #ruby
[23:38:29] dminuoso: If you test for .is_a? Enumerable, then thats a much stronger condition than testing for .responds_to? :each
[23:38:45] dminuoso: Because responding to .each but not being Enumerable has a high chance of being unlawful
[23:38:53] dminuoso: Or doing somenthing really funky
[23:39:35] vutral|kali: has joined #ruby
[23:39:43] vutral|kali: has joined #ruby
[23:40:24] s3nd1v0g1us: has joined #ruby
[23:40:41] eam: true - but that's a bit different since Enumerable is a mixin and likely to be used for iterators. Most objects which know how to become String aren't inherited from String
[23:40:49] s3nd1v0g1us: has joined #ruby
[23:41:02] eam: a time and a place for every approach I suppose
[23:41:19] s3nd1v0g1us: has joined #ruby
[23:41:35] Psybur_: has joined #ruby
[23:42:23] eam: I suppose to_s vs to_str complicates things, I'm mostly thinking of allowing to_s in that case
[23:43:05] xelkarin: has joined #ruby
[23:47:49] nowhere_man: has joined #ruby
[23:47:50] eckhardt: has joined #ruby
[23:48:48] milardovich: has joined #ruby
[23:49:06] eckhardt_: has joined #ruby
[23:50:09] s2013: has joined #ruby
[23:56:21] karapetyan: has joined #ruby
[23:59:10] bijan_: has joined #ruby