« Back to channel list

#ruby - 07 August 2019

« Back 1 day Forward 1 day »
[00:02:09] cako: has joined #ruby
[00:03:38] RetroPunk: has joined #ruby
[00:04:11] jenrzzz: has joined #ruby
[00:10:36] shtirlic: has joined #ruby
[00:44:24] cako: has joined #ruby
[00:45:30] zapata: has joined #ruby
[00:54:22] RetroPunk: hey all, if i wanted to make a new codebase for a current gem could i just make a new gem template (bundle gem) and copy over the gemspec file?
[00:55:29] havenwood: RetroPunk: You'd not be preserving much of the gem.
[00:55:50] havenwood: RetroPunk: What do you mean by new codebase? You're replacing ALL the code?
[00:55:58] RetroPunk: yeah, start from scratch
[00:56:00] havenwood: RetroPunk: Why preserve anything?
[00:56:07] havenwood: RetroPunk: Just start with a fresh folder.
[00:56:27] RetroPunk: and just name it the same?
[00:56:34] havenwood: RetroPunk: I personally like the exercise of starting from nothing. That way you won't have anything you don't need.
[00:56:41] havenwood: RetroPunk: Why name it the same?
[00:56:59] havenwood: RetroPunk: It's typically nice to have your gem name be unique.
[00:57:17] havenwood: RetroPunk: Maybe say more about why you're doing what you're doing?
[00:57:17] RetroPunk: because i just started it, i'm very new to Ruby and have noticed a lot of things i could do better, i'd like to update my existing gem with a new codebase if that makes sense
[00:57:37] havenwood: RetroPunk: The typical thing you'd do in that case is a major version bump of your gem.
[00:57:54] havenwood: RetroPunk: Release a new version.
[00:58:00] RetroPunk: definitely yeah, that's the plan. i just am trying to figure out the best practice for doing this
[00:58:17] havenwood: RetroPunk: Use git, update the things, release the new version.
[00:58:30] havenwood: RetroPunk: I like to tag the commit for the version release too, and push that to GitHub.
[00:58:47] RetroPunk: yeah i'm using GitLab right now for the project
[00:58:56] havenwood: RetroPunk: same steps there
[00:59:05] havenwood: RetroPunk: make your updates, push to GitLab, release gem
[00:59:33] havenwood: RetroPunk: If you don't want to think about those steps, consider using the gem-release gem: https://github.com/svenfuchs/gem-release#gem-release
[00:59:47] havenwood: RetroPunk: You can just: gem release --tag --push
[01:00:33] havenwood: RetroPunk: https://guides.rubygems.org/patterns/#semantic-versioning
[01:00:35] RetroPunk: yeah i understand that, i just want to make sure i do it right. i'm familiar with all the git steps. but, for example, i will be changing the folder name under the lib/ directory in the gem and the require statements would change as well
[01:00:43] havenwood: RetroPunk: https://semver.org/
[01:00:58] havenwood: RetroPunk: Yes, make all changes required for your new gem version.
[01:01:47] havenwood: RetroPunk: For example, here's a gem spike, then I released a major version bump due to a breaking change: https://github.com/havenwood/sha3-pure-ruby
[01:01:59] havenwood: RetroPunk: Note the tagged releases: https://github.com/havenwood/sha3-pure-ruby/releases
[01:02:59] havenwood: RetroPunk: You just make the commits to reflect your changes, then when you're done, tag the release and cut the gem version.
[01:03:22] RetroPunk: yeah i totally understand all that and sem ver, my question is more Ruby/bundle specific. if i create a NEW folder with bundle gem, could i push to rubygems.org on a current project?
[01:03:42] havenwood: RetroPunk: Have you already released your gem?
[01:04:17] havenwood: RetroPunk: To release a new version, you make your changes, then push the new gem version to RubyGems.
[01:05:18] havenwood: RetroPunk: For example, if I wanted to make a change, say move a file in that gem above ^ - I can make that change, bump the gem version, commit those changes to git, then: gem release --tag --push
[01:05:25] RetroPunk: but can i do this from a new folder? say i want to delete everything i currently have and start completely new, what would be the steps in the new gem directory for linking it with the current gem on rubygems.org? would it just be the same process as before?
[01:05:57] havenwood: RetroPunk: Normally you don't regenerate from scratch, you just make your changes. But you can do it however you want.
[01:06:40] RetroPunk: alright, maybe i won't regenerate then. i just wanted a completely clean start is all. i could probably finagle something
[01:06:40] havenwood: RetroPunk: If you want, start with a blank gemspec, add your gem name and new version and start from there.
[01:06:54] havenwood: RetroPunk: It's totally up to you. RubyGems doesn't care about anything but the code you push.
[01:07:12] havenwood: RetroPunk: The process you use to get there doesn't matter.
[01:07:15] RetroPunk: got ya. ok thank you very much for the help havenwood :)
[01:07:34] havenwood: RetroPunk: No prob! Have a good time gem cutting!
[01:19:36] cako: has joined #ruby
[01:22:49] bmurt: has joined #ruby
[01:25:45] SeepingN: has joined #ruby
[01:38:08] poontangmessiah: has joined #ruby
[01:39:38] involans: has joined #ruby
[01:43:18] AJA4350: has joined #ruby
[01:44:21] henninb: has joined #ruby
[01:45:42] bmurt: has joined #ruby
[01:46:19] m27frogy: has joined #ruby
[01:51:41] fphilipe: has joined #ruby
[02:08:45] ascarter: has joined #ruby
[02:11:25] tsrt^: has joined #ruby
[02:15:35] hc^: has joined #ruby
[02:16:13] hutch: has joined #ruby
[02:19:23] poontangmessiah: has joined #ruby
[02:20:56] poontangmessiah: has joined #ruby
[02:21:12] ecr^: has joined #ruby
[02:22:13] poontangmessiah: has joined #ruby
[02:23:34] poontangmessiah: has joined #ruby
[02:24:57] fredolinhares: has joined #ruby
[02:51:32] cliluw: has joined #ruby
[03:03:11] unixcat: has joined #ruby
[03:08:06] polishdub: has joined #ruby
[03:33:52] kyrylo: has joined #ruby
[03:35:32] kyrylo: has joined #ruby
[03:45:00] jenrzzz: has joined #ruby
[03:52:38] fphilipe: has joined #ruby
[03:57:37] hutch: has joined #ruby
[04:08:24] hutch: has joined #ruby
[04:08:56] jenrzzz: has joined #ruby
[04:09:32] kyrylo: has joined #ruby
[04:19:12] kyrylo: has joined #ruby
[04:32:30] tdy: has joined #ruby
[04:47:29] fphilipe: has joined #ruby
[04:54:43] jenrzzz: has joined #ruby
[05:31:32] kyrylo: has joined #ruby
[05:31:39] nhk^: has left #ruby: ()
[05:34:14] nehth^: has joined #ruby
[05:34:21] yummycouple: has joined #ruby
[05:37:22] yummycouple: minepi.com/thatbadmonster
[05:40:31] srt^: has joined #ruby
[05:41:21] havenwood: ?spam yummycouple
[05:41:21] ruby[bot]: havenwood: I don't see no yummycouple, whom should I tell about spam?
[05:41:32] havenwood: !spam yummycouple
[05:41:32] ruby[bot]: +bb yummycouple!*@*$#ruby-banned *!*@2607:fb90:3273:ac0f:7dc4:9106:7ab1:5dfb$#ruby-banned
[05:44:07] kyrylo: has joined #ruby
[05:49:40] igh^: has joined #ruby
[05:50:59] code_zombie: has joined #ruby
[06:01:44] fphilipe: has joined #ruby
[06:02:26] kyrylo: has joined #ruby
[06:07:33] tsujp: has joined #ruby
[06:07:52] tsujp: Hey guys, I'm trying to understand this repo, where is the entry point for this app? https://github.com/Paymium/gekko
[06:09:11] kyrylo: has joined #ruby
[06:10:01] sgh^^: has joined #ruby
[06:18:07] dellavg: has joined #ruby
[06:19:06] ramfjord: has joined #ruby
[06:19:46] havenwood: tsujp: Since there aren't docs or examples, your best best is probably to look at the specs: https://github.com/Paymium/gekko/blob/master/spec/gekko/book_spec.rb
[06:29:22] tsujp: Lovely, I'll need to refresh some Ruby and then I shall get into that
[06:30:05] tsujp: What should I do for type safety in Ruby? That is floating point operations. If I was using Javascript I'd use BigNumber or Typescript, if I was in C I'd have access to data types as it's statically-typed
[06:31:33] suukim: has joined #ruby
[06:35:25] code_zombie: has joined #ruby
[06:35:57] kyrylo: has joined #ruby
[06:38:54] kyrylo: has joined #ruby
[06:40:26] user12: has joined #ruby
[06:41:07] user12: how much ram is needed for redmine?
[06:42:37] havenwood: tsujp: An Integer is backed by Fixnum and Bignum under the hood with auto-promotion so you don't have to worry about it.
[06:42:52] havenwood: tsujp: Floats are plain old double-precision floats.
[06:43:07] havenwood: tsujp: Then BigDecimal and Rational.
[06:43:25] tsujp: If I was doing financial calculations I might use BigDecimal then
[06:43:32] havenwood: tsujp: BigDecimal is arbitrary precision floats.
[06:43:49] tsujp: Not even floats are usually precise enough for that, I think I remember using `double` whenever I did things in C that involved money
[06:44:07] havenwood: &>> require 'bigdecimal'; require 'bigdecimal/util'; '3.14'.to_d
[06:44:11] rubydoc: # => 0.314e1 (https://carc.in/#/r/7d6a)
[06:44:46] havenwood: tsujp: Or a Rational:
[06:44:49] rubydoc: # => (157/50) (https://carc.in/#/r/7d6b)
[06:44:59] _joes_: has joined #ruby
[06:45:23] rubydoc: # => (1/2) (https://carc.in/#/r/7d6c)
[06:46:53] lxsameer: has joined #ruby
[06:48:44] havenwood: I was just looking at a Python implementation of Posits and Quires, thinking of porting it to Ruby. https://github.com/mightymercado/PySigmoid
[06:49:35] havenwood: https://posithub.org/docs/Posits4.pdf
[06:50:17] pascal: has joined #ruby
[06:52:06] havenwood: I don't quite grok it yet, and it's a bunch of Python, so may or may not attempt.
[06:53:08] havenwood: Maybe someone else will do it. :)
[06:57:41] RetroPunk: hello again. having a strange issue. i am trying to create a new class within a module and include it in my main file but i'm getting an error: ./tracklist:38:in `<main>': uninitialized constant Tracklist::TrackParser (NameError)
[06:57:53] Intelo: can we just use rails internal server to run redmine instead of ngnix or apache
[06:58:01] TomyWork: has joined #ruby
[06:58:06] RetroPunk: here is the file that i am trying to include/instantiate: https://gitlab.com/DomenicF/ruby-tracklist/blob/TrackParser/lib/tracklist/track_parser.rb
[06:58:25] RetroPunk: here is where i am including it: https://gitlab.com/DomenicF/ruby-tracklist/blob/TrackParser/lib/tracklist.rb#L2
[06:58:49] RetroPunk: and i am trying to instantiate it here: https://gitlab.com/DomenicF/ruby-tracklist/blob/TrackParser/bin/tracklist
[06:59:38] jenrzzz: has joined #ruby
[07:00:15] kyrylo: has joined #ruby
[07:03:58] tsujp: has joined #ruby
[07:04:44] ytti: TIL: unum, about time we have competing real/float solution
[07:05:53] tpanarch1st: has joined #ruby
[07:10:19] prestorium: has joined #ruby
[07:12:45] tsujp: What is `unum`? I cannot find it in dash ruby2 docs
[07:14:54] za1b1tsu: has joined #ruby
[07:15:17] fphilipe: has joined #ruby
[07:20:11] aupadhye: has joined #ruby
[07:24:00] uid9164: has joined #ruby
[07:24:39] ytti: tsujp, https://en.wikipedia.org/wiki/Unum_(number_format)
[07:24:44] ytti: tsujp, 09:49 < havenwood> https://posithub.org/docs/Posits4.pdf
[07:26:37] suukim: has joined #ruby
[07:27:13] uid9164: has left #ruby: ("Leaving")
[07:29:26] user12: has joined #ruby
[07:36:33] user111: has joined #ruby
[07:46:09] deepredsky: has joined #ruby
[07:46:14] Renich: has joined #ruby
[07:51:38] jmcgnh: has joined #ruby
[08:05:46] mikecmpbll: has joined #ruby
[08:08:12] Sylario: has joined #ruby
[08:11:11] Intelo: https://pastebin.ubuntu.com/p/CSTzMRcJcg/
[08:11:16] Intelo: cannot use rvm
[08:13:13] ellcs: has joined #ruby
[08:15:52] ytti: Intelo, i would propose to read the single bullet point the output has
[08:17:12] Intelo: solved by https://stackoverflow.com/a/41573315
[08:18:15] ytti: you already ddi 1 and 2
[08:18:21] ytti: and 3 was written on the output, which you were msising
[08:19:19] ramfjord: has joined #ruby
[08:24:54] lord4163: has joined #ruby
[08:25:12] hcs^: has joined #ruby
[08:36:26] tpanarch1st: has joined #ruby
[08:36:50] mikecmpbll: has joined #ruby
[08:37:39] ua_: has joined #ruby
[08:41:45] ellcs: has joined #ruby
[08:43:27] kyrylo: has joined #ruby
[08:43:27] tuor: has joined #ruby
[08:44:13] za1b1tsu: has joined #ruby
[09:09:15] bruce_lee: has joined #ruby
[09:09:15] bruce_lee: has joined #ruby
[09:09:21] kyrylo: has joined #ruby
[09:09:27] Xiti: has joined #ruby
[09:18:06] Guest20366: has joined #ruby
[09:19:56] drnerdius: has joined #ruby
[09:34:43] algun: has joined #ruby
[09:54:46] tuor: has joined #ruby
[09:54:46] tuor: has joined #ruby
[09:59:48] nerdius: has joined #ruby
[10:02:08] SuperL4g: has joined #ruby
[10:03:37] Nicmavr: has joined #ruby
[10:07:26] nerdius: has joined #ruby
[10:08:50] nerdius: has joined #ruby
[10:13:44] BlueCookie: has joined #ruby
[10:19:35] ramfjord: has joined #ruby
[10:22:00] AJA4350: has joined #ruby
[10:40:48] zapata: has joined #ruby
[10:50:16] chalkmonster: has joined #ruby
[10:55:03] ramfjord: has joined #ruby
[11:29:06] CrazyEddy: has joined #ruby
[11:35:39] AJA4350: has joined #ruby
[11:44:59] chalkmonster: has joined #ruby
[11:48:38] prestorium: has joined #ruby
[12:00:14] za1b1tsu: has joined #ruby
[12:00:30] tim17d: has joined #ruby
[12:05:43] Swyper: has joined #ruby
[12:16:16] stryek: has joined #ruby
[12:25:37] RougeRR: has joined #ruby
[12:26:01] RougeRR: i trying to get ruby debugging working in vs code
[12:26:10] RougeRR: our application uses rackup/sinatra/puma
[12:26:18] RougeRR: im trying to follow the guide here: https://stackoverflow.com/questions/51722136/how-do-you-run-and-debug-ruby-on-rails-from-visual-studio-code
[12:26:24] RougeRR: well..answers here
[12:26:34] RougeRR: but i dont understand what should go in the program section
[12:26:42] RougeRR: is it the result of gem which rack
[12:26:47] RougeRR: im using rbenv
[12:27:43] GodFather: has joined #ruby
[12:28:28] GodFather_: has joined #ruby
[12:42:16] sh7d_: has joined #ruby
[12:43:08] AJA4351: has joined #ruby
[12:45:53] tsujp: has joined #ruby
[12:53:20] RougeRR: let me chage my question
[12:53:23] RougeRR: where is rack located
[12:53:28] RougeRR: as a program
[12:55:41] ramfjord: has joined #ruby
[12:55:48] lucasb: has joined #ruby
[13:21:51] poontangmessiah: has joined #ruby
[13:24:53] poontangmessiah_: has joined #ruby
[13:39:34] tsujp: has joined #ruby
[13:45:23] AJA4351: has joined #ruby
[13:46:09] bmurt: has joined #ruby
[13:49:54] qbrd[m]: @roguerr `gem which rack` is the location of `rack` green dir. The executable will be in `"${gem which rack}/bin"`
[13:50:17] qbrd[m]: s/green dir/gem dir/
[13:51:58] nerdius: has joined #ruby
[13:56:40] tsujp: has joined #ruby
[13:57:41] Intelo: has joined #ruby
[13:58:06] drincruz: has joined #ruby
[13:59:42] brool: has joined #ruby
[14:01:34] sh7d: has joined #ruby
[14:03:15] drnerdius: has joined #ruby
[14:04:02] cow[moo]: has joined #ruby
[14:09:53] Frem: has joined #ruby
[14:14:29] deepredsky: has joined #ruby
[14:22:40] AJA4351: has joined #ruby
[14:22:45] fphilipe_: has joined #ruby
[14:24:04] kyrylo: has joined #ruby
[14:25:47] deepredsky: has joined #ruby
[14:32:50] involans: has joined #ruby
[14:35:35] tpanarch1st_: has joined #ruby
[14:36:55] greengriminal: has joined #ruby
[14:56:50] AJA4351: has joined #ruby
[15:10:40] chalkmonster: has joined #ruby
[15:14:30] GodFather_: has joined #ruby
[15:14:32] GodFather: has joined #ruby
[15:16:08] sytherax: has joined #ruby
[15:25:21] ascarter: has joined #ruby
[15:25:31] Intelo: has joined #ruby
[15:33:20] yqt: has joined #ruby
[15:33:30] greengriminal: has joined #ruby
[15:35:37] sytherax: has joined #ruby
[15:39:40] sytherax: has joined #ruby
[15:44:50] rippa: has joined #ruby
[15:46:00] za1b1tsu: has joined #ruby
[15:54:40] wildtrees: has joined #ruby
[15:56:09] impermanence: has joined #ruby
[15:56:47] impermanence: 51 15 * * * /bin/ruby /usr/local/bin/cleanup -c /usr/local/bin/cleanup.yaml &> /var/log/cleanup.log || mail -s "ALARM: Host Cleanup Failed on $(hostname -i)" "systems@foo.com" "`hostname -s`<no-reply@mail.foo.com>"
[15:57:03] cow[moo]: has joined #ruby
[15:57:28] impermanence: I am testing a simple email alert via this || I figured that if /usr/local/bin/cleanup exited non zero then || right side would execute
[15:57:33] Swyper: has joined #ruby
[15:57:41] impermanence: this is running in crontab
[15:57:58] ellcs: has joined #ruby
[15:58:01] impermanence: and indeed left side exited !zero
[15:58:57] ellcs: has joined #ruby
[16:04:25] AJA4350: has joined #ruby
[16:04:30] chalkmonster: has joined #ruby
[16:05:20] algun: has joined #ruby
[16:07:41] duderonomy: has joined #ruby
[16:08:38] qbrd[m]: ACTION sent a long message: < https://matrix.org/_matrix/media/v1/download/matrix.org/EsLftSDzEKvvyrnVrjwbtdZN >
[16:13:50] KeyJoo: has joined #ruby
[16:22:43] eok^: has joined #ruby
[16:24:58] tdy: has joined #ruby
[16:26:18] duderonomy: has joined #ruby
[16:26:40] qbrd[m]: ok, I feel dumb...
[16:26:46] qbrd[m]: can someone explain this to me? https://dpaste.de/Uyqb
[16:27:02] qbrd[m]: why does `var1 = 'boz'` work, but `var2 << 'biz'` errors?
[16:27:12] qbrd[m]: shouldn't they both error as we're modifying an immutable string?
[16:27:23] qbrd[m]: or is it only the value that's assigned to `var` that's immutable.
[16:28:17] qbrd[m]: can I `var1.freeze = 'foo'`?
[16:28:21] qbrd[m]: (obviously that doesn't work...)
[16:29:52] adam12: qbrd[m]: I'm not an expert on this, but the value itself is frozen ("bar") but not the reference to it (var2)
[16:30:39] adam12: qbrd[m]: You're best bet for a frozen variable would be a constant, but even then, it's only intent revealing (I'm a constant and shouldn't be modified) vs Ruby saying you can't modify it.
[16:33:19] kyrylo: has joined #ruby
[16:33:32] qbrd[m]: I'm teaching a Chef class and the question about "immutable strings" came up, so we were discussing what that means/how they work.
[16:35:20] qbrd[m]: I of course opened with "you can't do string concatenation without a new variable", which I then proved to be a lie... lol.
[16:35:21] qbrd[m]: So, immutable strings are only good for disabling `gsub!` lol.
[16:41:50] sytherax: has joined #ruby
[16:41:56] kyrylo: has joined #ruby
[16:45:11] adam12: qbrd[m]: I believe they help reduce load on the GC as well
[16:52:01] poontangmessiah: has joined #ruby
[16:54:15] duderonomy: has joined #ruby
[16:55:57] FastJack: has joined #ruby
[16:57:53] kyrylo_: has joined #ruby
[17:00:09] kyrylo: has joined #ruby
[17:01:40] AJA4351: has joined #ruby
[17:02:39] qbrd[m]: ah! interesting.
[17:02:40] qbrd[m]: oh, I just found this https://www.mikeperham.com/2018/02/28/ruby-optimization-with-one-magic-comment/
[17:02:40] qbrd[m]: which basically says the same thing :)
[17:05:18] qbrd[m]: also, it seems my `'foo'.freeze` is redundant... lol
[17:08:10] adam12: qbrd[m]: There's a good post somewhere on the ruby-talk mailing list from normalperson (eric wong) who talks about it too.
[17:08:55] havenwood: qbrd[m]: That article's example isn't a good one, since it's already optimized and doesn't dup.
[17:09:11] adam12: qbrd[m]: Not allowing gsub! is handy tho. I once mutated the Rails params hash (let's call it, params[:state_abbr].upcase!), which caused a ton of grief trying to track down (pre frozen strings)
[17:10:06] adam12: qbrd[m]: https://rubytalk.org/t/psa-string-memory-use-reduction-techniques/74477
[17:10:11] havenwood: Discussion here: https://bugs.ruby-lang.org/issues/16047
[17:10:15] dviola: has joined #ruby
[17:10:33] havenwood: jeremyevans's point apply's to the article's example
[17:10:39] qbrd[m]: sweet, thanks!
[17:10:52] havenwood: freeze ALL THE THINGS \o/
[17:11:02] kyrylo: has joined #ruby
[17:11:14] havenwood: I prefer frozen by default.
[17:11:16] qbrd[m]: never not freeze!
[17:11:34] havenwood: qbrd[m]: https://gist.github.com/havenwood/0aa75f0c896a6dda0e56da5f21ed9fbd
[17:12:13] havenwood: qbrd[m]: Unless you fiddle...
[17:12:36] deepredsky: has joined #ruby
[17:13:50] kyrylo_: has joined #ruby
[17:16:15] qbrd[m]: ok, what is ^= ?
[17:16:17] kyrylo: has joined #ruby
[17:16:55] qbrd[m]: my google fu fails me.
[17:17:34] phaul: x [+-*/...]= y is a shorthand for x = x [+-*/...] y
[17:17:51] phaul: so a ^= b is a = a ^ b
[17:18:09] phaul: ^ being the bitwise xor
[17:19:39] reber: has joined #ruby
[17:22:44] kyrylo: has joined #ruby
[17:23:40] ramfjord: has joined #ruby
[17:25:20] involans: has joined #ruby
[17:42:45] impermanence: gem install --http-proxy http://my_prxy.net:3128 optparse
[17:42:54] impermanence: ERROR: Could not find a valid gem 'optparse' (>= 0) in any repository
[17:43:35] impermanence: but other gems are indeed pulling
[17:43:59] impermanence: apipie-bindings pulls
[17:44:12] involans: has joined #ruby
[17:45:29] hutch: has joined #ruby
[17:52:40] kyrylo: has joined #ruby
[17:59:20] deepredsky: has joined #ruby
[18:05:16] glosoli: has joined #ruby
[18:07:55] kyrylo: has joined #ruby
[18:12:25] brool: has joined #ruby
[18:14:30] chalkmonster: has joined #ruby
[18:17:04] cd: has joined #ruby
[18:24:39] havenwood: impermanence: optparse is in the stdlib but it hasn't been extracted to a stdgem
[18:24:44] havenwood: impermanence: https://stdgems.org/
[18:24:46] AJA4350: has joined #ruby
[18:25:26] havenwood: impermanence: https://github.com/ruby/ruby/blob/master/lib/optparse.rb
[18:33:38] GodFather: has joined #ruby
[18:34:10] GodFather_: has joined #ruby
[18:35:52] gix: has joined #ruby
[18:47:52] sdu: has joined #ruby
[18:51:33] leitz: has joined #ruby
[18:53:43] jenrzzz: has joined #ruby
[19:00:08] ukd1: has joined #ruby
[19:02:04] ukd1: has joined #ruby
[19:05:48] brool: i'm making a chatroom with sinatra and ajax, how do i keep a server-side list of active nicks? should i just have the app read/write to a file on every login/logout?
[19:05:57] brool: i just want something quick & dirty
[19:07:31] glosoli: has joined #ruby
[19:09:16] SeepingN: has joined #ruby
[19:09:57] erk^: has joined #ruby
[19:15:19] RetroPunk: has joined #ruby
[19:16:29] deepredsky: has joined #ruby
[19:16:34] RetroPunk: hey all, hope to get some help with this stupid issue i am having. i am trying to create a new class within a module and include it in my main file but i'm getting an error:
[19:16:35] RetroPunk: ./tracklist:38:in `<main>': uninitialized constant Tracklist::TrackParser (NameError)
[19:16:44] RetroPunk: here is the file that i am trying to include/instantiate: https://gitlab.com/DomenicF/ruby-tracklist/blob/TrackParser/lib/tracklist/track_parser.rb
[19:16:48] RetroPunk: here is where i am including it: https://gitlab.com/DomenicF/ruby-tracklist/blob/TrackParser/lib/tracklist.rb#L2
[19:16:58] RetroPunk: and i am trying to instantiate/initialize it here: https://gitlab.com/DomenicF/ruby-tracklist/blob/TrackParser/bin/tracklist
[19:17:59] sameerynho: has joined #ruby
[19:20:48] ascarter: has joined #ruby
[19:21:24] havenwood: brool: Serializing and writing to a file can sometimes result in transactional issues where changes don't occur together. The Ruby stdlib has PStore for Marshal and YAML::Store for Psych that provide transactional guarantees.
[19:22:11] havenwood: brool: Alternatively, you could use an in-memory cache. I've rolled my own with Rinda::TupleSpace from the stdlib before and kinda liked that.
[19:22:35] havenwood: brool: Or DBM (Berkley DB) ships with the Ruby stdlib as well. For values more complex than a String, there's YAML::DBM - which would probably work for your case.
[19:24:11] havenwood: brool: Here's an example of a TupleSpace cache, which is a little unordinary: https://github.com/stephaniewilkinson/yonderbook/blob/master/lib/tuple_space.rb
[19:24:31] havenwood: brool: Or here's a tiny wrapper gem I wrote around PStore a long while back: https://github.com/havenwood/persist#readme
[19:24:44] brool: thanks i'll look into all this
[19:25:04] havenwood: brool: Or there's always Redis, SQlite, Postgres and the usual suspects.
[19:25:06] brool: i actually think a cache is a better idea, a file is kind of a clumsy way for this
[19:25:36] brool: cus i'm not going to save users, just want a way to prevent duplicate nicks
[19:25:59] brool: kind of like irc but with no nickserv or anything, just hop on pick a nick and go
[19:26:11] havenwood: brool: With that TupleSpace one above, a reaper will come through every minute and remove cache items older than 24 hours.
[19:26:13] havenwood: And it's just those 31 lines.
[19:26:42] havenwood: Along with this little helper: https://github.com/stephaniewilkinson/yonderbook/blob/master/lib/cache.rb
[19:26:45] havenwood: They could be merged.
[19:27:40] havenwood: brool: If you haven't yet, I'd suggest taking a look at Roda. It's Sinatra inspired and really nice.
[19:28:11] havenwood: brool: It has a cache and routing tree built in, then a bunch of plugins you can cherry pick.
[19:28:15] havenwood: brool: http://roda.jeremyevans.net/
[19:29:16] havenwood: brool: I wrote a plugin that exposes HTTP/2 WebSockets in Roda backed by the async-websockets gem: https://github.com/socketry/roda-websockets
[19:29:31] havenwood: brool: You could write a nifty HTTP/2 WebSocket chat client with it. ;)
[19:30:11] havenwood: brool: And Roda already has a Thread safe cache. :)
[19:30:55] havenwood: Here's an example of using the plugin (HTTP/2 if your browser supports or HTTP/1 fallback): https://github.com/socketry/roda-websockets/blob/master/examples/interactive_browser/config.ru
[19:31:37] havenwood: brool: And here's an example of a chat app, done purely with async-websocket: https://github.com/socketry/async-websocket/tree/master/examples/chat
[19:32:55] kyrylo: has joined #ruby
[19:33:26] leftylink: RetroPunk: possible to check whether the right files are getting `require` d ? for example just adding a `puts __FILE__` at the bottom of each file? it would be disastrous if , for example, a stray `-I .` got into the command line flags and caused `bin/tracklist.rb` to require itself instead of `lib/tracklist.rb`...
[19:34:01] leftylink: actually, that's not even a reasonable suggestion for me to make
[19:34:09] RetroPunk: i can do that, though
[19:34:18] RetroPunk: i just figured it was being required because i didn't get an error for that
[19:34:21] leftylink: if bin/tracklist were requiring itself, it would be Tracklist that was undefined, not TrackParser
[19:34:27] leftylink: so my suggestion cannot be correct
[19:35:05] havenwood: RetroPunk: require 'tracklist/track_parser"
[19:35:41] havenwood: oh, you actually do already: https://gitlab.com/DomenicF/ruby-tracklist/blob/TrackParser/lib/tracklist.rb#L2
[19:36:06] leitz: RetroPunk, where is track_parser?
[19:36:32] RetroPunk: lib/tracklist/trackl_parser.rb
[19:36:43] RetroPunk: forget the typo
[19:36:47] RetroPunk: lib/tracklist/track_parser.rb
[19:37:21] leitz: lib/tracklist/ doesn't have a track_parser.rb in the repo you sent.
[19:37:22] havenwood: RetroPunk: You can drop this line: https://gitlab.com/DomenicF/ruby-tracklist/blob/master/tracklist.gemspec#L27
[19:37:29] havenwood: RetroPunk: 'bin' is the default bindir
[19:37:37] RetroPunk: leitz: did you check the TrackParser branch?
[19:37:42] havenwood: it's just Bundler that can't accept that default ;P
[19:37:51] havenwood: they keep generating gems that change it
[19:37:56] RetroPunk: ah ok, i'll just remove that line then :)
[19:38:11] leitz: RetroPunk, I was on master. Lemme go check.
[19:38:58] AJA4350: has joined #ruby
[19:41:58] leftylink: with that exact directory structure, one certainly would expect that `ruby -I lib bin/tracklist` would work. so something tricky is going on
[19:42:52] RetroPunk: i am wondering if it has to do with renaming the gem, i will try to explain what happened in detail
[19:43:12] leitz: leftylink, I'm thinking it's not finding the lib. Poking at it now.
[19:43:42] RetroPunk: last night i created a gem called "tracklist" and wanted to push it to rubygems.org. this gem was already taken, so i renamed it to ruby-tracklist. however, after doing so i couldn't require 'ruby-tracklist', i could only require 'tracklist' and it still worked
[19:43:46] RetroPunk: i hope this makes sense
[19:44:26] leftylink: `ruby -I` doesn't really care what the gem is called
[19:45:04] leftylink: can someone tell me real quick what the style of art in matz's avatar is called? https://pbs.twimg.com/profile_images/511244255294001152/v5phEU1O.jpeg
[19:45:05] leitz: RetroPunk, which taglib are you using?
[19:45:06] havenwood: RetroPunk: https://guides.rubygems.org/name-your-gem/
[19:45:17] havenwood: leftylink: cartoon :P
[19:45:29] RetroPunk: btw, i don't get an error when running ruby -I lib bin/tracklist .
[19:45:29] leitz: Cartoon with color.
[19:45:45] RetroPunk: leitz: gem "taglib-ruby"
[19:45:49] leitz: RetroPunk, then the issue is that it can't find your library.
[19:47:12] leitz: While bad form, I tend to add: $LOAD_PATH << File.expand_path('../../lib', __FILE__) to my command programs. You won't need it once you have the gem installed.
[19:47:32] RetroPunk: leitz: i lied, i'm sorry, different error...
[19:47:34] RetroPunk: ruby/tracklist/track_parser (LoadError)
[19:47:43] RetroPunk: in `require': cannot load such file --
[19:47:43] RetroPunk: ruby/tracklist/track_parser (LoadError)
[19:47:52] leitz: Which explains the "uninitialized constant".
[19:48:04] leitz: Which line of which file?
[19:48:17] RetroPunk: wait hold on i'm sorry
[19:48:34] leitz: Yeah...I *never* make mistakes...
[19:48:36] jefffrails35: has joined #ruby
[19:48:38] RetroPunk: that link havenwood sent got me confused :P i changed the require to ruby/tracklist/track_parser
[19:48:39] leitz: ACTION chokes on his own words...
[19:48:49] RetroPunk: haha the life of the perfect dev
[19:49:58] RetroPunk: yeah so i'm confused, it doesn't *error* with the -I command
[19:50:24] RetroPunk: so that's something
[19:50:36] leitz: Like I said, it can't find your library, because your ~/lib isn't in the LOAD_PATH.
[19:50:46] leitz: -I lib fixes that for you.
[19:52:52] RetroPunk: so what you're doing there with the $LOAD_PATH is basically concatenating onto the $LOAD_PATH with the lib directory i am assuming
[19:53:20] leitz: Adding it to the LOAD_PATH, yes.
[19:54:02] RetroPunk: i added this to my bin/tracklist file and i am still getting the error
[19:54:19] leitz: If you open up an irb session you can "puts $LOAD_PATH" and it should show you the path.
[19:54:46] leitz: Hmmm...try adding it to lib/tracklist.rb as well. I'll check my notes.
[19:56:00] ukd1: has joined #ruby
[19:56:20] RetroPunk: yeah i see the $LOAD_PATH in irb, it's all stuff in the .rvm folder
[19:57:02] RetroPunk: leftylink: sorry didn't see that, it's bitmoji i think?
[19:57:41] leitz: what if you all the load path to the main program, and then add a "puts $LOAD_PATH" there? Does it see your lib directory?
[19:58:07] eddof13: has joined #ruby
[19:58:23] RetroPunk: yeah the lib directory is there
[19:58:27] RetroPunk: but not lib/tracklist
[20:00:01] jefffrails35: has joined #ruby
[20:00:48] code_zombie: has joined #ruby
[20:02:13] leitz: The lib should work, it should look in lib/tracklist for track_parser.
[20:02:50] leftylink: bitmoji, that looks like that is te term I was looking for, thank you
[20:02:54] leitz: Have you tried putting it in tracklist.rb as well?
[20:03:07] RetroPunk: the $LOAD_PATH code you sent? yeah
[20:03:15] RetroPunk: i can do a puts $LOAD_PATH there though
[20:03:35] teardown: has joined #ruby
[20:03:35] leitz: Try, but it should show the lib.
[20:03:51] leitz: Granted, I'm still a Ruby-Newbie, but this usually works for me.
[20:05:06] RetroPunk: the puts isn't even outputting from the tracklist.rb
[20:05:26] leitz: That's a clue.
[20:05:28] RetroPunk: let me try removing the initialization
[20:06:18] RetroPunk: yeah it's just not outputting anything to the terminal hmm
[20:07:01] RetroPunk: even puts "hello" doesn't work in that file
[20:07:20] sytherax: has joined #ruby
[20:08:11] RetroPunk: does that mean that the require is only requiring the class tracklist and not the module?
[20:08:27] RetroPunk: or the file, rather
[20:10:03] Rapture: has joined #ruby
[20:10:47] leftylink: maybe it is worth doing `puts $LOADED_FEATURES.grep(/tracklist/)` to see what exactly got `require`d, and see if that matches up w/ expectations
[20:12:07] RetroPunk: it looks like tracklist/version.rb and tracklist.rb are being loaded
[20:17:16] matt76: has joined #ruby
[20:18:58] leftylink: isn't tat inconsistent with the earlier statement tat putting a `puts` in tracklist.rb had no effect?
[20:19:24] Fusl: has joined #ruby
[20:20:25] RetroPunk: hmm actually
[20:20:38] RetroPunk: it looks like it's loading these files from the .rvm directory
[20:20:43] RetroPunk: .rvm/gems/ruby-2.6.0/gems/ruby-tracklist-1.0.1/lib/tracklist.rb
[20:20:49] RetroPunk: .rvm/gems/ruby-2.6.0/gems/ruby-tracklist-1.0.1/lib/tracklist/version.rb
[20:21:14] RetroPunk: so that means that it's not even reading anything in the local folder? lol
[20:21:21] ukd1: has joined #ruby
[20:23:28] RetroPunk: i bet if i built the gem and installed it it would work, but that's counter productive
[20:23:38] hutch: has joined #ruby
[20:30:28] leftylink: also TIL `$LOADED_FEATURES` for this express purpose
[20:31:18] RetroPunk: thank you this is really helpful... any idea on how to go about getting it to load locally?
[20:34:02] ellcs: has joined #ruby
[20:34:04] leftylink: I thought you already said it yourself - you saw that `-I lib` worked. isn't that the way to go? it's not like Ruby is magic. It's not going to know where to `require` the files from unless explicitly told so
[20:36:30] RetroPunk: i suppose so
[20:37:41] RetroPunk: thank you all for your help, i really appreciate it
[20:37:47] RetroPunk: i will just use the -I flag from now on
[20:38:07] leftylink: hmm. although maybe it is customary for `bin/` to prepend its own `lib` to the $LOAD_PATH ? I'm not sure what is the convention among gem authors
[20:38:56] leftylink: or maybe it's customary to require_relative ???
[20:39:21] Sithembewena: has joined #ruby
[20:39:31] leftylink: those are some options to explore. I cannot advise on wheter that would break some convention that gem authors adhere to, but they are options
[20:40:25] leftylink: eh, the require_relative is mostly unsatisfying since things directly required by `bin/whatever` will be affected, but if we assume that files in `lib` will continue to `require` instead of `require_relative`, then there will be no dice there
[20:42:53] eddof13: has joined #ruby
[20:43:22] Nicmavr: has joined #ruby
[20:43:28] leftylink: random internet person says gems can use require_relative for internals. https://medium.com/@ellishim/understanding-require-vs-require-relative-vs-require-all-80e3b26d89e6 . assuming this random internet stranger isn't completely unjustified, perhaps this is a possible avenue to explore
[20:43:51] sytherax: has joined #ruby
[20:44:33] RetroPunk: thank you, i shall try this
[20:46:15] sytherax: has joined #ruby
[20:47:57] houhoulis: has joined #ruby
[20:48:33] leftylink: random internet person in https://www.reddit.com/r/ruby/comments/3341zm/require_best_practices/ preferred the LOAD_PATH way of doing things, and recommended not using require_relative. I wonder why.
[20:49:55] leftylink: aha excellent, they talk about it in https://www.reddit.com/r/ruby/comments/3341zm/require_best_practices/cqi0un7/ .
[20:50:03] havenwood: RetroPunk: I'd really recommend following RubyGems naming convention.
[20:50:42] RetroPunk: havenwood: so restart the gem and name it ruby_tracklist?
[20:50:45] havenwood: RetroPunk: There's no track_list gem. Why not use that name?
[20:50:52] RetroPunk: yeah i could do that
[20:50:57] havenwood: RetroPunk: TrackList is solid.
[20:51:34] RetroPunk: so basically create a new template gem (totally fine with starting over) and name it track_list?
[20:51:48] havenwood: RetroPunk: TrackList is lib/track_list.rb, which is super simple.
[20:52:00] RetroPunk: for sure yeah
[20:52:11] RetroPunk: could i still name the "binary" tracklist?
[20:52:37] havenwood: RetroPunk: Yes, I'd suggest starting with a new gem name that follows convention to the T. You might also consider starting from a blank folder and only adding back what you need.
[20:52:44] havenwood: RetroPunk: Yes, you can still name the binary tracklist
[20:52:55] RetroPunk: great i'm going to do this
[20:53:05] leftylink: as I read it, jrochkind's most compelling argument is that if I need to split a gem into two, then suddenly I won't be able to use some of the `require_relative` anymore and will be forced to change them to `require`. that is a fair point, so should be evaluated against te probability of te gem ever having to split in two in the future
[20:53:15] havenwood: RetroPunk: Here's an example of a bin/siphash even though it's a SipHash namespace: https://github.com/havenwood/digest-sip_hash/blob/master/bin/siphash
[20:53:25] havenwood: RetroPunk: that's actually no problem whatsoever
[20:54:37] havenwood: RetroPunk: executable names are properly more arbitrary. namespaces should match names.
[20:54:57] RetroPunk: i didn't know about the conventions, that is my bad for not looking into it first
[20:55:01] RetroPunk: still learning so much
[21:00:43] admin123: has joined #ruby
[21:01:48] drnerdius: has joined #ruby
[21:03:53] AJA4350: has joined #ruby
[21:06:47] houhoulis: has joined #ruby
[21:10:17] involans: has joined #ruby
[21:12:58] RetroPunk: havenwood: i'm getting another error now about it not being able to load the file... if i push this up to gitlab would you mind taking a quick look for me?
[21:13:11] havenwood: RetroPunk: link?
[21:13:31] titanbiscuit: has joined #ruby
[21:14:15] RetroPunk: havenwood: https://gitlab.com/DomenicF/track_list
[21:16:55] go|dfish: has joined #ruby
[21:18:40] houhoulis: has joined #ruby
[21:20:23] sytherax: has joined #ruby
[21:23:24] ur5us: has joined #ruby
[21:25:44] jenrzzz: has joined #ruby
[21:32:27] RetroPunk_: has joined #ruby
[21:34:40] havenwood: RetroPunk: You'll just need to install the gem for that to work.
[21:34:42] chalkmon1: has joined #ruby
[21:35:25] RetroPunk: havenwood: do you mean i need to install my own gem every time i make a change or something else?
[21:35:30] havenwood: RetroPunk: rake install
[21:35:53] havenwood: RetroPunk: If you want to test the binary and not use a require_relative or modify the load path, yes.
[21:36:06] RetroPunk: is this the best practice?
[21:36:17] havenwood: RetroPunk: yes
[21:36:41] havenwood: RetroPunk: If you install the gem, does it work?
[21:36:45] havenwood: RetroPunk: rake install
[21:36:58] havenwood: RetroPunk: The binary won't be available when the gem isn't installed.
[21:37:18] havenwood: RetroPunk: Gem binaries usually don't work if you try to use them directly, since they tend to rely on load path.
[21:37:35] RetroPunk: this all makes sense now
[21:37:48] RetroPunk: ok i thought i would be able to save and just test locally like that
[21:37:51] RetroPunk: but i need to rake install first
[21:37:56] RetroPunk: and yes, it works :)
[21:38:21] havenwood: RetroPunk: thum👍🏽
[21:38:31] RetroPunk: thanks a lot man, that explains so much
[21:39:51] quesker: has joined #ruby
[21:40:17] quesker: on mac I did gem install thor. looks like it installed. but I don't know where it put it
[21:42:01] havenwood: quesker: gem env gemdir
[21:42:20] havenwood: quesker: gem which thor
[21:42:50] havenwood: quesker: you can also: gem open thor
[21:43:08] mjacob: is there a way to define a "data class" with additional methods that works similar to inheriting from a anonymous struct ("class X < Struct.new(:foo, :bar)") but doesn't use inheritance?
[21:43:12] havenwood: quesker: or: gem contents thor
[21:43:39] havenwood: mjacob: X = Struct.new(:foo, :bar)
[21:44:03] havenwood: mjacob: If you're on a modern Ruby, also consider using: keyword_init: true
[21:44:29] jmcgnh_: has joined #ruby
[21:44:36] havenwood: mjacob: https://blog.bigbinary.com/2018/01/16/ruby-2-5-allows-creating-structs-with-keyword-arguments.html
[21:44:39] involans: has joined #ruby
[21:45:16] mjacob: havenwood: what if i want to add more methods to X?
[21:45:27] havenwood: mjacob: X = Struct.new(:foo, :bar, keyword_init: true) do
[21:45:45] mjacob: havenwood: ah, i see, thanks
[21:46:36] havenwood: &>> X = Struct.new(:foo, :bar, keyword_init: true) { def combined; "#{foo}#{bar}" end }; X.new(foo: 'ya', bar: 'y!').combined # mjacob
[21:46:38] rubydoc: # => "yay!" (https://carc.in/#/r/7dbf)
[21:47:36] drincruz: has joined #ruby
[21:48:23] GodFather_: has joined #ruby
[21:48:29] GodFather: has joined #ruby
[21:50:07] greengriminal: has joined #ruby
[21:52:30] ascarter: has joined #ruby
[21:59:18] chalkmonster: has joined #ruby
[22:08:52] ascarter: has joined #ruby
[22:10:58] x86sk: has joined #ruby
[22:19:17] dviola: has joined #ruby
[22:19:54] eddof13: has joined #ruby
[22:21:27] Retr0Punk: havenwood: i'm getting there i think. just having another load issue... again... i followed your advice and created a new class file and then did rake install but i'm getting a load error again. the repo is https://gitlab.com/DomenicF/track_list
[22:21:52] Frobozz: has joined #ruby
[22:21:52] Retr0Punk: in track_list.rb i am doing require 'track_list/directory_parser'
[22:22:00] Retr0Punk: and then rake install
[22:22:20] Retr0Punk: then i get cannot load such file -- track_list/directory_parser (LoadError)
[22:25:48] m27frogy: has joined #ruby
[22:28:58] Retr0Punk: havenwood: idk why but it works now, after doing rake install like 5 times
[22:52:23] quesker: has left #ruby: ()
[23:00:25] AJA4350: has joined #ruby
[23:01:00] morenoh149: has joined #ruby
[23:08:18] sytherax: has joined #ruby
[23:13:21] sytherax: has joined #ruby
[23:19:16] Fusl: has joined #ruby
[23:22:33] chalkmonster: has joined #ruby
[23:33:00] ukd1_: has joined #ruby
[23:33:35] poontangmessiah: has joined #ruby
[23:40:31] morenoh149: has joined #ruby
[23:47:20] sytherax: has joined #ruby