orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jyaworski has quit [Ping timeout: 256 seconds]
orbyt_ has joined #ruby
Jahhein has joined #ruby
Mike11 has joined #ruby
rshetty has joined #ruby
solocshaw has quit [Ping timeout: 260 seconds]
rshetty has quit [Ping timeout: 268 seconds]
solocshaw has joined #ruby
apparition has joined #ruby
Haris has joined #ruby
<Haris>
I'm installing bundle. it gives error when it reaches pg. pg installs header files at custom folder (i.e., /usr/pgsql-9.4/include/ ). How to soft link them under /usr/include or make them available for bundle to get installed normally ?
<Haris>
I'v tried softlinking the folder /usr/pgsql-9.4/include/ to /usr/include/pgsql-9.4, but it doesn't work. bundle can't find pg's headers to build pg. I'v tried soft-linking single files, but reached an error, where it seemed soft linking the folder would be the only way it would work
ogres has quit [Quit: Connection closed for inactivity]
conta has quit [Ping timeout: 268 seconds]
rippa has joined #ruby
Puffball has quit [Remote host closed the connection]
Mike11 has quit [Quit: Leaving.]
_aeris_ has quit [Ping timeout: 256 seconds]
_aeris_ has joined #ruby
ledestin has joined #ruby
kapil___ has joined #ruby
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
marr has joined #ruby
tomphp has joined #ruby
Sauvin has quit [Ping timeout: 260 seconds]
jcarl43 has quit [Quit: WeeChat 2.1]
mniip has quit [Ping timeout: 240 seconds]
blackmesa has joined #ruby
Sauvin has joined #ruby
apparition has quit [Quit: Bye]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Haris>
guys ?
conta has joined #ruby
<Haris>
I'm installing the ruby gem for pg. It can't locate the files installed by pg from pg's yum for 9.4.17
conta has quit [Ping timeout: 260 seconds]
schneider has joined #ruby
blackmesa has quit [Ping timeout: 256 seconds]
Bozo_the_Clown has quit [Remote host closed the connection]
Mia has quit [Ping timeout: 260 seconds]
imode1 has quit [Ping timeout: 264 seconds]
shenghi has quit [Ping timeout: 240 seconds]
shenghi has joined #ruby
CrazyEddy has quit [Ping timeout: 260 seconds]
CrazyEddy has joined #ruby
blackmesa has joined #ruby
blackmesa has quit [Ping timeout: 255 seconds]
alfiemax has joined #ruby
erlend has quit [Ping timeout: 268 seconds]
erlend has joined #ruby
nowhereman_ has quit [Ping timeout: 264 seconds]
p0s1x has joined #ruby
rshetty has joined #ruby
rshetty has quit [Remote host closed the connection]
rshetty has joined #ruby
Haris has left #ruby [#ruby]
p0s1x has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
alfiemax has quit [Remote host closed the connection]
imode1 has joined #ruby
alfiemax has joined #ruby
alfiemax has quit [Remote host closed the connection]
p0s1x has joined #ruby
face has quit [Disconnected by services]
rshetty has quit [Remote host closed the connection]
p0s1x has quit [Client Quit]
alfiemax has joined #ruby
conta has joined #ruby
alfiemax has quit [Ping timeout: 260 seconds]
conta has quit [Ping timeout: 260 seconds]
p0s1x has joined #ruby
rshetty has joined #ruby
apeiros has quit [Read error: Connection reset by peer]
apeiros has joined #ruby
p0s1x has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
kiltzman has quit [Ping timeout: 252 seconds]
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rshetty has quit [Ping timeout: 255 seconds]
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
tomphp has joined #ruby
apparition has joined #ruby
schneider has quit [Ping timeout: 256 seconds]
alfiemax has joined #ruby
alfiemax has quit [Remote host closed the connection]
conta has joined #ruby
kapil___ has quit [Quit: Connection closed for inactivity]
schneider has joined #ruby
zenspider has quit [Quit: bye]
conta has quit [Ping timeout: 248 seconds]
atchoum has joined #ruby
<atchoum>
hello
<atchoum>
I have trouble when using unit tests.
<atchoum>
If I `require` a file with unit test in it, the test is ran each time I require this file.
schneider has quit [Ping timeout: 256 seconds]
<atchoum>
So the same test is rerun 3 or 4 itmes.
<atchoum>
How can I have unit tests running if I only run this file main.rb ?
<atchoum>
not when I `require` it ?
<atchoum>
A possible solution would be to have specialized import, like loading only a module from a given ruby file.
<atchoum>
any idea ?
p0s1x has joined #ruby
ncopa2 has quit [Remote host closed the connection]
rshetty has joined #ruby
leitz has joined #ruby
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
p0s1x has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rshetty has quit [Ping timeout: 264 seconds]
imode1 has quit [Ping timeout: 240 seconds]
tomphp has joined #ruby
physicist__ has quit [Quit: leaving]
<leitz>
If I want an acceptance test suite that lets me run a program from the command line and then the suite evaluates the output, RSpec? Cucumber? Other?
jottr_ has joined #ruby
<leitz>
I'm already planning to learn more rspec.
<atchoum>
I don't get why ruby has such kind of a `primitive` builtin import models
<atchoum>
I mean, it seems very hard to define namespace,
physicist__ has joined #ruby
p0s1x has joined #ruby
<atchoum>
can you have multiple inheritance in ruby by another mean than just using mixins ?
<leitz>
Not directly, as in Python. However, you can have child classes of other child classes. And mixins are pretty powerful.
kapil___ has joined #ruby
rshetty has joined #ruby
<leitz>
atchoum, I'm not a great Ruby programmer, just answering until the smart people wake up. )
<leitz>
Modules mixed in, seem to provide a decent namespace.
<atchoum>
yes
<atchoum>
that's what i am doing right now, it seems you can actually structure your code in a convenient way
<atchoum>
Module stuff is a powerful abstraction
<atchoum>
I am too used to the python rigid type system so ...
<atchoum>
I need to try to continue to practice
rshetty has quit [Ping timeout: 260 seconds]
erlend has quit [Ping timeout: 260 seconds]
<leitz>
atchoum, when you say "I need to try to continue to practice" you are really saying "I will not stop learning." That is a great way to get great.
mjolnird has joined #ruby
<leitz>
Ruby and Python are different. Both are pretty good.
erlend has joined #ruby
dionysus69 has joined #ruby
dr3w_ has joined #ruby
<atchoum>
I have trouble with do blocks associated with iterators
<atchoum>
I assumed that since everything is an expression in ruby, you can do something like ((1..10).each do |x| x*2 end).sum
<atchoum>
it would be then (2..20).sum but is actually (1..10). If I try to use map, then it works. Should I use map really ?
AJA4350 has joined #ruby
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<apeiros>
atchoum: obj.each always returns obj
<apeiros>
atchoum: you want .map instead
<apeiros>
also if you want to chain, use {} instead of do/end, it's much nicer to read
<apeiros>
>> (1..10).map { |x| x*2 }.sum
<ruby[bot]>
apeiros: # => undefined method `sum' for [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]:Array (NoMethodError) ...check link for more (https://eval.in/981879)
<leitz>
atchoum, apeiros is one of those smart people I was talking about. :)
amelliaa has joined #ruby
riotjones has joined #ruby
riotjones has quit [Client Quit]
trautwein has quit [Quit: ZNC 1.6.6 - http://znc.in]
trautwein has joined #ruby
biberu has joined #ruby
venmx has joined #ruby
trautwein has quit [Client Quit]
trautwein has joined #ruby
trautwein has quit [Client Quit]
mjolnird has quit [Remote host closed the connection]
trautwein has joined #ruby
trautwein has quit [Client Quit]
Erlingur has joined #ruby
trautwein has joined #ruby
<atchoum>
say you have a @instance_variable and an `instance` object. How do you get the value of @instance_variable from the `instance` object ?
postmodern has quit [Quit: Leaving]
<apeiros>
access to instance variables from "outside" is only possible via methods
<apeiros>
so either you provide an explicit reader (e.g. via attr_reader :name), or you use Object#instance_variable_get
<apeiros>
the latter is meant mostly for debugging/development, and in rare cases of metaprogramming
<atchoum>
okay
<atchoum>
thanks
<leitz>
apeiros, any opinion on the rspec/cucumber/other mental debate?
<atchoum>
I had written a special method but attr_reader seems fine
<apeiros>
hm? I don't like rspec and prefer minitest. I think cucumber is a great idea but IMO & IME is only worth the effort in rather large companies. no idea about "other mental debate".
p0s1x has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<leitz>
apeiros, my CLI based character generator gives a few lines to STDOUT. I'm reading "Growing Object Oriented Software, Guided By Tests" and it pointed out the value of acceptance testing. That's what I'm looking to do.
<leitz>
Also to learn more rspec, but not sure if that's the right tool for this particuler task.
<apeiros>
leitz: huh? acceptance testing is not an automated task.
<apeiros>
unit & integration tests are
<apeiros>
acceptance testing is whether the users of the software "accept" the changes
<apeiros>
at least that's how I learnt it 🤔
marr has quit [Ping timeout: 248 seconds]
<apeiros>
oh, looking at the WP article, it seems there's a lingual difference. seems in english what I mean is specified in more detail as "user acceptance test" (in german we call it just "acceptance test")
<apeiros>
in that case - not quite sure where the differentiation of non-user acceptance testing and unit/integration tests is
<atchoum>
do you have any idea of a where binding similar to Haskell `where` in ruby ?
<leitz>
unit testing is each class, integration is connections between layers (code connect to database), and acceptance is "Does the output look like it should".
<leitz>
That's the definition list i have so far.
<apeiros>
atchoum: I don't know haskell, so without an explanation, not really, no
<leitz>
In my case, I need to verify that 2-8 lines of output are in the right order, format, and nothing blows up.
<leitz>
Since I'm still learning to code, things blow up a lot. :)
<atchoum>
basically the idea is to have an expression with a binding definition just below the expression
<atchoum>
instead of above
<atchoum>
`let y=3 + x where x = 2`
<atchoum>
defines y = 5
dr3w_ has joined #ruby
<atchoum>
that would be useful but I can also store the result in a variable above my block of code
<atchoum>
the effect would be the same though less elegant perhaps.
<apeiros>
what's the difference to just `y = 3 + x`?
<atchoum>
not that much.
<atchoum>
do you know how one can access ancestor methods in a class ?
<apeiros>
super
<atchoum>
ok
<apeiros>
class A < B; def foo; super; end; end # super will call foo in B, if B doesn't define it, then in B's superclass etc.
<apeiros>
note that super has some rather special syntax rules:
<apeiros>
`super`: invoke the inherited method with all parameters passed to the current method, also keeping all changes via assignment
<apeiros>
`super()` invoke the inherited method without arguments, but will still pass on a block if one was given
<apeiros>
`super(&nil)` also suppresses a passed block
<al2o3-cr>
apeiros: TIL never new about super(&nil)
<apeiros>
yeah, that one cost me half an hour of my life I'll never get back 😅
<al2o3-cr>
;)
<al2o3-cr>
*knew
<atchoum>
hashmap are mutable objects right ? So if do map on a list of dict, you are actually mutating all the objects in place, and so the original list is also modified, right ?
<apeiros>
mutating objects stored in the hashmap and mutating the hashmap itself are two different things
<apeiros>
but yes, if you mutate an object, it is visible everywhere it is referenced
rshetty has joined #ruby
<atchoum>
is there a possibility for dict comprehension in ruby ?
<apeiros>
if dict-comprehension is similar as list-comprehension - all those things work via methods in ruby
<atchoum>
myDict.map |x, y| {x=>y}
<atchoum>
something like that
<apeiros>
that works almost like that
<atchoum>
but I don't know the proper syntax. yeah, so there must be a convenient method to do this, but it is not map I guess.
<atchoum>
can you tell me how you would do to unset a method from a mixed in module ?
<apeiros>
I wouldn't
<apeiros>
but there's the undef keyword, and Module#undef_method and #remove_method
ledestin has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<chridal>
I have a class that in turn uses RestClient::Resource.new and eventually does a .get on it. I would like to test this, with RSpec for instance. It is easy to test it, if I were to use expect_any_instance_of(RestClient::Resource).to receive(:get), but it is considered bad practice to use any_instance_of.
<chridal>
How can I test this instead? I need to stub out that call.
jottr_ has joined #ruby
cschneid has joined #ruby
erlend has quit [Ping timeout: 255 seconds]
jottr_ has quit [Ping timeout: 256 seconds]
dr3w_ has joined #ruby
leah2 has quit [Ping timeout: 276 seconds]
erlend has joined #ruby
apeiros has quit [Read error: Connection reset by peer]
trautwein has quit [Quit: ZNC 1.6.6 - http://znc.in]
trautwein has joined #ruby
leah2 has joined #ruby
jottr_ has joined #ruby
apeiros has joined #ruby
<atchoum>
How would you do if you have a list of records [{'id'=>foo, 'field1'=> value1, 'field2'=> value2}] to transform it into a hashmap with {foo=>{'field1'=> value1, 'field2'=>value2}, bar=>, etc.} ?
trautwein has quit [Quit: ZNC 1.6.6 - http://znc.in]
<pabs>
list.reduce({}) { |r, row| id = row.delete('id'); r[ODODODODODODODODODid] = row; r }
<pabs>
err
<pabs>
list.reduce({}) { |r, row| id = row.delete('id'); r[id] = row; r }
<pabs>
sorry about that
<apeiros>
pabs: each_with_object >>> inject with an artificial last statement
<apeiros>
(or reduce)
kapil___ has quit [Quit: Connection closed for inactivity]
<pabs>
atchoum: if you want to keep the id in the row you can ditch the delete and do it like this: list.reduce({}) { |r, row| r[row['id']] = row; r }
trautwein has joined #ruby
<atchoum>
ok, reduce is cool
<atchoum>
ruby is very functional
<apeiros>
list.each_with_object({}) { |row, hash| hash[row["id"]] = row } # as said, no artificial "; r" required
<atchoum>
you can update hashmap in place with that, isn't it ?
<apeiros>
yes
<apeiros>
or whichever object you use
al2o3-cr has quit [Ping timeout: 240 seconds]
<apeiros>
the argument you pass to each_with_object is yielded on every iteration. it's suitable for accumulators which you want to mutate.
<apeiros>
inject/reduce is for when you're working with results of operations
<apeiros>
(return values)
dionysus69 has quit [Quit: dionysus69]
ruurd has quit [Ping timeout: 240 seconds]
gr33n7007h has joined #ruby
gr33n7007h is now known as al2o3-cr
jottr_ has quit [Ping timeout: 256 seconds]
elementaru has joined #ruby
zapata has quit [Quit: WeeChat 2.1]
konsolebox has quit [Max SendQ exceeded]
sagax has quit [Read error: Connection reset by peer]
zapata has joined #ruby
rshetty has joined #ruby
rshetty has quit [Ping timeout: 240 seconds]
jottr_ has joined #ruby
physicist__ has quit [Read error: Connection reset by peer]
Dimik has joined #ruby
physicist__ has joined #ruby
jottr_ has quit [Ping timeout: 256 seconds]
VVelox has joined #ruby
schneider has joined #ruby
<VVelox>
For Net::LDAP, how do I disable encryption?
jottr_ has joined #ruby
<VVelox>
looks like setting the method to simple should work, but it is erroring.... although I think this may be a Mastodon bug
<atchoum>
what is the ruby equivalent of the `in` operator in python ?
<atchoum>
1 in [3,2,1]
<atchoum>
would be true
<atchoum>
4 in [3,2,1] would be false, but how do you do that in ruby ?
<atchoum>
got it it would be include
<al2o3-cr>
atchoum: [1,2,3].member? 1
<al2o3-cr>
or include? indeed
VVelox has left #ruby [#ruby]
<al2o3-cr>
Array#include? Enumerable#member? Range#cover? Comparable#between? are your friends :)
\void has joined #ruby
Erlingur has joined #ruby
Erlingur has quit [Client Quit]
alfiemax has joined #ruby
oleo2 has joined #ruby
jottr_ has quit [Ping timeout: 256 seconds]
alfiemax has quit [Ping timeout: 255 seconds]
oleo2__ has joined #ruby
noobineer has joined #ruby
oleo2 has quit [Ping timeout: 276 seconds]
apparition has quit [Quit: Bye]
oleo2__ has quit [Remote host closed the connection]
yokel has quit [Remote host closed the connection]
noobineer has quit [Ping timeout: 256 seconds]
yokel has joined #ruby
jottr_ has joined #ruby
donofrio has quit [Remote host closed the connection]
alfiemax has joined #ruby
chalupajack has joined #ruby
jottr_ has quit [Ping timeout: 264 seconds]
venmx has joined #ruby
erlend has quit [Ping timeout: 264 seconds]
erlend has joined #ruby
jottr_ has joined #ruby
chalupajack has quit [Ping timeout: 276 seconds]
rshetty has joined #ruby
chalupajack has joined #ruby
chalupajack has quit [Remote host closed the connection]
AJA4350 has quit [Ping timeout: 240 seconds]
schneider has quit [Quit: WeeChat 2.0.1]
venmx has quit [Remote host closed the connection]
schneider has joined #ruby
venmx has joined #ruby
jottr_ has quit [Ping timeout: 256 seconds]
yeticry has quit [Ping timeout: 255 seconds]
solocshaw has joined #ruby
yeticry has joined #ruby
Olipro has quit [Ping timeout: 255 seconds]
lupine has quit [Ping timeout: 255 seconds]
alfiemax has quit [Ping timeout: 276 seconds]
AJA4350 has joined #ruby
lupine has joined #ruby
schneider has quit [Ping timeout: 268 seconds]
dstrunk has joined #ruby
AJA4350 has quit [Remote host closed the connection]
AJA4350 has joined #ruby
orbyt_ has joined #ruby
Xiti has quit [Quit: Xiti]
jottr_ has joined #ruby
Xiti has joined #ruby
errakeshpd has joined #ruby
Yzguy has joined #ruby
jottr_ has quit [Ping timeout: 246 seconds]
solocshaw has quit [Ping timeout: 268 seconds]
marr has joined #ruby
errakeshpd has quit []
marr has quit [Remote host closed the connection]
dstrunk has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<apeiros>
havenwood: check backlog, I showed kapil___ tap as an option for `(large_expression_returning_array).tap { |ary| ary[-1] = … }`, i.e. to change the last item of an array which is the result of some large-ish expression.
<apeiros>
just saying because I'll be mainly afk now, so you can properly take over ;-)
<havenwood>
apeiros: oops, didn't see that - roger!
<havenwood>
kapil___: nvm!
<kapil___>
I am using rails
<apeiros>
(but yes, of course, the way they apply it now makes little sense)
jottr_ has quit [Ping timeout: 264 seconds]
Yzguy has joined #ruby
<kapil___>
apeiros: `(large_expression_returning_array).tap { |ary| ary[-1] = … }` works
jottr_ has joined #ruby
aaronm04 has joined #ruby
<aaronm04>
Hi, is it a bad idea to do `puts` from multiple threads at the same time?
darkhanb has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<Zarthus>
aaronm04: kind of, depends on your application
<Zarthus>
if the order of output doesn't matter, it doesn't really hurt
<aaronm04>
the order does matter, and it's also important that I not lose any lines
<Zarthus>
how do you expect the order to be correct when you have multiple threads performing actions asynchronously?
<Zarthus>
you could wait for one thread to finish its action before moving on with the other thread, but then the benefit of threading is kind of lost
<aaronm04>
I was assuming 1 puts = 1 write syscall (which are atomic)
dr3w__ has joined #ruby
<aaronm04>
if the order gets messed up, I'm considering using a Queue to send all puts lines to a logger thread
tomphp has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dr3w_ has quit [Ping timeout: 240 seconds]
<Zarthus>
i don't think i fully understand, the order will be whatever completes first
<Zarthus>
it's not being "messed up", but it does mean if ThreadA completes first that message will be before ThreadB
<aaronm04>
that's actually what I want
<apeiros>
aaronm04: puts is not atomic
<apeiros>
in general, don't assume anything to be atomic which doesn't explicitly state to be
dmarcoux has joined #ruby
<aaronm04>
it would be bad if puts from thread A happens before puts from thread B, but the puts A line is _after_ the puts B line
<aaronm04>
apeiros: ok, thanks
<Zarthus>
there is no order though, sometimes ThreadB might finish faster and then that message is first
<aaronm04>
that would be ok
<aaronm04>
my main concerns are 1) puts lines being lost, and 2) puts lines out of order from when the puts are actually executed
Deesl has joined #ruby
za1b1tsu has quit [Ping timeout: 256 seconds]
<Zarthus>
i've never actually seen (2) happen ever in the years i've been programming, i'd wonder what language would do that
<aaronm04>
hmm, alright
jottr_ has quit [Ping timeout: 264 seconds]
z3uS is now known as z3uS-
z3uS- is now known as z3uS
z3uS has quit [Quit: /dev/null]
z3uS has joined #ruby
HoierM has quit [Ping timeout: 268 seconds]
Deesl has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]