<thebananaking>
I've got an X/Y problem - I think I'm using entirely the wrong tool for the job, and I could use some advice on how I should be going about this from the ground up
<thebananaking>
I'm trying to write a suite of tests for our user/dev environment - basically running a bunch of shell commands to see if software updates/changes have broken things
<thebananaking>
I've been poking at test/unit, but it seems like a slightly dodgy fit for what I want - it seems more suited to testing code itself
Technodrome has joined #ruby
bluvinyl has quit [Ping timeout: 250 seconds]
mwlang_ has quit [Quit: mwlang_]
wildtrees has quit [Quit: Leaving]
<Iambchop>
thebananaking: serverspec? what kind of breakage are you testing for?
<thebananaking>
things like 'oh he installed a new glibc and didn't test that students can still run ghc'
<thebananaking>
which happens. A lot.
<thebananaking>
dev==test==prod
davidw has quit [Ping timeout: 240 seconds]
<thebananaking>
and yes, I know.
NODE has quit [Quit: changing servers]
NODE has joined #ruby
johnny56 has quit [Ping timeout: 240 seconds]
jenrzzz has joined #ruby
Tempesta has quit [Quit: AdiIRC is updating to v3.8 Beta Build (2019/12/09 UTC) 64 Bit]
Tempesta has joined #ruby
johnny56 has joined #ruby
Creatornator has joined #ruby
lucasb has quit [Quit: Connection closed for inactivity]
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Swyper_ has quit [Remote host closed the connection]
Swyper has joined #ruby
wallace_mu has quit [Remote host closed the connection]
wallace_mu has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.6]
wallace_mu has quit [Ping timeout: 250 seconds]
brool has quit [Ping timeout: 246 seconds]
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
Swyper has quit [Remote host closed the connection]
schne1der has joined #ruby
donofrio has quit [Remote host closed the connection]
bvdw has quit [Read error: Connection reset by peer]
sphex has quit [Remote host closed the connection]
bvdw has joined #ruby
schne1der has quit [Ping timeout: 265 seconds]
salerace has joined #ruby
salerace has quit [Client Quit]
salerace has joined #ruby
salerace has quit [Quit: salerace]
salerace has joined #ruby
sauvin has quit [Ping timeout: 250 seconds]
salerace has quit [Quit: salerace]
Technodrome has joined #ruby
Technodrome has quit [Remote host closed the connection]
sauvin has joined #ruby
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
xco has joined #ruby
Swyper has joined #ruby
orbyt_ has joined #ruby
Swyper has quit [Ping timeout: 246 seconds]
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
SeepingN has joined #ruby
jenrzzz has quit [Ping timeout: 252 seconds]
jenrzzz has joined #ruby
xco has joined #ruby
fphilipe has joined #ruby
Swyper has joined #ruby
andikr has joined #ruby
SeepingN has quit [Quit: The system is going down for reboot NOW!]
Mrgoose845701915 has quit [Ping timeout: 268 seconds]
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Swyper has quit [Remote host closed the connection]
Swyper has joined #ruby
Swyper has quit [Remote host closed the connection]
infinityfye has joined #ruby
sphex has joined #ruby
CrazyEddy has joined #ruby
<cxl>
Morning all! How could I write an attr_writer for a hash that memoizes? I'd like it so that when I do `my_var[:foo] = :bar` it actually does `my_var[:foo] ||= :bar` without my havving to remember the ||= every time I assign to it.
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
TomyWork has joined #ruby
<ytti>
i guess you could define your own hash style class - http://p.ip.fi/O6s-
<ytti>
and you'd do ||= in that method to assign value
Axy has joined #ruby
ur5us has joined #ruby
Mia has quit [Ping timeout: 245 seconds]
vondruch has joined #ruby
ur5us has quit [Remote host closed the connection]
ur5us has joined #ruby
prestorium has joined #ruby
<_phaul>
I think my_var[:foo] = :bar; my_var[:foo] # => :not_bar is confusing. I would much rather be explicit with ||=
r3m has quit [Quit: WeeChat 2.7-rc1]
r3m has joined #ruby
Fernando-Basso has joined #ruby
ur5us has quit [Remote host closed the connection]
ur5us has joined #ruby
fphilipe has quit [Ping timeout: 250 seconds]
Swyper has joined #ruby
Swyper has quit [Ping timeout: 250 seconds]
fphilipe has joined #ruby
conta has joined #ruby
ellcs has joined #ruby
dionysus69 has joined #ruby
fphilipe has quit [Ping timeout: 246 seconds]
cadabrax has joined #ruby
dionysus69 has quit [Remote host closed the connection]
dionysus69 has joined #ruby
romanblanco has joined #ruby
claudiuinberlin has joined #ruby
ellcs has quit [Ping timeout: 250 seconds]
Nahra has joined #ruby
Nahra has joined #ruby
fphilipe has joined #ruby
Nicmavr has quit [Read error: Connection reset by peer]
Nicmavr has joined #ruby
romanblanco has quit [Quit: Quit]
romanbla1co has joined #ruby
Fernando-Basso has quit [Quit: Leaving]
reber has joined #ruby
moonshine_ has joined #ruby
imadper is now known as iMadper|garbagem
moonshine1 has joined #ruby
moonshine1 has quit [Client Quit]
<moonshine_>
I'm new to this language can you suggest if you guys know better resource?
ur5us has quit [Ping timeout: 250 seconds]
cd has quit [Quit: cd]
<dionysus69>
wanted to ask if it is worth switching to rubymine, sometimes I see my coworkers do some cool stuff in it, like super easy breakpoints, and lots of other features, currently I use sublime text 3
<ytti>
i'm not jetbrains user, but probably
<dionysus69>
just post your experiences when and if you switched from text editor to an IDE
<ytti>
i'm just habitual vim user, but it's not because vim is good
<ytti>
i'm pretty confident if i'd put in the hours to learn IDE, i'd be much more productive with proper IDE
<dionysus69>
yea VIM is just too much for me, seems like I need to be a VIM developer not a rails developer :D
im0nde has quit [Ping timeout: 250 seconds]
im0nde_ has joined #ruby
<ytti>
and really what is the whole jetbrains toolbox, like 150bucks/year?
_phaul has quit [Ping timeout: 240 seconds]
<ytti>
so what, 40cents/day
<dionysus69>
dunno, nothing that a developer can't effort if he/she needs it ^.^
<ytti>
if that tool makes you more productive, it's stupid c heap
<dionysus69>
yea its stupid cheap compared to MS/WIN ecosystem
moonshine_ has quit [Ping timeout: 265 seconds]
<ytti>
i had recently friend switch from visual studio code to jetbrains, and he's extremely happy
<ytti>
said it saves him several hours every week
romanbla1co has quit [Quit: leaving]
<ytti>
bought the toolbox as he developes in python, ruby, go
<ytti>
and is frustraded he didn't do it before
<ytti>
i've not seen the light, but it's mostly of my own complacancy
_phaul has joined #ruby
nowhereman has quit [Ping timeout: 276 seconds]
conta1 has joined #ruby
conta1 has quit [Remote host closed the connection]
_phaul has quit [Ping timeout: 252 seconds]
conta has quit [Ping timeout: 250 seconds]
_phaul has joined #ruby
lxsameer has joined #ruby
solars has joined #ruby
_phaul has quit [Ping timeout: 245 seconds]
_phaul has joined #ruby
_phaul has quit [Ping timeout: 250 seconds]
_phaul has joined #ruby
_phaul has quit [Ping timeout: 250 seconds]
_phaul has joined #ruby
Guest21040 has quit [Ping timeout: 264 seconds]
_phaul has quit [Ping timeout: 265 seconds]
dasher00 has joined #ruby
ellcs has joined #ruby
_phaul has joined #ruby
<shaman42>
TomyWork:
<shaman42>
oopsie sorry.
Bish has joined #ruby
_phaul has quit [Ping timeout: 250 seconds]
<Bish>
ytti: so loop is intended to be called by the user and you use the block to block until it's finished, i got that
<Bish>
how would you write a program though, that has many connections at once?
<Bish>
and many fowards and channels in parallel?
<Bish>
(talking Net::SSH) ofcourse
<ytti>
Bish, multipple channels or multiple sessions?
<Bish>
both
<Bish>
i tried to inherit from your eventloop.. and tried to esentially loop forever.. but then calls like ch.wait don't know when they're "done" and exec! etc stop working
donofrio has joined #ruby
_phaul has joined #ruby
_phaul has quit [Ping timeout: 252 seconds]
_phaul has joined #ruby
_phaul has quit [Ping timeout: 265 seconds]
_phaul has joined #ruby
infinityfye has quit [Remote host closed the connection]
infinityfye has joined #ruby
_phaul has quit [Ping timeout: 246 seconds]
prestorium has quit [Quit: prestorium]
infinityfye has quit [Remote host closed the connection]
infinityfye has joined #ruby
prestorium has joined #ruby
_phaul has joined #ruby
_phaul has quit [Ping timeout: 250 seconds]
yann-kaelig has joined #ruby
_phaul has joined #ruby
_phaul has quit [Ping timeout: 268 seconds]
bvdw has quit [Read error: Connection reset by peer]
bvdw has joined #ruby
_phaul has joined #ruby
reber has quit [Ping timeout: 240 seconds]
_phaul has quit [Ping timeout: 265 seconds]
_phaul has joined #ruby
lineus has quit [Ping timeout: 260 seconds]
sergioro has left #ruby [#ruby]
<cadabrax>
I never quite got IDEs
lineus has joined #ruby
<cadabrax>
it feels like using a text editor forces me to think about how the code is actually put together
_phaul has quit [Ping timeout: 240 seconds]
<cadabrax>
the only thing that annoys me to no end is that it's impossible to copy from vim within tmux and paste on dpaste.de/gist etc
<cadabrax>
I have to `less myfile.rb` and visual select with tmux and put it in the OS's clipboard.
<cadabrax>
same with frontends for git. Yes the commands take more effort to learn but if you don't understand how git works you're going to have a hard time regardless when you need to go beyong add/commit/push. To wit, most (all?) my colleagues use git tower or something like that and they have no clue what to do if it doesn't exactly go add > commit > push.
_phaul has joined #ruby
_phaul has quit [Ping timeout: 240 seconds]
<Bish>
don't use IDEs then
_phaul has joined #ruby
<Bish>
public opinion is shifting in your direction, seeing the editors getting less bloated
<Bish>
vscode is basicially a editor, and not an IDE
<ytti>
git has great UX
<ytti>
you type your question to google
<ytti>
click on stackexchange page
<ytti>
and copy paste the command string
<Bish>
ytti: are you going to answer me, too :p?
<ytti>
Bish, i think you call the loop for whole session, so all channels move forward
<ytti>
Bish, so if you do multisession, like thread per session, each of these threads separately should call the ssh.loop when they want more data
<ytti>
like you'd do
<Bish>
hm, okay
<ytti>
@ssh.loop(0.1) do
<ytti>
something
<ytti>
return bool
<ytti>
end
<ytti>
actually no return, but implicit return true, to continue looping
<ytti>
and exit with return if you want to out of the loop
<Bish>
or next and break, that is, isn't it?
<ytti>
like you'd loop while waiting for shell to match the string you want
<ytti>
and once you get the match, you exit the loop and do your thing
<ytti>
once you again need more data, you loop again
<Bish>
i don't know i would've liked to not have tod o that manually :/
<ytti>
i don't know if next continues looping
<Bish>
a single thread in the background with mutual exclusion
<ytti>
@ssh.loop(0.1) do
<Bish>
ytti: it does
<ytti>
match = @output.match something
<ytti>
return match if match
<ytti>
true
<ytti>
end
<ytti>
i guess would be realistic example
<Bish>
yeha i'd never write code like that :D
<ytti>
why?
<Bish>
it feels like busy waiting
<ytti>
but that is what shell is, right?
<ytti>
it's async
<ytti>
you get some input from there when you get it
<ytti>
and you have to keep reading input and work when you got what you wanted
<Bish>
so is tcpip, you still abstrac that away, i'd rather look at the whole buffer than doing that
<ytti>
for #exec, you don't have to loop at all
<ytti>
it's just if you open shell channel
<Bish>
primary focus will be on forwards for me
<ytti>
there is no real beginning or end
<ytti>
the ssh protocol doesn't know what's up
<ytti>
should it wait for someting or not
<ytti>
you have to decide that as programmer
<Bish>
sure but this is certainly not the only way to do it
<ytti>
when you want to work on data, and when you want to wait for more
<ytti>
i'm sure it's not, but what would have been your approach?
<ytti>
on_data hook?
<ytti>
which is just syntactic sugar, right?
<Bish>
can you make your example more concrete? because i never had a case like that
<ytti>
well you run command say 'ls'
<ytti>
what do you want to do?
<ytti>
you want to wait for prompt
<ytti>
so you'd do
<ytti>
@ssh.loop(0.1) do
<Bish>
well in the background same thing like you do
<ytti>
match = @output.match /prompt/
<Bish>
your exec! waits for the channel to be closed
<ytti>
return @output if match
<ytti>
true
<ytti>
end
<ytti>
you'd keep looping, until you see the shell prompt (i.e. end of 'ls')
<ytti>
yes, for exec ytou dno't need #loop
<ytti>
if you do exec there is no need for this
<ytti>
you need #loop if you ope nshell channel
<Bish>
yeah do you have an example where you need this?
<ytti>
you have no idea when 'ls' stopped outputting
<ytti>
when you need to open shell?
_phaul has quit [Ping timeout: 240 seconds]
andikr has quit [Ping timeout: 268 seconds]
banisterfiend has joined #ruby
<Bish>
well who does that :D and why?
<ytti>
maybe you're running program which wants input
<ytti>
but if you can get away using #exec, you should always use exec channel
<Bish>
yeah even the i would've designed it that way
<Bish>
that i have a stdin and a stdout
<ytti>
LOT of SSH implementations close session when first channel closes :(
<ytti>
so if you want to run >1 command
<ytti>
you either open shell channel, or you do new TCP session for every command
<Bish>
and writing and reading would be just like with popen
<ytti>
but always try to avoid opening shell in ssh if you can avoid it
<ytti>
exec makes things so much easier as there is obvious beginning and end to output
<ytti>
shell doesn't have it, you're force to do shit like prompt detection
<Bish>
well i simply wouldn't do that , i just want a ruby native implementation
<Bish>
but this loop stuff is designed like a C gameengine
<Bish>
i really dont see the benefits of that
<Bish>
doesn't feel ruby-idomatic ot me
andikr has joined #ruby
arooni_team_b has joined #ruby
dviola has quit [Quit: WeeChat 2.6]
arooni has quit [Ping timeout: 240 seconds]
<ytti>
i still don't quite understand what would be the superior alternative way
<ytti>
you say popen
<ytti>
but that's like syntactic sugar to this
<Bish>
yes.. and ruby is nothing but syntactic sugar
<ytti>
dunno
<ytti>
i mean with popen you dn't control when new data arrives
<ytti>
you don't know what the state is
<ytti>
with this, you can halt the world
<ytti>
if you do it outside loop, state won't c hange until you go back to the loop
<ytti>
if it was just popen, you'd have no option but to be inside loop with dynamic state
<ytti>
there is no reason why you can't write few lines method to turn loop into popen
<ytti>
and treat it like that
<MrCrackPot>
Im getting a weird parse error from Date. My string is mm/dd/yyyy (01/02/2019) so i used Date.parse(date_string, '%m/%d/%Y')
<Bish>
ytti: it makes my code less pretty
<Bish>
if you call read on a normal IO it blocks.. why wouldn't that be the case for a "remote stdin"
<MrCrackPot>
but the Date.parse returns invalid date if i do (01/23/2019) but ok if (21/01/2019)
<Bish>
MrCrackPot: use strfdate
<ytti>
i'm not sure i understand
<MrCrackPot>
ah thats my problem haha thanks Bish
<Bish>
MrCrackPot: Date and DateTime use different (not standardized) styles of dates
<ytti>
you have #on_data
<ytti>
if that's all you care
<ytti>
you can register on_data
<ytti>
and just call @ssh.loop
<ytti>
without parameters
<Bish>
yeah but i have to do that, and call loop and make sure the loop doesnt run before the actual handlers regiersted
<ytti>
to get it going
<ytti>
and you'd like implicit call on @ssh.loop
<ytti>
after all is said and done?
<Bish>
yeah if i have say.. 100 connections ? i have 100 threads which all hae their own loops
<Bish>
that doesn't sound right
<Bish>
why not have one eventloop (why does Net::SSH have that feature, either way?)
<Bish>
which makes things possible like stdin,stdout = session.shell('bash')
<Bish>
and i don't care what happens in the background
<MrCrackPot>
Bish you sure its strfdate all i can find in docs is strftime
<Bish>
MrCrackPot: yeah that's what i meant
<MrCrackPot>
ah thanks
<Bish>
personally i would go with iso8601, atleast as long it should not be human-readable
<Bish>
that always does the trick for dates, time, you name it
<Bish>
date with timezones, no problem
<Bish>
&> Date.today.iso8601
<rubydoc>
parser error at position 0 around `>'
<Bish>
&>> Date.today.iso8601
<rubydoc>
stderr: -e:4:in `<main>': uninitialized constant Date (NameError)... check link for more (https://carc.in/#/r/86d1)
<rubydoc>
stderr: -e:4:in `<main>': undefined method `iso8601' for 2019-12-10 12:14:01 +0000:Time (NoMethodError)... check link for more (https://carc.in/#/r/86d3)