havenwood changed the topic of #ruby to: Rules & more: https://ruby-community.com | Ruby 2.7.0, 2.6.5, 2.5.7: https://www.ruby-lang.org | Paste 4+ lines of text to https://dpaste.de/ and select Ruby as the language | Rails questions? Ask in #RubyOnRails | Books: https://goo.gl/wpGhoQ | Logs: https://irclog.whitequark.org/ruby | Can't talk? Register/identify with Nickserv first!
cisco has joined #ruby
ur5us has joined #ruby
<phaul> oh Christ. it's flaky test. I really hate when this happens. Is there something fundemantally wrong with https://github.com/phaul/yarr/blob/master/spec/yarr/command/rename_fact_spec.rb#L68 in conjuction with database cleaner gem + truncation strategy?
ellcs has quit [Ping timeout: 246 seconds]
drincruz_ has joined #ruby
ExoUNX has quit [Quit: later fam...]
noboruma has quit [Remote host closed the connection]
markopasha has quit [Read error: Connection reset by peer]
markopasha has joined #ruby
elcuervo has quit [Read error: Connection reset by peer]
elcuervo has joined #ruby
wildtrees has quit [Quit: Leaving]
roadie has joined #ruby
Translat-Embedde has quit [Ping timeout: 250 seconds]
tfreedman has joined #ruby
<tfreedman> so I'm trying to get something to work with two copies of rails, in two separate repos, that have to communicate with each other
markopasha has quit [Ping timeout: 250 seconds]
<tfreedman> both running under rvm
<tfreedman> repo A does a bunch of work fetching stuff, then signals to repo B to deal with the incoming data
<tfreedman> so I have repo A using backticks to run a process, and it works fine if it's me doing this from a terminal
<tfreedman> but not if it's cron hitting repoA then triggering repoB, presuambly because repoB's settings aren't fully loaded
<tfreedman> so uhhh, what's wrong with this command:
<tfreedman> ```
<tfreedman> command = "/bin/bash -l -c \"cd #{path} && ./bin/rails runner -e development \'x = ApplicationController.new ; x.update(#{uids.to_s.gsub('"', '\"')}, :#{service})\'\""
<tfreedman> ```
<tfreedman> (path is the file path to repoB)
ur5us has quit [Ping timeout: 260 seconds]
roadie has quit [Ping timeout: 240 seconds]
<tfreedman> is there an easy way to not have repoA's environment variables initialized when using backticks?
ExoUNX has joined #ruby
greypack has joined #ruby
bvdw has quit [Read error: Connection reset by peer]
bvdw has joined #ruby
roadie has joined #ruby
factormystic has joined #ruby
roadie has quit [Ping timeout: 246 seconds]
<kinduff> whats the log on repoB when executing that runner?
<kinduff> does it raise an exception because the environment is not fully loaded?
Tempesta has quit [Quit: See ya!]
<tfreedman> so the log is from repoA
<tfreedman> ~/.rvm/gems/ruby-2.6.5@repoA/gems/bundler-2.1.4/lib/bundler/spec_set.rb:86:in `block in materialize': Could not find concurrent-ruby-1.1.5 in any of the sources (Bundler::GemNotFound)
<tfreedman> with a complete backtrace
cschneid has joined #ruby
<tfreedman> repoB isn't actually getting loaded, when this is run by cron
<tfreedman> when it's run by me running ```rails c``` in bash, and then running do_the_thing_in_repo_b(), it works
cschneid_ has quit [Ping timeout: 250 seconds]
Tempesta has joined #ruby
ChmEarl has quit [Quit: Leaving]
<tfreedman> alternatively, if anyone has a less ridiculous way of linking A to B, I'm all ears
<tfreedman> though I'd prefer to avoid doing something like POSTing data to a route that repo B offers
<tfreedman> or writing a file to disk and waiting for repoB to check it every so often
cisco has quit [Remote host closed the connection]
roadie has joined #ruby
roadie has quit [Ping timeout: 264 seconds]
kevinburke has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
drincruz has joined #ruby
d3bug has quit [Quit: Connection closed for inactivity]
drincruz_ has quit [Ping timeout: 264 seconds]
drincruz_ has joined #ruby
drincruz has quit [Ping timeout: 246 seconds]
drincruz_ has quit [Ping timeout: 246 seconds]
roadie has joined #ruby
kristian_on_linu has quit [Remote host closed the connection]
d3bug has joined #ruby
roadie has quit [Ping timeout: 246 seconds]
vondruch has quit [Quit: vondruch]
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
cschneid_ has joined #ruby
cschneid has quit [Ping timeout: 250 seconds]
roadie has joined #ruby
cd has joined #ruby
tsujp has joined #ruby
gix has quit [Disconnected by services]
braincrash has quit [Quit: bye bye]
tsujp has quit [Client Quit]
braincrash has joined #ruby
roadie has quit [Ping timeout: 256 seconds]
polishdub has joined #ruby
BTRE has quit [Quit: Leaving]
BTRE has joined #ruby
Swyper has joined #ruby
zlogan has quit [Ping timeout: 246 seconds]
roadie has joined #ruby
drincruz_ has joined #ruby
BTRE has quit [Quit: Leaving]
roadie has quit [Ping timeout: 264 seconds]
drincruz_ has quit [Ping timeout: 250 seconds]
polishdub has quit [Ping timeout: 256 seconds]
dviola has joined #ruby
ExoUNX has quit [Quit: I'm leaving these neckbeards]
BTRE has joined #ruby
ExoUNX has joined #ruby
davor has quit [Ping timeout: 256 seconds]
zlogan has joined #ruby
sergioro has quit [Quit: leaving]
Technodrome has joined #ruby
Swyper has quit [Remote host closed the connection]
roadie has joined #ruby
sergioro has joined #ruby
davor has joined #ruby
cschneid has joined #ruby
cschneid_ has quit [Ping timeout: 250 seconds]
polishdub has joined #ruby
roadie has quit [Ping timeout: 256 seconds]
fluxAeon has quit [Ping timeout: 240 seconds]
fluxAeon has joined #ruby
d3bug has quit [Quit: Connection closed for inactivity]
vondruch has joined #ruby
roadie has joined #ruby
chalkmonster has joined #ruby
polishdub has quit [Ping timeout: 264 seconds]
william1_ has quit [Ping timeout: 240 seconds]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
polishdub has joined #ruby
drincruz_ has joined #ruby
polishdub has quit [Remote host closed the connection]
drincruz_ has quit [Ping timeout: 256 seconds]
roadie has quit [Ping timeout: 250 seconds]
william1_ has joined #ruby
kevinburke has quit [Quit: Connection closed for inactivity]
akem has quit [Quit: Leaving]
markopasha has joined #ruby
code_zombie has quit [Quit: Leaving]
dviola has quit [Quit: WeeChat 2.7.1]
cschneid_ has joined #ruby
cschneid has quit [Ping timeout: 250 seconds]
roadie has joined #ruby
iNs has quit [Ping timeout: 240 seconds]
chalkmonster has quit [Quit: WeeChat 2.7.1]
iNs has joined #ruby
gix has joined #ruby
sauvin has quit [Ping timeout: 250 seconds]
cschneid_ has quit [Quit: ZNC 1.7.5 - https://znc.in]
drincruz_ has joined #ruby
drincruz_ has quit [Ping timeout: 240 seconds]
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Swyper has joined #ruby
cschneid has joined #ruby
yxhuvud has quit [Read error: Connection reset by peer]
yxhuvud has joined #ruby
sauvin has joined #ruby
Swyper has quit [Ping timeout: 250 seconds]
sergioro has quit [Quit: leaving]
ta has quit [Ping timeout: 264 seconds]
ta has joined #ruby
<clemens3> what is a repo? I must be out of the loop for too long
<tfreedman> repository?
<clemens3> git?
<tfreedman> yes
conta has joined #ruby
<clemens3> so to RailsA server has something arrived and ready, and can just open a RailsB page to let RailsB process your stuff, not?
<tfreedman> yeah
<clemens3> curl "http://localhost:portrailsb/message"
<tfreedman> the problem with that is that the command RailsB has to run is long
<tfreedman> so I'd be removing a worker from the pool by doing that
<clemens3> then why use rails at all?
<clemens3> why not to a batch somewhere with the data
<tfreedman> for A or B?
<clemens3> why the whole rails thing?
<tfreedman> B is a website
<tfreedman> repo A is inserting a bunch of records into a DB, and then repoB (the viewer) has to re-render a bunch of stuff
<tfreedman> repoB's script is currently a runner, but I could make it a rake task too
<tfreedman> it's basically "repoA gave us some data - do we need to rebuild our caches as a result of the new data that came in?"
<clemens3> so both on the same machine?
<tfreedman> yes, for the time being
<clemens3> so both tasks seem to have nothing todo with a web server, only after B has finished rendering, will it be shown
<tfreedman> if they were on different machines, I'd have just done curl http://repoB/update
conta has quit [Quit: conta]
<clemens3> so same machine is easier
<clemens3> so do B rendering not in a rails process
<tfreedman> so repo B is a website that uses cached data
<tfreedman> the command being triggered is to update the cache
<tfreedman> it's uhhh, complicated
<tfreedman> clemens3: how?
<clemens3> the cache update, what is the outcome of that? a bunch of svg/jpeg files?
<clemens3> what is the rendering?
<tfreedman> uhhh
<clemens3> so let a invoke update_cache.sh
<clemens3> a=A
<tfreedman> so basically, there's a ton of tables with a ton of data for a bunch of users
<clemens3> update_cache.sh is in b..
<clemens3> A is inserting into the DB
<jhass> are you looking for http://rvm.io/workflow/scripting?
<clemens3> B is taking it out and doing something with it
<clemens3> so just do that
<tfreedman> each table updates individually at different points in time
<tfreedman> the result of the cache update is a decision as to whether or not X being updated actually affects whether or not user A should be displayed differently
<jhass> btw I wouldn't new up ApplicationController but extract that to a PORO in lib/ and invoke it through a rake task maybe
<clemens3> I think you must get clear about the real problem, not some rails technicality, that likely is not needed at all
<tfreedman> computing it in real time is way too slow
<tfreedman> I can probably do it as a rake task, but I assume I'll have the same issue
<tfreedman> the problem is with RVM failing to set up the environment, and not the script itself failing
<jhass> see my link :)
<jhass> or http://rvm.io/deployment/cron actually
<tfreedman> yeah, I've tried that
<tfreedman> I assume I'm doing something wrong, but it isn't working
<tfreedman> since it still always has some env vars of railsA
<jhass> is A even running as a website/server?
<tfreedman> the command I have in repoA is ```"/bin/bash -l -c \"source ~/.rvm/environments/ruby-2.6.5@repoB && cd #{path} && ./bin/rails runner -e development \'x = ApplicationController.new ; x.update(#{uids.to_s.gsub('"', '\"')}, :#{service})\'\""```
<tfreedman> jhass: uhhh, kinda
<tfreedman> repoA is a very weird repository
<tfreedman> I can elaborate more on it, but uhhh, it's not a typical repo
<tfreedman> whereas repoB is a typical rails website
<jhass> well if the answer was no I would have suggested to just merge them into one project and have the background update just be a rake task
<tfreedman> so hilariously, this actually was one project at one point
<jhass> because honestly, this ApplicationController.new and the whole setup smells to heaven :P
<tfreedman> repoA is a runtime with certain proprietary bits
<tfreedman> repoB is the open source spinoff I'm trying to release
<jhass> maybe A should be a Rails engine that can plug into B? or even vice versa
<jhass> yeah, actually vice versa
<clemens3> tfreedman: what is the cache update output, also some data in a DB?
<clemens3> you need a long running process in batch mode which sends a message or commit when done, so B can use the result
<tfreedman> so repoA returns a list of which users had updates, and which specific tables to rescan for each user
<clemens3> rails, repo, all this chargon is just to confuse yourself
<tfreedman> so the console output isn't really useful
<tfreedman> it's fine to use old data while something in the background is updating
<jhass> does running the full /bin/bash command on its own outside cron work?
<clemens3> so learn about commits or atomic actions, which will be done at the end of the long running batch job
<jhass> does it work from a shell inside A?
<tfreedman> jhass: that version doesn't, I get ~/repoA/vendor/cache/ruby/2.6.0/gems/railties-5.2.4.1/lib/rails/application/configuration.rb:118:in `load_defaults': Unknown version "6.0" (RuntimeError)
jetchisel has quit [Quit: Unfortunately time is always against us -- [Morpheus]]
<tfreedman> which suggests there's a bug in the script
<tfreedman> namely, that RVM for repoA is still loaded when it tries to load repoB
<xco> i have this ruby code that i'm trying to access the keys by strings, i get nil unless i access by symbol, while the original hash has string keys https://gist.github.com/xcobar/0127b81701913c69a5cc3d6df6ca840e
<xco> how do i force it to return data when i access by it's string keys without using Rails's hashwithindifferentaccess?
<leftylink> but
<leftylink> those are symbol keys, not string keys
<leftylink> &>> {"hello": 5}
<rubydoc> # => {:hello=>5} (https://carc.in/#/r/8r4q)
<leftylink> symbol.
<leftylink> errr
<leftylink> oh, hmm
<leftylink> I guess you want to transform_keys to_s
<xco> oh i missed the : after the string!!!
<leftylink> I read too fast. my apologies
<xco> damn
<xco> :D
<leftylink> oh wait, it turns out I was OK even though I read too fast
<xco> no bu ti think the origin "data" has sympbol keys anyway
<xco> so me accessing by symbols doesn't make sense
<jhass> tfreedman: what if you do -lc 'set -e; ....'?
<jhass> tfreedman: maybe you need to cd before the source
<tfreedman> /bin/bash -l -c "set -e && source ....
<tfreedman> this: /bin/bash -l -c "set -e && source .... ?
<tfreedman> same error
<jhass> yeah
<jhass> okay so the source is not failing outright
<jhass> try to cd first
<tfreedman> yeah, same thing
<jhass> what if you drop the -l ?
<tfreedman> same thing
<jhass> what if you prepend /usr/bin/env -i ?
<tfreedman> as part of the command, or before /bin/bash
<jhass> before /bin/bash
conta has joined #ruby
<jhass> I would expect -l to do that already but...
<tfreedman> # /usr/bin/env -i /bin/bash -c "source ~/.rvm/environments/ruby-2.6.5@repoB && cd ~/sites/repoB && ./bin/rails runner -e development... produces "Could not find concurrent-ruby-1.1.5 in any of the sources"
<jhass> and with cd before source? are you sure you're sourcing the right environment? What's rvm current saying in sites/repoB?
rippa has joined #ruby
<tfreedman> ruby-2.6.5@repoB
<jhass> probably not literally
<jhass> I wouldn't be too surprised all the secrecey hiding the bug :P
<tfreedman> If you're interested in helping me further, I can PM you some details
jetchisel has joined #ruby
<jhass> I prefer others being able to jump in, watch & learn, sorry :)
<tfreedman> the only two changes I've made in any commands before copying/pasting are actual_name -> repoB, and the changed path (/home/username/sites -> ~/sites/repoB)
<tfreedman> but otherwise everything is exactly as output
<jhass> idk, how about we just sidestep RVM and do bundle --path vendor/bundle in B?
<jhass> then as long as both projects use the same ruby minor version you should be able to just run commands in B from A's environment
<tfreedman> okay, hmm
<tfreedman> so I kept getting errors no matter what I did, even after reverting some stuff
<tfreedman> I finally just killed SSH and re-opened it, and now it's back to working (from within repoA's rails c via "/bin/bash -l -c \"cd #{path} && ./bin/rails runner -e development \'x = ApplicationController.new ; x.update(#{uids.to_s.gsub('"', '\"')}, :#{service})\'\""
<jhass> oh well, *shrugs*
<jhass> if nothing else I hope you took away some hints to rethink the architecture :)
<tfreedman> so it seems like whatever commands were being run were also breaking my actual SSH session
<tfreedman> fun
<tfreedman> unfortunately, I can't think of a good alternative
<tfreedman> aside from just setting up a route in rails and having repoA hit it with HTTParty
<tfreedman> which is getting very tempting right now
<tfreedman> but since it might take up to a minute to run, I figured that was the last resort
<jhass> well we still have no clue what any of this is really about, so it's hard to give specifics hints
<jhass> but as I said from all I've gathered so far, B could be a rails engine mounted into A
<jhass> and expose a library interface to do tasks such as the above
<tfreedman> B used to be a rails engine for A
<tfreedman> A is a closed source component, and B was a hobby thing written as a joke
<tfreedman> they definitely worked while coupled
<tfreedman> I don't want to maintain that component as part of A's development, so I'm trying to decouple them as much as possible
<jhass> maybe too much. As long as B doesn't call any code from A and doesn't assume and paths/config files/database schema from A to be present, I see no reason why it wouldn't still be an engine
<jhass> B can expose whatever interface there needs to be between them as any normal gem would and A could just call it. No need for internal endpoints or running tasks in a nother project
<tfreedman> I opted to not keep B as a rails engine because it's a standalone thing, with a UI and everything
<tfreedman> so it seemed better to just create a new site, move B into it as its own thing, and migrate all the code from A->B
<jhass> wouldn't be the first thing to be standalone'ish but best shipped as a rails engine. think any generic admin panel rails engine for example
<jhass> or sidekiq's admin dashboard
<tfreedman> it's evolved into a reasonably complete app - you wouldn't exactly integrate this into another project
<tfreedman> it started as a plugin for an existing project as a joke, not something you'd realistically want to do
shokohsc has joined #ruby
<tfreedman> it started from a discussion somewhat akin to "can your project run Doom?"
<tfreedman> to which the only response was to write it as a plugin, demo it, and then spin it off into a separate thing so that nobody ever asks me why this is part of our source code
MrCrackPot has joined #ruby
conta has quit [Quit: conta]
drincruz_ has joined #ruby
drincruz_ has quit [Ping timeout: 250 seconds]
ellcs has joined #ruby
ellcs has quit [Max SendQ exceeded]
cschneid_ has joined #ruby
ellcs has joined #ruby
ellcs has quit [Max SendQ exceeded]
schne1der has joined #ruby
ellcs has joined #ruby
cschneid has quit [Ping timeout: 240 seconds]
kinduff has quit [Read error: Connection reset by peer]
kinduff has joined #ruby
akem has joined #ruby
elcuervo has quit [Read error: Connection reset by peer]
drincruz_ has joined #ruby
Tempesta has quit [Quit: AdiIRC is updating to v3.8 Beta Build (2020/03/17 UTC) 64 Bit]
Tempesta has joined #ruby
chalkmonster has joined #ruby
ua has quit [Read error: Connection reset by peer]
ua has joined #ruby
troulouliou_dev has joined #ruby
TCZ has joined #ruby
bvdw has quit [Read error: Connection reset by peer]
bvdw has joined #ruby
troulouliou_dev has quit [Read error: Connection reset by peer]
Translat-Embedde has joined #ruby
<phaul> I think I understand the flaky test issues I have. The problem is the assumtion that faker + factorybot would generate different data on subsequent calls. Sometimes it does sometimes it doesn't. if it doesn't assertions like expect {}.to change {} might fail, as we might change from the same to the same
troulouliou_dev has joined #ruby
troulouliou_dev has quit [Ping timeout: 250 seconds]
cschneid has joined #ruby
cschneid_ has quit [Ping timeout: 250 seconds]
troulouliou_dev has joined #ruby
lucasb has joined #ruby
Swyper has joined #ruby
oneeggeach has joined #ruby
mheld has joined #ruby
oneeggeach has quit [Client Quit]
buzzkill has left #ruby ["seeyas!"]
conta has joined #ruby
GodFather has joined #ruby
william1_ has quit [Ping timeout: 240 seconds]
troulouliou_dev has quit [Ping timeout: 265 seconds]
conta has quit [Quit: conta]
fluxAeon has quit [Ping timeout: 240 seconds]
Swyper has quit [Remote host closed the connection]
troulouliou_dev has joined #ruby
Swyper has joined #ruby
<TCZ> is it possible to have object that will respond to every message
<phaul> yes, override method missing. when the method search fails in the inheritance chain, it starts invoking method missing. If that finds anything it's executed instead. (top level will implement it and that's what causes the method missing error)
<phaul> by top leve I mean top of the inheritance chain
<phaul> &ri method_missing
<rubydoc> I found 13 entries matching method method_missing. Use &list method_missing if you would like to see a list
<TCZ> phaul i mean something like nil but returning nil when method is called on it
<phaul> that's a slightly different question
<phaul> we have safe nagiator op for that purpose
<phaul> &>> nil&.anything
<rubydoc> # => nil (https://carc.in/#/r/8r52)
<TCZ> oh thanks
<phaul> np
<phaul> also on a higher architectural level you can look into the null object pattern. &. is a ni check, which can be considered as a code smell
drincruz_ has quit [Ping timeout: 250 seconds]
<TCZ> if im clicking on screen and no object is clicked i should &click on nil or create background so i always have something to click on? ;p
mthsgrc has joined #ruby
caterfxo has quit [Quit: leaving]
Technodrome has joined #ruby
d3bug has joined #ruby
TCZ has quit [Quit: Leaving]
TCZ has joined #ruby
leeijaw has joined #ruby
leeijaw has left #ruby [#ruby]
Swyper has quit []
TCZ has quit [Quit: Leaving]
banisterfiend has joined #ruby
iNs has quit [Quit: bubye]
iNs has joined #ruby
kristian_on_linu has joined #ruby
troulouliou_dev has quit [Quit: Leaving]
troulouliou_div2 has joined #ruby
caterfxo has joined #ruby
drincruz_ has joined #ruby
cschneid has quit [Ping timeout: 256 seconds]
cschneid_ has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.7.1]
TCZ has joined #ruby
CalimeroTeknik has joined #ruby
william1_ has joined #ruby
william1_ has quit [Ping timeout: 256 seconds]
mojca has quit [Quit: quitting]
ChmEarl has joined #ruby
mojca has joined #ruby
Esa_ has joined #ruby
ExoUNX has quit [Quit: later fam...]
sauvin_ has joined #ruby
sauvin has quit [Ping timeout: 250 seconds]
Technodrome has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sauvin_ is now known as sauvin
sergioro has joined #ruby
william1_ has joined #ruby
drincruz_ has quit [Ping timeout: 250 seconds]
alfiemax has joined #ruby
troulouliou_div2 has quit [Quit: Leaving]
conta has joined #ruby
Technodrome has joined #ruby
alexherbo2 has joined #ruby
drincruz_ has joined #ruby
alfiemax has quit [Ping timeout: 250 seconds]
conta has quit [Quit: conta]
<xco> I created my first gem reviews, contributions are welcome! I'll appreciate it :) https://github.com/siaw23/kovid
<xco> 😷
<xco> havenwood i'll appreciate serious critiques from you as well as from
<adam12> xco: Looks great, but I would of left the exe folder.
<xco> phaul ;)
<xco> and from everyone :)
<xco> adam12 i think you told me there's no "rule" around where the executable file goes
<xco> ?
<xco> aaah it wasn't you
<adam12> xco: Sure, but that folder now has other files such as console and setup.
<xco> adam12 havenwood told me that
<adam12> xco: Which will conflict with any other gem that does exactly the same thing.
<xco> right i can move it
<adam12> xco: It happens to lots of people. Here's a recent one for the Wisper gem. https://github.com/krisleech/wisper/issues/180
<xco> ooo i see
<xco> fixing now
noboruma has joined #ruby
TCZ has quit [Quit: Leaving]
chalkmonster has joined #ruby
Emmanuel_Chanel has quit [Ping timeout: 250 seconds]
Esa_ has quit []
orbyt_ has joined #ruby
cschneid has joined #ruby
cschneid_ has quit [Ping timeout: 256 seconds]
SuperL4g has joined #ruby
drincruz_ has quit [Ping timeout: 256 seconds]
chalkmonster has quit [Quit: WeeChat 2.7.1]
SuperL4g has quit [Quit: leaving]
Fridtjof has quit [Quit: ZNC - http://znc.in]
Fridtjof has joined #ruby
drincruz_ has joined #ruby
KramerC has quit [Read error: Connection reset by peer]
KramerC has joined #ruby
banisterfiend has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Emmanuel_Chanel has joined #ruby
alexherbo2 has quit [Ping timeout: 264 seconds]
ChmEarl has quit [Quit: Leaving]
noboruma has quit [Remote host closed the connection]
noboruma has joined #ruby
hassox has joined #ruby
fluxAeon has joined #ruby
SuperL4g has joined #ruby
jcalla has quit [Read error: Connection reset by peer]
ExoUNX has joined #ruby
bvdw has quit [Read error: Connection reset by peer]
bvdw has joined #ruby
fluxAeon has quit [Ping timeout: 258 seconds]
SuperL4g has quit [Quit: WeeChat 2.7.1]
SuperLag has quit [Quit: leaving]
SuperL4g has joined #ruby
SuperL4g is now known as SuperLag
<phaul> nil&.nil?
<phaul> &>> nil&.nil?
<rubydoc> # => nil (https://carc.in/#/r/8r5q)
fluxAeon has joined #ruby
<leftylink> in this situation, it is appropriate to say "correct! nil!"
<leftylink> and not say "wat"
SuperLag has quit [Remote host closed the connection]
alexherbo2 has joined #ruby
sergioro has quit [Ping timeout: 256 seconds]
cd has quit [Quit: cd]
<phaul> that was my guess too..
sergioro has joined #ruby
mniip has quit [Ping timeout: 606 seconds]
SuperLag has joined #ruby
ChmEarl has joined #ruby
mniip has joined #ruby
ur5us has joined #ruby
drincruz_ has quit [Ping timeout: 264 seconds]
alexherbo20 has joined #ruby
mniip has quit [Ping timeout: 600 seconds]
alexherbo2 has quit [Ping timeout: 240 seconds]
alexherbo20 is now known as alexherbo2
CalimeroTeknik has quit [Quit: バイバイ]
cschneid has quit [Ping timeout: 256 seconds]
cschneid_ has joined #ruby
mniip has joined #ruby
sergioro has quit [Quit: leaving]
phaul has quit [Ping timeout: 246 seconds]
phaul has joined #ruby
dviola has joined #ruby
drincruz_ has joined #ruby
drincruz_ has quit [Ping timeout: 250 seconds]
ellcs has quit [Ping timeout: 246 seconds]
ellcs has joined #ruby
TCZ has joined #ruby
markopasha has quit [Remote host closed the connection]
<havenwood> &>> nil&.itself.nil?
<rubydoc> # => true (https://carc.in/#/r/8r5s)
<havenwood> &>> -2 ** 2
<rubydoc> # => -4 (https://carc.in/#/r/8r5t)
<havenwood> &>> -2.itself ** 2
<rubydoc> # => 4 (https://carc.in/#/r/8r5u)
<havenwood> ¯\_(ツ)_/¯
<havenwood> Reminds me of this issue ticket: https://bugs.ruby-lang.org/issues/16677
<al2o3-cr> nil&.itself.nil? = nil.nil? no &. operand being performed. -2.itself ** 2 is just a precedence issue.
markopasha has joined #ruby
<al2o3-cr> &>> -(2.itself) ** 2
<rubydoc> # => -4 (https://carc.in/#/r/8r5v)
markopasha has quit [Max SendQ exceeded]
<al2o3-cr> &. returns nil if there is a nil in the chain.
<rubydoc> parser error at position 0 around `.'
markopasha has joined #ruby
clemens3 has quit [Read error: Connection reset by peer]
rmnull has quit [Quit: WeeChat 2.7.1]
rmnull has joined #ruby
d3bug has quit [Quit: Connection closed for inactivity]
markopasha has quit [Remote host closed the connection]
_phaul has joined #ruby
markopasha has joined #ruby
drincruz_ has joined #ruby
<havenwood> al2o3-cr: Yeah, not the same issue, just both become as expected by adding a `.itself`.
<havenwood> al2o3-cr: And both are not as expected without it.
phaul has quit [Ping timeout: 264 seconds]
<havenwood> al2o3-cr: That's an interesting class of bugs.
d3bug has joined #ruby
<leftylink> unfair
<al2o3-cr> why would that be expected?
<al2o3-cr> i don't get it.
<havenwood> "not as expected"
drincruz_ has quit [Ping timeout: 256 seconds]
<al2o3-cr> nil&.itself is just nil
<leftylink> unfair because the .itself was inserted between & and .
<leftylink> you wouldn't say -2*.itself*2
<havenwood> al2o3-cr: I mean that the `.nil?` check then returns `true`, as expected.
<havenwood> al2o3-cr: I'm commenting on a user perspective, where something being itself is presumed to not change behavior.
<havenwood> al2o3-cr: The syntax involved changes, no doubt.
<al2o3-cr> havenwood: it doesn't you not applying the operand.
<al2o3-cr> *your
<al2o3-cr> itself will always return itself.
<al2o3-cr> if there is a nil anywhere in the chain it will result in nil
code_zombie has joined #ruby
<al2o3-cr> so that, nil&.nil? is expected to be nil.
<al2o3-cr> if you get what i'm saying.
<havenwood> al2o3-cr: Yeah, that's fair—and I remember an issue ticket along those lines from back when it was added.
<havenwood> al2o3-cr: It just reminded me of the other issue, but you're right this one isn't a bug. Matz says neither are. I'm not so sure on the (-2) one.
ule has quit [Remote host closed the connection]
william1_ has quit [Ping timeout: 250 seconds]
<al2o3-cr> havenwood: cool, no worries, it just seems a lot of people have trouble understanding the sno or lo.
ule has joined #ruby
<havenwood> al2o3-cr: sno lo?
<al2o3-cr> safe navigation operator or lonely operator ;)
<havenwood> al2o3-cr: Baby is now asleep, so my brain is present. :)
<al2o3-cr> you made me type it ;( lol
<havenwood> Haha
<al2o3-cr> :P
<al2o3-cr> xco: btw, in the kovid gem you created, you'd still need to create a custom cache class and pass an instance of that class to Typhoeus::Config.cache for it to work.
<al2o3-cr> havenwood: you getting much sleep?
<havenwood> al2o3-cr: never do
<havenwood> al2o3-cr: so at least that stays the same :)
<al2o3-cr> i can imagine :)
<al2o3-cr> she'll be a ruby ninja in no time :P
<havenwood> xco: Congrats on cutting your first gem!
william1_ has joined #ruby
<al2o3-cr> xco: it's pretty awesome!
<xco> al2o3-cr yeah i know something was off there but that's why i waited for a review, the custom cache class would be the one in the their README already right?
<al2o3-cr> xco: exactly.
<xco> havenwood thanks :)
<xco> al2o3-cr thank you :D
<al2o3-cr> xco: don't forget to pass it to `Typhoes::Config.cache` though ;)
<al2o3-cr> xco: and your welcome
snuz has joined #ruby
ellcs has quit [Ping timeout: 246 seconds]
<xco> al2o3-cr you're talking about this? https://gyazo.com/b91428cdd810c14927f6d56ff36de656
<al2o3-cr> yup
<havenwood> xco: Happy to do a review!
<havenwood> xco: It's nice to have an alias file load the original, rather than repeat the code.
<havenwood> xco: For example, from Ruby source: https://github.com/ruby/ruby/blob/master/lib/optionparser.rb
<xco> al2o3-cr ah ok, i can make a separate class to get that fixed!
<al2o3-cr> xco: sure.
<havenwood> xco: I'd do that in `covid`: https://github.com/siaw23/kovid/tree/master/exe
<havenwood> xco: A nit, but I think it'd be cleaner to do away with the `nineteen` namespace and have that behavior in `Kovid`.
<xco> havenwood you mean the aliasing of "covid"?
<havenwood> xco: The `kovid` and `covid` files.
<havenwood> xco: exe/ ones
<xco> aha, what about those?
<xco> i copied code that's true but i didn't know how else to go about that, knew there's a better way
<havenwood> xco: They look great, but I'd have the alias one require_relative the other—rather than pasting contennt.
<havenwood> xco: Then you can make updates in one place.
<xco> oooooooo
<xco> then i could have one of the files empty right?
<xco> is that what you mean?
<xco> but the link you showed me is a .rb file :/
<xco> i'm confused :D
<havenwood> xco: Yeah, that's library style.
<havenwood> xco: Sorry, the same pattern applies to executables and loadable libraries.
drincruz_ has joined #ruby
<havenwood> xco: You have the alias load the original rather than repeating the content.
<havenwood> xco: TL;DR: Have `covid` just `require_relative 'kovid'`.
<xco> :D
<xco> got it
<havenwood> xco: The I feel like Kovid::Nineteen should be moved into Kovid, just so other conventions work more cleanly and to make it simpler. I could though see why you like it like you have it. I'd still flatten it, personally.
davispuh has joined #ruby
<xco> i know some people would, i feel more comfortable this way, got enough "bashing" for doing it like how you're saying now and got used to this style
<havenwood> xco: You could put the functions inside `class << self` at top level in Kovid, with just a `module_function`. These seem fairly reasonable includable, so that'd be a nice flexibility. And, none of these are private, so module_function works well.
<xco> i used to do it like how you're describing it
<xco> oh i even forgot about module_function!!!
<xco> that's a good idea
<havenwood> xco: Then You'd have Kovid require Kovid::Request, and I'd move Tableize to kovid/request/tableize.
drincruz_ has quit [Ping timeout: 240 seconds]
<havenwood> xco: That way, Kovid requires Kovid::Request which requires Kovid::Request::Tableize.
<xco> got it
<havenwood> xco: To me, that structure mirrors the hierarchy.
ellcs has joined #ruby
<xco> havenwood thanks a lot... unless you have more review comments :)
<havenwood> xco: cli.rb looks good to me. When I see an `if Hash#[]` I often consider Hash#fetch. https://github.com/siaw23/kovid/blob/master/lib/kovid/cli.rb#L16
<havenwood> xco: Nevermind that.
<xco> ;)
<havenwood> I might extract a `FULL_FLAG = %w[-f --full].freeze` here: if name[-1] == '-f' || name[-1] == '--full'
<al2o3-cr> xco: 18 stars already ;)
<xco> al2o3-cr you rock!
<havenwood> xco: Then: if FULL_FLAG.include?(name.fetch(-1))
<xco> havenwood now that's sexy :D
<havenwood> xco: name = name[1..-1]
<xco> which line is that? i forgot where i wrote what? :D
snuz has quit [Ping timeout: 250 seconds]
<havenwood> xco: Those are my only comments for cli.rb. Looks good.
<xco> **facepalm**
<xco> but i'm happy you're pointing these out now, i have like a list of things to fix...this whole things was than quickly!!
<havenwood> xco: I'd also extract these into constants, which will reduce the number of Strings created: https://github.com/siaw23/kovid/blob/master/lib/kovid/request.rb#L45-L46
<xco> yup!
<xco> for that i'd actually like to write a URI builder
<xco> and have the refactorised properly
<havenwood> xco: rows = ["Thakfully...
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
<xco> ;)
<xco> +1
<havenwood> xco: Ah, I see - there are various paths. You could have a single Hash constant for paths or just several constants.
<havenwood> xco: I'd extract constant on the headings arrays in tableize.rb too.
snuz has joined #ruby
<xco> you mean you'd make the headings a constant?
<havenwood> xco: Yup
<xco> some of the headings repeat so i can move them up a scope as constant
<xco> i believe that's what you mean too
<havenwood> xco: Yeah, by making them constants you can have just one version of them that the method can use each time.
<havenwood> xco: Like: COUNTRY_HEADINGS = [...].freeze
<xco> yeah those are on my list of todos while i get a lot of the things pushed, but i'm keeping this convo to as reference for things i may forget so keep'em coming :D
<havenwood> xco: It just reduces object churn by the GC. It's only a nit, but I just do it uniformly on things that are constant.
<havenwood> xco: Mostly repeats from here, like `rows = data.map ...` here: https://github.com/siaw23/kovid/blob/master/lib/kovid/tablelize.rb#L50-L54
<xco> +1
<xco> it's the same thing from the previous file
<xco> noted
<havenwood> rows = data.map do |country|; country.values_at('countries, 'cases', ...)` here: .values_at
<xco> +2
<havenwood> xco: That's all I've got for lib/. Good stuff!
<xco> THANK YOU! if i discover a cure for the virus you'll be the first to know
snuz has quit [Quit: WeeChat 2.7.1]
markopasha has quit [Remote host closed the connection]
snuz has joined #ruby
roadie has quit [Ping timeout: 250 seconds]
ferche23 has joined #ruby
cschneid has joined #ruby
cschneid_ has quit [Ping timeout: 240 seconds]
dhoc has joined #ruby
jmcgnh has quit [Ping timeout: 256 seconds]
<xco> al2o3-cr do you perhaps have an explanation for this? https://gyazo.com/4133b9f154c056209712b68c876f2e37
<xco> look at line 21
<xco> first get to my blog is not cached
sergioro has joined #ruby
<xco> is it because i already have Typhoeus::Config.cache = Cache.new earlier that the caching is happening?
jmcgnh has joined #ruby
<al2o3-cr> no, it's because the time to live hasn't exceeded.
dhoc has quit [Quit: Textual IRC Client: www.textualapp.com]
<al2o3-cr> you'd have to wait 1 hour.
jetchisel has quit [Quit: Unfortunately time is always against us -- [Morpheus]]
<xco> i exited irb and came back
jetchisel has joined #ruby
<al2o3-cr> i don't see a problem.
<xco> i was confused whether the Cache class was doing anything
<xco> got it now :)
dhoc has joined #ruby
dionysus69 has joined #ruby
<al2o3-cr> xco: oh, right, yes. you exited the process so the cache was invalidated.
<al2o3-cr> that would of returned true.
<xco> :D :D
dhoc has quit [Client Quit]
<al2o3-cr> xco: your confusing me now ;)
<al2o3-cr> paste text in future not images ;)
<al2o3-cr> xco: that's with the cache class added, btw.
<xco> oh sorry
william1_ has quit [Ping timeout: 256 seconds]
<al2o3-cr> xco: cache_ttl kw has no effect if Config.cache is not set.
<xco> yup got that now with my little experiment
yokel has quit [Ping timeout: 264 seconds]
<al2o3-cr> at least your using the best net gem out there currently, imo.
<havenwood> xco: You might consider keeping a single connection open to make the various calls, or even make them in parallel with Hydra.
<al2o3-cr> HTTparty is just a wrapper for net/http.
<al2o3-cr> havenwood: +1 ^
<havenwood> al2o3-cr: And it parties too hard.
<al2o3-cr> hehe ;) yes, i suppose it does.
<havenwood> So hard it has a gem install message!
<havenwood> That's too hard.
clemens3 has joined #ruby
<al2o3-cr> xco: make an install message for your gem ;)
dhoc has joined #ruby
<havenwood> al2o3-cr: Typoeus also handily supports gzip, which I presume the server supports, so I'd suggest just using it.
<havenwood> al2o3-cr: accept_encoding: "gzip"
<havenwood> al2o3-cr: oops, wrong nnick
<havenwood> al2o3-cr: I'm more error prone these days. >.>
<al2o3-cr> lol np :P
<havenwood> xco: The server presumably supports gzip, so that'll be a nice way to make the payload way smaller over the wire.
<havenwood> (Not that it's large.)
<al2o3-cr> xco: with using hydra you can still cache requests.
snuz has quit [Quit: WeeChat 2.7.1]
yokel has joined #ruby
fluxAeon has quit [Ping timeout: 240 seconds]
ellcs has quit [Ping timeout: 246 seconds]
drincruz_ has joined #ruby
fluxAeon has joined #ruby
yokel has quit [Remote host closed the connection]
yokel has joined #ruby
dhoc has quit [Quit: dhoc]
drincruz_ has quit [Ping timeout: 246 seconds]
<al2o3-cr> havenwood: what do you make of this: https://gist.github.com/gr33n7007h/fb17b14d1f1ef6e621713a6dd81b4d50
nowhere_man has quit [Read error: Connection reset by peer]
noboruma has quit [Remote host closed the connection]
<havenwood> al2o3-cr: Yeah, I expect the 1st and 3rd behavior, because precedence. The 2nd is interesting.
<al2o3-cr> havenwood: i don't know what to make of this.
<al2o3-cr> why would it be leaving unary -
lucasb has quit [Quit: Connection closed for inactivity]
<al2o3-cr> havenwood:
<al2o3-cr> &>> -2.send(:**, 2).send(:-@)
<rubydoc> # => -4 (https://carc.in/#/r/8r7n)
<havenwood> &>> 2.send(:-@).send(:**, 2)
<rubydoc> # => 4 (https://carc.in/#/r/8r7p)
<al2o3-cr> idk, it's got me this one.
<al2o3-cr> havenwood: i tried that first
<al2o3-cr> it's got to be something to do with unary semantics.
caterfxo has quit [Ping timeout: 240 seconds]
<al2o3-cr> &>> [[-2 ** 2, -2.itself ** 2], [+2 ** 2, +2.itself ** 2], [~2 ** 2, ~2.itself ** 2], [!2 & true, !2.itself & true]]
<rubydoc> # => [[-4, 4], [4, 4], [9, 9], [false, false]] (https://carc.in/#/r/8r7t)
<al2o3-cr> havenwood:
<al2o3-cr> &>> %i(+@ -@).map { 0.method(_1) }
<rubydoc> # => [#<Method: Integer(Numeric)#+@()>, #<Method: Integer#-@()>] (https://carc.in/#/r/8r7u)
drincruz_ has joined #ruby
<al2o3-cr> unary - is only on Integer class, whereas + is inherits from Numeric.
<TCZ> &>> nil &+ 2
<rubydoc> # => false (https://carc.in/#/r/8r80)
<TCZ> &>> nil &* 2
<rubydoc> stderr: -e:4: syntax error, unexpected *... check link for more (https://carc.in/#/r/8r81)
xco has quit [Quit: Textual IRC Client: www.textualapp.com]
fluxAeon has quit [Ping timeout: 250 seconds]
TCZ has quit [Quit: Leaving]
<_phaul> omg, or whatever it is appropriate to say right now
schne1der has quit [Ping timeout: 264 seconds]
fluxAeon has joined #ruby
tfreedman has left #ruby ["User left"]
<_phaul> what is &+ in simple terms? and why is it not &*
<al2o3-cr> _phaul: take it easy
ChmEarl has quit [Ping timeout: 250 seconds]
<_phaul> i'm easy. I've not read the discussion.. is this something I would understand from there?
<al2o3-cr> _phaul: which one?
<_phaul> nil &+ 2 being a valid expression in the first place
ChmEarl has joined #ruby
<al2o3-cr> no, not that. -2.itself ** 2 equaling 4.
<leftylink> I see I was tricked. nicely done.
<leftylink> but now I have learned, and will not be tricked
<leftylink> again in the future, I mean to say
<leftylink> I congratulate the one who came up with the trick, it was quite clever. it would have been less clever if it looked something like its true form... but that is the nature of all trickery, I guess
<leftylink> &>> 1 &+-+-+-+-+-+-+-+-+-+-+- 1
<rubydoc> # => 1 (https://carc.in/#/r/8r83)
<leftylink> now you see.
<leftylink> that makes it much less tricky
caterfxo has joined #ruby
<leftylink> do not expect to trick me again with that in the future
<al2o3-cr> roger that leftylink ;)
<leftylink> it is good that I get periodically reminded of the potential for trickery in the language... keeps me honest
<leftylink> and prevent from letting my guard down
<al2o3-cr> leftylink: are you entering into a karate tournament? don't be so hard on "self"
<_phaul> so now, ..., can you explian to the rest of us what is happening here
<al2o3-cr> who?
<leftylink> there is a unary +, but there is no unary *
<leftylink> ... unless we're talking about splats I guess, but there was no splatting going on there
<al2o3-cr> leftylink: nil & false will always be false. nil &+ 2 is is object (nil) & object (+2)