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!
jenrzzz has quit [Ping timeout: 265 seconds]
jenrzzz has joined #ruby
Fernando-Basso has quit [Remote host closed the connection]
simonfromspace has quit [Ping timeout: 240 seconds]
coffeex3 has quit [Ping timeout: 255 seconds]
evdubs has quit [Quit: Leaving]
evdubs has joined #ruby
emers2n has joined #ruby
DTZUZU has quit [Ping timeout: 240 seconds]
TCZ has joined #ruby
DTZUZU has joined #ruby
DaRock has joined #ruby
bsdbandit-01 has joined #ruby
xco has joined #ruby
xco has quit [Client Quit]
bsdband29 has quit [Ping timeout: 255 seconds]
<emers2n> Get this... you're making an API call in Ruby. Occasionally, the API service returns a 'too many requests' error, and the entire script fails without data from the request.
<emers2n> In which case, how do I make the script keep trying every 1-2 seconds until it succeeds? Can't figure out how to code this in an intelligent manor, I feel like I'm a single while statement away from solution? Code example https://pastebin.com/raw/YaFMBmXk
<ruby[bot]> emers2n: as I told you already, please use https://gist.github.com
drincruz has quit [Ping timeout: 258 seconds]
Jonopoly has quit [Quit: WeeChat 2.5]
xco has joined #ruby
jenrzzz has quit [Ping timeout: 260 seconds]
jenrzzz has joined #ruby
_phaul has quit [Ping timeout: 240 seconds]
Bounga` has quit [Ping timeout: 240 seconds]
phaul has joined #ruby
TCZ is now known as programming_expe
programming_expe is now known as jeudi_gras
siery has joined #ruby
dionysus69 has quit [Ping timeout: 255 seconds]
coderhs has quit [Quit: Leaving]
ur5us has joined #ruby
jenrzzz has quit [Read error: Connection reset by peer]
citizentwo has joined #ruby
jenrzzz has joined #ruby
citizentwo has quit [Remote host closed the connection]
mozzarella has quit [Remote host closed the connection]
mozzarella has joined #ruby
StoneCypherMac has quit [Ping timeout: 240 seconds]
<al2o3-cr> emers2n: play about with this for a bit: https://gist.github.com/gr33n7007h/b7ef03c5cce64e34d6732c47d5d7e081
<emers2n> al2o3-cr: yeah that's exactly what I needed. Thanks so much
<al2o3-cr> emers2n: np. just adapt your code to suit.
StoneCypherMac has joined #ruby
<emers2n> Right on, thanks. Do you mind explaining what's going on with this line %i(ok warn fatal critical).sample?
<emers2n> Omg, sorry, I see now that is just to demonstrate error codes
davidw has quit [Ping timeout: 260 seconds]
<emers2n> Appreciate it!
<al2o3-cr> %i sigil creates an array of symbols and sample picks one element of that array at random.
<al2o3-cr> &>> %i(ok warn fatal critical).sample
<rubydoc> # => :fatal (https://carc.in/#/r/8ldh)
bvdw has quit [Read error: Connection reset by peer]
<al2o3-cr> emers2n: yw
bvdw has joined #ruby
StoneCypherMac has quit [Ping timeout: 258 seconds]
<emers2n> al2o3-cr https://carc.in/#/r/8ldj
<al2o3-cr> :)
coffeex3 has joined #ruby
bsdbandit-01 has quit [Read error: Connection reset by peer]
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
coffeex3 has quit [Ping timeout: 258 seconds]
<al2o3-cr> %>> "emers2n is %s but also very %s" % %i(neat cool kickass awesome).sample(2)
drincruz has joined #ruby
<al2o3-cr> &>> "emers2n is %s but also very %s" % %i(neat cool kickass awesome).sample(2)
<rubydoc> # => "emers2n is cool but also very awesome" (https://carc.in/#/r/8ldm)
<emers2n> lol <3
<al2o3-cr> 👍
<emers2n> Check this one out!
<emers2n> &>> p "hello world!"
<rubydoc> # => "hello world!"... check link for more (https://carc.in/#/r/8ldn)
splud_wurk has quit [Quit: splud_wurk]
jottr has quit [Ping timeout: 255 seconds]
ChmEarl has quit [Quit: Leaving]
olddogbarks has joined #ruby
howdoi has quit [Quit: Connection closed for inactivity]
pama has quit [Quit: Textual IRC Client: www.textualapp.com]
olddogbarks has quit [Quit: I am functioning within established parameters.]
citizentwo has joined #ruby
markopasha has quit [Remote host closed the connection]
StoneCypherMac has joined #ruby
SeepingN has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Bounga` has joined #ruby
citizentwo has quit [Remote host closed the connection]
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Bounga` has quit [Ping timeout: 272 seconds]
citizentwo has joined #ruby
jenrzzz has quit [Ping timeout: 265 seconds]
cd has quit [Quit: cd]
ur5us has quit [Ping timeout: 240 seconds]
citizentwo has quit [Remote host closed the connection]
fphilipe has joined #ruby
StoneCypherMac has quit [Ping timeout: 260 seconds]
citizentwo has joined #ruby
fphilipe_ has quit [Ping timeout: 272 seconds]
StoneCypherMac has joined #ruby
drincruz has quit [Ping timeout: 255 seconds]
jeudi_gras has quit [Quit: Leaving]
duderonomy has joined #ruby
StoneCypherMac has quit [Ping timeout: 260 seconds]
eflaexie has joined #ruby
<eflaexie> hi
<eflaexie> hi
<eflaexie> hi
eflaexie has left #ruby [#ruby]
StoneCypherMac has joined #ruby
drincruz has joined #ruby
JoeA2552 has joined #ruby
StoneCypherMac has quit [Ping timeout: 240 seconds]
drincruz has quit [Ping timeout: 260 seconds]
jmcgnh has quit [Ping timeout: 260 seconds]
drincruz has joined #ruby
adiosk has joined #ruby
jmcgnh has joined #ruby
adiosk has left #ruby ["hi"]
Yoasl has joined #ruby
Yoasl has left #ruby ["hi"]
tredkilla has joined #ruby
iamayam has quit [Ping timeout: 256 seconds]
orbyt_ has joined #ruby
citizentwo has quit [Remote host closed the connection]
citizentwo has joined #ruby
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
iamayam has joined #ruby
citizentwo has quit [Ping timeout: 248 seconds]
alfiemax has joined #ruby
SeepingN has joined #ruby
alexherbo2 has quit [Ping timeout: 255 seconds]
braincrash has quit [Quit: bye bye]
StoneCypherMac has joined #ruby
LinuxKnight has joined #ruby
braincrash has joined #ruby
ttoocs has joined #ruby
StoneCypherMac has quit [Quit: leaving]
citizentwo has joined #ruby
gix- has joined #ruby
gix has quit [Disconnected by services]
Bounga` has joined #ruby
Bounga` has quit [Ping timeout: 240 seconds]
coffeex3 has joined #ruby
SeepingN has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
_phaul has joined #ruby
gix- has quit [Ping timeout: 268 seconds]
phaul has quit [Ping timeout: 258 seconds]
snuz has quit [Read error: Connection reset by peer]
my_dude has quit [Ping timeout: 260 seconds]
Azure has quit [Ping timeout: 260 seconds]
ur5us has joined #ruby
dStromboli has quit [Quit: WeeChat 2.7]
xco has joined #ruby
ur5us has quit [Ping timeout: 258 seconds]
sergioro has joined #ruby
tredkilla has quit [Ping timeout: 240 seconds]
reyfi9e has quit [Ping timeout: 265 seconds]
Batisi[m] is now known as batisi[m]
bsdbandit-01 has joined #ruby
cthulchu_ has quit [Ping timeout: 240 seconds]
jenrzzz has joined #ruby
duderonomy has joined #ruby
jenrzzz has quit [Ping timeout: 255 seconds]
reyfi9e has joined #ruby
hoijui has joined #ruby
ur5us has joined #ruby
jenrzzz has joined #ruby
AndreYuhai has joined #ruby
<AndreYuhai> Hey there, how do I upload a file to s3 bucket and attach it to a model? I still can't get it.
<AndreYuhai> From server side.
phaul has joined #ruby
SeepingN has joined #ruby
jenrzzz has quit [Ping timeout: 260 seconds]
_phaul has quit [Ping timeout: 240 seconds]
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
shansen_ has quit [Quit: ZNC 1.7.4+deb0+bionic0 - https://znc.in]
sauvin has joined #ruby
Bounga` has joined #ruby
ewanchic has quit [Read error: Connection reset by peer]
ur5us has quit [Ping timeout: 255 seconds]
Bounga` has quit [Ping timeout: 272 seconds]
coffeex3 has quit [Ping timeout: 268 seconds]
duderonomy has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
SeepingN has quit [Disconnected by services]
SeepingN_ has joined #ruby
ur5us has joined #ruby
TzilTzal has joined #ruby
JJonah_ has quit [Quit: Connection closed for inactivity]
hiroaki has quit [Ping timeout: 260 seconds]
sergioro has quit [Quit: Lost terminal]
schne1der has joined #ruby
bvdw has quit [Read error: Connection reset by peer]
bvdw has joined #ruby
jenrzzz has joined #ruby
johnny56 has quit [Ping timeout: 240 seconds]
_phaul has joined #ruby
schne1der has quit [Ping timeout: 265 seconds]
ur5us has quit [Ping timeout: 255 seconds]
phaul has quit [Ping timeout: 258 seconds]
jenrzzz has quit [Read error: Connection reset by peer]
jenrzzz has joined #ruby
fphilipe has quit [Ping timeout: 240 seconds]
clemens3 has quit [Quit: WeeChat 2.7]
fphilipe has joined #ruby
nowhereman has quit [Ping timeout: 272 seconds]
conta has joined #ruby
conta1 has joined #ruby
conta has quit [Ping timeout: 268 seconds]
conta1 is now known as conta
JoeA2552 has quit [Quit: Textual IRC Client: www.textualapp.com]
schne1der has joined #ruby
pinpox- has joined #ruby
stdedos has quit [Remote host closed the connection]
stdedos has joined #ruby
pinpox has quit [Ping timeout: 248 seconds]
pinpox- is now known as pinpox
TomyWork has joined #ruby
clemens3 has joined #ruby
mikecmpbll has joined #ruby
seenseen has joined #ruby
chalkmonster has joined #ruby
Jonopoly has joined #ruby
GodFather has quit [Read error: Connection reset by peer]
GodFather has joined #ruby
conta has quit [Quit: conta]
phaul has joined #ruby
_phaul has quit [Ping timeout: 260 seconds]
AndreYuhai has quit [Quit: Leaving]
_phaul has joined #ruby
pwnd_nsfw` has joined #ruby
stooj has quit [Ping timeout: 240 seconds]
phaul has quit [Ping timeout: 240 seconds]
NODE has quit [Quit: changing servers]
NODE has joined #ruby
pwnd_nsfw has quit [Ping timeout: 258 seconds]
stooj has joined #ruby
royal_screwup21 has joined #ruby
Jonopoly has quit [Read error: Connection reset by peer]
NODE has quit [Quit: changing servers]
Ytrezar has quit [Quit: Cya !]
Ytrezar has joined #ruby
NODE has joined #ruby
phaul has joined #ruby
royal_screwup21 has quit [Remote host closed the connection]
_phaul has quit [Ping timeout: 260 seconds]
fphilipe has quit [Read error: Connection reset by peer]
russt has quit [Ping timeout: 248 seconds]
russt has joined #ruby
mikecmpbll has quit [Quit: inabit. zz.]
phaul has quit [Ping timeout: 255 seconds]
mikecmpbll has joined #ruby
phaul has joined #ruby
fphilipe has joined #ruby
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
dionysus69 has joined #ruby
Mrgoose845701915 has quit [Ping timeout: 245 seconds]
Fernando-Basso has joined #ruby
Mrgoose845701915 has joined #ruby
cisco has joined #ruby
conta has joined #ruby
vondruch has quit [Quit: vondruch]
vondruch has joined #ruby
TCZ has joined #ruby
chalkmonster has quit [Ping timeout: 260 seconds]
chalkmonster has joined #ruby
conta has quit [Quit: conta]
TzilTzal has quit [Quit: Leaving.]
royal_screwup21 has joined #ruby
jacksop has joined #ruby
alfiemax has quit [Remote host closed the connection]
xco has joined #ruby
akemhp has quit [Read error: Connection reset by peer]
NODE has quit [Quit: changing servers]
NODE has joined #ruby
alfiemax has joined #ruby
seenseen has quit [Read error: Connection reset by peer]
seenseen has joined #ruby
johnny56 has joined #ruby
Azure has joined #ruby
schne1der has quit [Quit: schne1der]
SeepingN has joined #ruby
schne1der has joined #ruby
SeepingN_ has quit [Ping timeout: 268 seconds]
royal_screwup21 has quit [Remote host closed the connection]
drincruz has quit [Read error: Connection reset by peer]
vondruch_ has joined #ruby
emers2n has quit [Remote host closed the connection]
vondruch_ has quit [Client Quit]
vondruch has quit [Ping timeout: 240 seconds]
vondruch has joined #ruby
cisco has quit [Remote host closed the connection]
alexherbo2 has joined #ruby
vondruch_ has joined #ruby
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
conta has joined #ruby
vondruch_ has quit [Client Quit]
vondruch has quit [Read error: Connection reset by peer]
vondruch has joined #ruby
xco has joined #ruby
jacksop has quit [Remote host closed the connection]
jacksop has joined #ruby
burningserenity has joined #ruby
burningserenity has quit [Max SendQ exceeded]
burningserenity has joined #ruby
drincruz has joined #ruby
ta has quit [Quit: WeeChat 2.7]
ta has joined #ruby
akemhp has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.7]
akemhp_ has joined #ruby
drincruz has quit [Ping timeout: 265 seconds]
jmcgnh has quit [Read error: Connection reset by peer]
akemhp has quit [Ping timeout: 258 seconds]
buckworst has joined #ruby
bsdband65 has joined #ruby
buckworst has quit [Client Quit]
buckworst has joined #ruby
bsdbandit-01 has quit [Ping timeout: 260 seconds]
jmcgnh has joined #ruby
Arahael has joined #ruby
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
TCZ has quit [Quit: Leaving]
alexherbo2 has joined #ruby
schne1der has quit [Ping timeout: 258 seconds]
Arahael has quit [Ping timeout: 255 seconds]
banisterfiend has joined #ruby
ellcs1 has joined #ruby
sergioro has joined #ruby
bvdw has quit [Read error: Connection reset by peer]
sergioro has quit [Client Quit]
bvdw has joined #ruby
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
Arahael has joined #ruby
t0th_- has joined #ruby
<t0th_-> hi, anybody can help me with elasticsearch gem?
simonfromspace has joined #ruby
bsdband65 has quit [Ping timeout: 240 seconds]
bsdbandit-01 has joined #ruby
banisterfiend has quit [Read error: Connection reset by peer]
vondruch has quit [Ping timeout: 258 seconds]
schne1der has joined #ruby
jacksop has quit [Remote host closed the connection]
jacksop has joined #ruby
jacksop has quit [Client Quit]
mossplix has joined #ruby
royal_screwup21 has joined #ruby
Esa_ has joined #ruby
royal_screwup21 has quit [Remote host closed the connection]
banisterfiend has joined #ruby
alfiemax has quit [Remote host closed the connection]
conta has quit [Quit: conta]
Swyper has joined #ruby
royal_screwup21 has joined #ruby
dinfuehr has quit [Ping timeout: 260 seconds]
wickedbloodfart has joined #ruby
dinfuehr has joined #ruby
chalkmonster has joined #ruby
lucasb has joined #ruby
seenseen has quit [Ping timeout: 240 seconds]
royal_screwup21 has quit [Remote host closed the connection]
banisterfiend has quit [Ping timeout: 265 seconds]
Nathan2296 has joined #ruby
<Nathan2296> I'm trying to build fluentd from the gemfile, but after it's installed I get the following: https://pastebin.com/BYZ1S8brBut both yajl and yajl-ruby are installed as seen by 'gem list'
<ruby[bot]> Nathan2296: we in #ruby do not like pastebin.com, it loads slowly for most, has ads which are distracting and has terrible formatting. Please use https://gist.github.com
seenseen has joined #ruby
drincruz has joined #ruby
suukim has joined #ruby
spiette has quit [Quit: ZNC 1.7.5 - https://znc.in]
spiette has joined #ruby
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<adam12> Nathan2296: You're running a command?
minall has joined #ruby
burningserenity has quit [Ping timeout: 240 seconds]
mossplix has quit [Remote host closed the connection]
<Nathan2296> Yeah sorry I forgot to copy that, I get that error just by running 'fluentd'
<adam12> Nathan2296: What happens if you use `bundle exec fluentd`?
<Nathan2296> Let me try that, give me a second to build bundle
<adam12> Nathan2296: Hmm? What do you mean?
mossplix has joined #ruby
<Nathan2296> root@qemux86-64:~# bundle exec fluentdCould not locate Gemfile
royal_screwup21 has joined #ruby
<Nathan2296> no dice
<adam12> Nathan2296: Oh. I thought you had a Gemfile? Says in the beginning.
<Nathan2296> Oh sorry
<Nathan2296> I'm building it as a package from the Gemfile
m_antis has joined #ruby
<adam12> Nathan2296: From the Gemspec?
<adam12> Nathan2296: A package like rpm or deb or something?
<Nathan2296> It's being built through the ruby bbclass for bitbake
m_antis has quit [Read error: Connection reset by peer]
m_antis has joined #ruby
<Nathan2296> Which complicates things unfortunately
royal_screwup21 has quit [Remote host closed the connection]
<adam12> Nathan2296: Yeah .. you've lost me.
<Nathan2296> In theory, the gems are being built with 'gem build ...' and included into an embedded linux image
<Nathan2296> And using gem list, I can see that all of the runtime dependencies for fluentd are at least being detected by gem
Fraeon has quit [Ping timeout: 260 seconds]
<Nathan2296> But actually trying to use fluentd produces that error that it can't load such file yajl/yajl
jintseng has joined #ruby
<adam12> Nathan2296: I wonder if yajl is a C library
<adam12> yajl/yajl might actually be yajl.yajl.so
<adam12> s/\/\//
<Nathan2296> God lol, there's the C yajl, the yajl gem, and the yajl-ruby gem
<Nathan2296> And as far as I can tell I have them all installed
Fraeon has joined #ruby
<adam12> Nathan2296: I just wonder if a file was missed. If it's a C binding, it might generated a shared object file. When you build it, it might not be included hence the missing require.
<adam12> Nathan2296: Are you using gem build for yajl and yajl-ruby?
<Nathan2296> Yes
<adam12> Nathan2296: Does it give you a .gem file?
dviola has joined #ruby
<adam12> Also, I think you don't need the yajl dependency. It looks unrelated to the the JSON parsing library. yajl-ruby likely.
<adam12> (you likely need yajl-ruby)
<Nathan2296> Yajl dependency as in the C yajl or the yajl gem
<adam12> Nathan2296: yajl gem. Looking at the project, it's actually a logger. I might be wrong.
<Nathan2296> Yeah I don't think so either, and only yajl-ruby is listed as a fluentd dependency
burningserenity has joined #ruby
<adam12> Nathan2296: You are doing `gem build yajl-ruby` somewhere?
<Nathan2296> So searching the filesystem I have '/usr/lib64/ruby/gems/2.5.0/cache/yajl-ruby-1.0.0.gem'
<Nathan2296> YEs
xco has joined #ruby
<Nathan2296> The compile script: https://pastebin.com/DCg09MSB
<ruby[bot]> Nathan2296: as I told you already, please use https://gist.github.com
<adam12> Nathan2296: I'd probably try unpacking the gem and see what's in it.
<Nathan2296> Okay unpacking it I don't see anything strange
<Nathan2296> Is there something I should be looking for in particular?
<adam12> Nathan2296: Does it have a lib/yajl/yajl.rb?
<Nathan2296> Nope
<adam12> Nathan2296: how about lib/yajl/yajl.so ?
<Nathan2296> It has the directory yajl-ruby-1.0.0/lib/yajl with several folders and rb files
<Nathan2296> No yajl.* files tho
<adam12> That's a weird version too. Latest is 1.4.1.
<Nathan2296> I'm using it as it's specified for fluentd
<adam12> Ah.
Swyper has quit [Remote host closed the connection]
<Nathan2296> Doing gem unpack on a normal 'gem install yajl-ruby' has neither the yajl.rb or yajl.so files
<Nathan2296> So nothing amiss there
<adam12> There's got to be a yajl.so file missing from somewhere tho.
<adam12> Instead of calling gem build for that dependency, maybe you can unpack and run `rake gem` instead. It will use the rake-compiler gem which builds dependencies.
<Nathan2296> Oh, in yajl-ruby-1.0.0/lib there is a yajl.rb
<adam12> Yeah. You need yajl/yajl.so.
<Nathan2296> No yajl.so's on the system
<Nathan2296> Interestingly though, there are .so files for some of the other gems that I needed as dependencies
simonfromspace has quit [Ping timeout: 258 seconds]
<adam12> Did you install them the same way? And are they so files for dependencies or for gems?
<Nathan2296> Installed exactly the same, and they're .so files for gems that are dependencies for fluentd
<Nathan2296> i.e. `find msgpack-1.3.3 -name *.so` yields `lib/msgpack/msgpack.so`
<Nathan2296> but `find yajl-ruby -name *.so` doesn't find anything
<Nathan2296> I'm assuming then that it needs a .so file to import?
Swyper has joined #ruby
<adam12> Yes. C bindings normally have .so files along with them (not always since they can use the FFI interface Fiddle but yajl doesn't)
<adam12> Ruby looks for both .rb and .so files when requiring. So require "yajl/yajl" would be "yajl/yajl.rb" and "yajl/yajl.so"
<adam12> I know there's a .so file missing; I built it locally and it exists.
<adam12> If you're not cross compiling, build yajl-ruby by installing it's dev dependencies, unpacking it, then running `rake native gem`. In theory you'll get a gem file WITH the .so file in it. I haven't tried it and I'm not 100% familiar with rake-compiler.
<Nathan2296> Strange, when I `gem install yajl-ruby` there's no .so file
<adam12> Nathan2296: Does it say "Building native extensions" when installing?
<Nathan2296> Yes
<Nathan2296> But then unpacking it, it doesn't have the .so file
<adam12> Ah. That's normal. Unpack only extracts the source.
<adam12> Unless it gets shipped as a native gem.
<Nathan2296> Ah
<adam12> You could try `gem info yajl-ruby` and then view the directory it shows.
<Nathan2296> So as above, I installed the dependencies with `bundle install` and than ran `rake native gem`, but end up with `NoMethodError: undefined method `split' for nil:NilClass`
<adam12> or if you have an editor, `gem open yajl-ruby`
coffeex3 has joined #ruby
<adam12> Yeah; I received the same error. I'm presuming it might be a bug in rake-compiler but I didn't look.
<Nathan2296> `gem open yajl-ruby` there's no .so file in the lib folder
<Nathan2296> Oh but there is in yajl directory, mb
<Nathan2296> Okay interesting
duderonomy has joined #ruby
<adam12> there's a lib/yajl/yajl.so file?
ellcs1 has quit [Ping timeout: 248 seconds]
<Nathan2296> So when I `gem install yajl-ruby` locally, and then `gem open yajl-ruby` there is a .so file. On my image doing `gem open yajl-ruby` there is no .so file
<Nathan2296> But also, when I try `gem install yajl-ruby -v 1.0.0` locally I get a compiler error. I'm wondering if my build process is squashing that error and it's not being properly installed
<adam12> I couldn't build 1.0.0 either. I'm presuming it's related to Ruby version, since 1.0.0 is almost 10 years old.
<adam12> But that's entirely possible.
<Nathan2296> Let me try 1.4.1 on the image and see what happens
<Nathan2296> Running into build issues but I think it's env related, give me a few mins to try to resolve
poontangmessiah has joined #ruby
bsdbandit-01 has quit [Quit: -a- Connection Timed Out]
coffeex3 has quit [Ping timeout: 240 seconds]
bsdbandit-01 has joined #ruby
coffeex3 has joined #ruby
<Nathan2296> adam12: Sorry for the long wait, ran into a stupid issue, fixed now. Doing `gem open yajl-ruby` on 1.2.1 yajl-ruby on my image I don't have a .so file
kinduff has joined #ruby
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ttoocs has quit [Ping timeout: 240 seconds]
coffeex3 has quit [Quit: WeeChat 2.4]
mossplix has quit [Remote host closed the connection]
mossplix has joined #ruby
fphilipe has quit [Read error: Connection reset by peer]
fphilipe has joined #ruby
mossplix has quit [Ping timeout: 265 seconds]
mossplix has joined #ruby
mossplix has quit [Read error: Connection reset by peer]
mossplix has joined #ruby
conta has joined #ruby
simonfromspace has joined #ruby
DaRock has quit [Ping timeout: 268 seconds]
<simonfromspace> Looking for refactoring suggestions on this. https://github.com/simonpeterdebbarma/eztv-scraper/tree/scraper
<havenwood> simonfromspace: You can drop the ".rb" here: https://github.com/simonpeterdebbarma/eztv-scraper/blob/scraper/bin/eztv-scraper#L3
Nathan2296 has quit [Quit: Ping timeout (120 seconds)]
<havenwood> simonfromspace: Namespace all of these under EZTVScraper: https://github.com/simonpeterdebbarma/eztv-scraper/tree/scraper/lib/eztv_scraper
Nathan2276 has joined #ruby
<havenwood> simonfromspace: And match the class/module name to the filename.
<havenwood> simonfromspace: class EZTVScraper; module Parser; ...
<havenwood> simonfromspace: (It'll be easy to put them all inside a class. If you don't, each one potentially conflicts at top level.)
<havenwood> simonfromspace: A gem should only add a single namespace at top level generally, in this case EZTVScraper.
conta has quit [Quit: conta]
<havenwood> simonfromspace: It's best to just `if choice` and `else`, no `== true` or `== false`: https://github.com/simonpeterdebbarma/eztv-scraper/blob/scraper/lib/eztv_scraper/ui.rb#L45
<simonfromspace> Alright
<simonfromspace> I'm still confused about the Namespace suggestion though
<havenwood> simonfromspace: Let me show you one example.
cd has joined #ruby
<simonfromspace> So everything in one file?
<havenwood> simonfromspace: This UserInterface can be used like your old one without changing other code, but it's EZTVScraper::UserInterface not a top level UserInterface that might conflict with other UserInterfaces out there.
<simonfromspace> I see, alright
<havenwood> simonfromspace: Note ^ how the filename also mirrors the UserInterface
<simonfromspace> alright
<havenwood> EZTVScraper::UserInterface is in /lib/eztv_scraper/user_interface.rb—they correspond perfectly.
<simonfromspace> I'll implement that
<havenwood> 👍🏽
<simonfromspace> And now inside my starting file, how would I include the module?
<simonfromspace> Or just call the class
<simonfromspace> invoke*
<havenwood> simonfromspace: You won't need to change your other code.
<simonfromspace> Oh
<havenwood> simonfromspace: It keeps it tidy, in your gem namespace.
<havenwood> simonfromspace: If every gem leaked top level constants, it'd be chaos.
<simonfromspace> And it's no problem that all files have a EZTVScraper clas
<havenwood> simonfromspace: That's normal!
<Nathan2276> adam12: Sorry if I missed something but I lost connection for awhile there
<simonfromspace> Thanks for the fresh brain cells, havenwood
<havenwood> simonfromspace: See here, for example: https://github.com/pry/pry/blob/master/lib/pry/hooks.rb
<havenwood> simonfromspace: Pry::Hooks is ilb/pry/hooks.rb
<havenwood> Pry::Forwardable doesn't stomp on anyone else's Forwardable, since it's in the Pry namespace.
<havenwood> And the filename mirrors.
dviola has quit [Quit: WeeChat 2.7]
<havenwood> simonfromspace: After these namespace changes, I'd vote go ahead and cut a gem.
<simonfromspace> Done as instructed and app works fine
<havenwood> simonfromspace: That's a nice way to get and share easy access to the executable in your PATH.
cthulchu_ has joined #ruby
<simonfromspace> This is a capstone project for me, and one of our goals was to make unit tests
<simonfromspace> So far, I've been unable to make tests except create a variable named success and pass it if everything goes well or return false if rescue catches an error. Like, that was the super hacky way for me to write a test.
<simonfromspace> Should I have written the app any differently.
<simonfromspace> I'm not passing any value or parameters between methods
<simonfromspace> and that makes it even more difficult to test anything.
<adam12> Nathan2276: Nothing further from me when you dropped connection. I'm all out of ideas. You need that .so file to be shipped with the gem you're packaging.
clemens3 has quit [Quit: and bye]
phaul has quit [Ping timeout: 255 seconds]
<havenwood> simonfromspace: It's normal in tests to have some setup. Then you test the interface. You can also test what's printed. This is a very print-heavy thing.
<havenwood> simonfromspace: Push the most recent code?
<simonfromspace> pushed
<Nathan2276> adam12: Ahah! So turns out that for whatever reason I was building 1.2.1 rather than 1.4.0, 1.4.0 does produce the .so file! Thanks so much for all of your help, I wouldn't have figured that out without you
davidw has joined #ruby
davidw has joined #ruby
davidw has quit [Changing host]
<adam12> Nathan2276: Cheers.
<havenwood> simonfromspace: Looking muuuch better! I think you're right, it's time for tests
<simonfromspace> Thanks to you
xco has joined #ruby
citizentwo has quit [Ping timeout: 240 seconds]
<havenwood> simonfromspace: 'lib/eztv_scraper' now nicely requires the other it needs.
<havenwood> simonfromspace: You're then ready to do a setup block and get testing.
<havenwood> simonfromspace: I always use Minitest, but RSpec is a super popular choice too and plenty of folk her can help with it.
<simonfromspace> I've done a but of testing on previous Ruby projects
<simonfromspace> bit*
<simonfromspace> But in those cases it was really easy to figure out what to expect
charon77 has joined #ruby
<simonfromspace> Here's an example. The other test files are not mine, but basic testing like this was relatively easier.
<havenwood> simonfromspace: I think you probably should do this line in your bin/eztv-scraper file instead of in the lib/: https://github.com/simonpeterdebbarma/eztv-scraper/blob/scraper/lib/eztv_scraper.rb#L30
<havenwood> simonfromspace: I'm guessing you'll just do a `before do` in RSpec to set up an instance of the class to test against?
phaul has joined #ruby
seenseen is now known as TinderFX
<havenwood> simonfromspace: Or maybe #let instead of #before.
<havenwood> simonfromspace: https://kolosek.com/rspec-let-vs-before/
<simonfromspace> Yeah, I've done some stuff with let
<havenwood> All these #before examples show the instance of a class. It seems close to what you're doing.
<simonfromspace> Yeah
<havenwood> simonfromspace: Try setting up an instance of EZTVScraper and then test that what should happen when you call a method does.
<simonfromspace> I noticed that
<simonfromspace> Alrighty
<havenwood> simonfromspace: Folk here should be able to help if you run into trouble testing the text output.
<simonfromspace> Alright
<simonfromspace> I'll try to write something, I don't know tbh
poontangmessiah has quit [Quit: WeeChat 2.7]
xco has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jintseng has quit [Ping timeout: 240 seconds]
chalkmonster has quit [Quit: WeeChat 2.7]
chalkmonster has joined #ruby
t0th_- has quit [Quit: Leaving]
tau has joined #ruby
conta has joined #ruby
conta has quit [Ping timeout: 255 seconds]
mossplix has quit [Remote host closed the connection]
mossplix has joined #ruby
dinfuehr has quit [Ping timeout: 258 seconds]
nofxx_ has joined #ruby
dinfuehr has joined #ruby
nofxx has quit [Ping timeout: 260 seconds]
fphilipe has quit [Ping timeout: 240 seconds]
coderhs has joined #ruby
mossplix has quit [Ping timeout: 260 seconds]
minall has quit [Remote host closed the connection]
citizentwo has joined #ruby
<simonfromspace> Interesting error. Looks like they are down. Or is it an issue on my end.
<simonfromspace> https://dpaste.org/Jqk2
<simonfromspace> Trying to publish a gem/
alfiemax has joined #ruby
<simonfromspace> It was a temporary error. I pushed it fine.
charon77 has quit [Quit: WeeChat 2.7]
Esa has joined #ruby
wickedbloodfart has quit [Quit: wickedbloodfart]
Esa_ has quit [Ping timeout: 240 seconds]
mikecmpbll has quit [Quit: inabit. zz.]
<simonfromspace> Small achievement bust just published my first gem : https://rubygems.org/gems/eztv_scraper
<simonfromspace> s/bust/but
gix has joined #ruby
howdoi has joined #ruby
<Nathan2276> More fun Ruby questions. I'm trying to build concurrent-ruby, with `gem build concurrent-ruby` but get an error about a missing concurrent_ruby.jar file
<Nathan2276> It seems I have to generate it somehow
tau has quit [Ping timeout: 240 seconds]
Snowy has joined #ruby
fphilipe has joined #ruby
impermanence has joined #ruby
<havenwood> Nathan2276: Are you using JRuby? I'd suggest asking in the #jruby channel, in any case, since they'll know.
<havenwood> simonfromspace: Congrats on cutting your first gem!!
<havenwood> simonfromspace: https://rubygems.org/gems/eztv_scraper
nofxx has joined #ruby
<Nathan2276> Sorry for the ignorance, but is JRuby a dependency? And if so is it just for building or a runtime dependency
<simonfromspace> :)
<havenwood> Nathan2276: Are you using JRuby? Show the error?
nofxx_ has quit [Ping timeout: 260 seconds]
<simonfromspace> ty havenwood I'm waiting for a review and hopefully I
<simonfromspace> I'll get another day to write tests
<Nathan2276> havenwood: ERROR: While executing gem ... (Gem::InvalidSpecificationException) ["lib/concurrent/concurrent_ruby.jar"] are not files
<Nathan2276> No I'm not using JRuby currently
coderhs has quit [Ping timeout: 248 seconds]
chalkmonster has quit [Quit: WeeChat 2.7]
<simonfromspace> Is there any way I can make my gem run by itself from the CLI?
<havenwood> Nathan2276: It looks like there's some fiddling to do around that file: "the jar is part the concurrent-ruby-x.y.z.gem"
<havenwood> simonfromspace: Say more about what you mean there?
<havenwood> simonfromspace: When you install the gem, the executable should be available in your path to run.
<simonfromspace> I mean, like an app I can run in the CLI anywhere
<simonfromspace> I assume that's another whole topic
fphilipe has quit [Ping timeout: 272 seconds]
<havenwood> simonfromspace: I don't understand.
<havenwood> simonfromspace: Try in your command line: eztv-scraper
<havenwood> simonfromspace: You should add option parsing. :)
<simonfromspace> does nothing
<Nathan2276> havenwood: Sorry I'm a little lost. Since it needs the jar does that mean that Java is a runtime dependency?
<havenwood> Nathan2276: Nope, it just has Java extensions. JRuby folk in #jruby should know what the deal is or there are probably issues or docs showing what's up but I don't know where.
<havenwood> simonfromspace: Do you expect this to trigger the interface you want?: https://github.com/simonpeterdebbarma/eztv-scraper/blob/scraper/bin/eztv-scraper#L5
<havenwood> simonfromspace: What should it be to make it hum
<havenwood> ?
jintseng has joined #ruby
<simonfromspace> Yeah, would that be possible?
<havenwood> simonfromspace: What method do you need to call on this instance to get it going? What's it supposed to do?
<havenwood> simonfromspace: In the executable, do whatever it is that it's supposed to do.
<simonfromspace> calling the class EZTVScraper.new does everything
<havenwood> simonfromspace: Then it should *just work*.
<simonfromspace> Yes sir
<simonfromspace> It works fine when I call the class in a ruby file
<havenwood> simonfromspace: But the executable does nothing?
<simonfromspace> You know how git works anywhere when you call it, I thought it would work like that
<havenwood> simonfromspace: Sanity check that it's the right file. Check: command -V eztv-scraper
<havenwood> simonfromspace: It should work like that.
<havenwood> simonfromspace: I don't think I get your issue. Are you saying you're running `eztv-scraper` and it doesn't print anything?
<havenwood> simonfromspace: Look at the file you're running: cat `which eztv-scraper`
<havenwood> simonfromspace: which -a eztv-scraper
<havenwood> simonfromspace: I'm in a meeting, but make sure you're running the gem you've installed, the right branch, and that the content you think is in the executable is tere.
<havenwood> there*
<simonfromspace> Okay
<simonfromspace> You should attend your meeting
<simonfromspace> Thanks for the suggestions
<simonfromspace> I'll see what I can do
splud_wurk has joined #ruby
chalkmonster has joined #ruby
coderhs has joined #ruby
mikecmpbll has joined #ruby
burningserenity has quit [Ping timeout: 255 seconds]
chalkmonster has quit [Quit: WeeChat 2.7]
Snowy has quit [Remote host closed the connection]
codefriar has joined #ruby
Snowy has joined #ruby
royal_screwup21 has joined #ruby
Snowy has quit [Ping timeout: 258 seconds]
gigetoo has quit [Ping timeout: 245 seconds]
bsdbandit-01 has quit [Quit: -a- Connection Timed Out]
gigetoo has joined #ruby
bsdbandit-01 has joined #ruby
burningserenity has joined #ruby
royal_screwup21 has quit [Remote host closed the connection]
<simonfromspace> I tried to look at other gems on Github including their gemspec but I can't figure out why my gem does not run when called in the CLI
<havenwood> simonfromspace: You can edit your gem in place with `gem open eztv_scraper` then put a debugging line in the executable: p "IT RAN"
<havenwood> simonfromspace: You can revert those changes with: gem pristine eztv_scraper
jmcgnh has quit [Ping timeout: 255 seconds]
rippa has joined #ruby
<simonfromspace> Oh
<simonfromspace> isn't that file required?
<havenwood> simonfromspace: Is that how the file is spelled?
<havenwood> simonfromspace: Isn't it a dash?
<simonfromspace> No
<simonfromspace> The gem works fine if I call EZTVScraper.new in a random ruby file
<havenwood> simonfromspace: eztv-scraper
<havenwood> simonfromspace: eztv_scraper
<havenwood> simonfromspace: oh, you changed the exe
<havenwood> simonfromspace: This file path isn't quite idiomatic yet: https://github.com/simonpeterdebbarma/eztv-scraper/blob/gem/eztv_scraper.gemspec#L23
<simonfromspace> yeah, should i make them all snake_case?
<havenwood> simonfromspace: switch lib/EZTVScraper/ to lib/eztv_scraper/
<simonfromspace> right on
<havenwood> simonfromspace: Yeah, always snake case for files, other than executables, where you can dash if you want
jmcgnh has joined #ruby
<havenwood> simonfromspace: Then move your Gemfile deps to the eztv_scraper.gemspec and just have Gemfile have: gemspec
<simonfromspace> can I skip version number for now?
tau has joined #ruby
<havenwood> simonfromspace: yeah, you can just edit a gem then occasionally publish a new version when you feel like it
<simonfromspace> I mean, version number for deps
<havenwood> simonfromspace: I like to use a pessimistic operator, like `'~> 1'` unless I fear a dep doesn't follow semver.
clemens3 has joined #ruby
<havenwood> simonfromspace: Think which deps are development versus not.
<havenwood> simonfromspace: In this ^ case, base32 and concurrent-ruby are deps and minitest and rake are dev deps.
burningserenity has quit [Remote host closed the connection]
<simonfromspace> Okay
<simonfromspace> I'll do that
<havenwood> simonfromspace: Then `gem open eztv_scraper` and put a debugging line in bin/eztv_scraper to see why it's not working as expected.
<havenwood> simonfromspace: To revert your gem to the unedited version: gem pristine eztv_scraper.
<simonfromspace> I'll let you know what happens
<havenwood> simonfromspace: Good luck!
<simonfromspace> ty
Ai9zO5AP has joined #ruby
jenrzzz has quit [Ping timeout: 255 seconds]
burningserenity has joined #ruby
alexherbo2 has joined #ruby
<simonfromspace> how do I translate this in gemspec -> nokogiri (1.10.8 x64-mingw32, 1.10.7 x64-mingw32)
alfiemax has quit [Remote host closed the connection]
nahmanreally has joined #ruby
tau has quit [Read error: Connection reset by peer]
<havenwood> simonfromspace: s.add_dependency 'nokogiri', '~> 1'
<havenwood> simonfromspace: Then, once you put `gemspec` in place of gem in the Gemfile, run: bundle
burningserenity has quit [Ping timeout: 255 seconds]
<simonfromspace> Okay
<simonfromspace> I see you put very specific releases
burningserenity has joined #ruby
chalkmonster has joined #ruby
gheegh has joined #ruby
<simonfromspace> havenwood, did the gem open eztv_scraper but it didn't do anything
lmns has quit [Quit: The Lounge - https://thelounge.chat]
<havenwood> simonfromspace: Alternatively, just run the local version of the binary: bin/eztv_scraper
<havenwood> simonfromspace: Are you on Windows or something Unixy?
<simonfromspace> Yes
alexherbo24 has joined #ruby
<simonfromspace> Win 10 x64
<havenwood> I don't know PowerShell, but check what the equivalent of `which` and `cat` are and take a look at `which eztv_scraper` and then `cat $(which eztv_scraper`.
<havenwood> simonfromspace: You can just edit the gem files.
<havenwood> simonfromspace: Then restore them, with: gem pristine
alexherbo2 has quit [Ping timeout: 255 seconds]
alexherbo24 is now known as alexherbo2
<havenwood> simonfromspace: Figure out a quick feedback loop for editing the gem and do some print-based debugging with the executable to sanity check.
xco has joined #ruby
xco has quit [Client Quit]
ellcs1 has joined #ruby
burningserenity has quit [Ping timeout: 265 seconds]
jenrzzz has joined #ruby
<simonfromspace> havenwood,
<simonfromspace> what are these lines doing?
<simonfromspace> Also, I think my problem is I'm missing an executable https://guides.rubygems.org/make-your-own-gem/#adding-an-executable
<ytti> simonfromspace, adds 'lib' directory in current directory to the path where 'require' seaerches for them
<ytti> simonfromspace, unnecessary today, as you could and should use require_relative
<simonfromspace> So should I require lib if I want to make my gem executable?
<ytti> no
<ytti> in this context 'digest/sip_hash/version' is in local lib directory
<ytti> and 'require' couldn't load it
<ytti> but because $LOAD_PATH was manipulated to include 'lib', now require can load it
<ytti> it should instead be
<ytti> require_relative 'lib/digest/sip_hash/version'
<ytti> for lines 3..5
<simonfromspace> alright
<ytti> it's probably copied from some skeleton author uses since early ruby days
<ytti> and never refactored to be more idiomatic in modern ruby land
TomyWork has quit [Ping timeout: 256 seconds]
<simonfromspace> I see
<simonfromspace> https://dpaste.org/du0c
<simonfromspace> Do you think I need any changes in my gemspec?
<gheegh> anyone dealing with Rails ever have the problem that Sidekiq is processing the queue in LIFO order instead of FIFO order? I can't find ANYTHING that explains why this is happening..
<simonfromspace> Removed the require_relative and it worked just fine :D ytti
<simonfromspace> havenwood, it works. my gem works. it executes
burningserenity has joined #ruby
<ytti> i personally generate files from git
<ytti> s.files = %x(git ls-files -z).split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
sauvin has quit [Remote host closed the connection]
<ytti> i'dp robably add email at least, maybe homepage too (like git repo)
<ytti> i probably wouldn't bother with date
<ytti> and if i did, i'd generate it
<ytti> and unless you are actually opinoinated about licenses, i wouldn't choose GPL, but would choose apache
<ytti> to be less restrictive
<ytti> GPL stuff isn't welcome in bsd worlds in many cases
<ytti> or is less accepted
<ytti> i have bias against apache, because it communicates antipatent sentiment
<ytti> s/against/for/
<ytti> (as opposed to say bsd or mit license)
<simonfromspace> Okay I'll make the changes as instructed. This was my first gem so I'm open to any feedback.
<simonfromspace> I do not really know how to generate the files but I'll try to read your code above and understand what it does
burningserenity has quit [Read error: Connection reset by peer]
jenrzzz has quit [Ping timeout: 258 seconds]
infinity2022 has quit [Read error: Connection reset by peer]
infinity2022 has joined #ruby
burningserenity has joined #ruby
suukim has quit [Quit: Konversation terminated!]
<ytti> simonfromspace, it just asks git what files are in the repo, then removes some things we really dont want
<ytti> simonfromspace, so it wont work unless you're actually using git
lxsameer has joined #ruby
burningserenity has quit [Read error: Connection reset by peer]
<ytti> which today is usually safe bet
<simonfromspace> it is sure bet
<ytti> then it should work verbatim
<ytti> and produce equivalent array as your manual one
<ytti> but require no maintaince when you add/remove files
bvdw has quit [Read error: Connection reset by peer]
alexherbo2 has quit [Ping timeout: 260 seconds]
bvdw has joined #ruby
burningserenity has joined #ruby
dionysus69 has quit [Remote host closed the connection]
burningserenity has quit [Read error: Connection reset by peer]
<simonfromspace> done ytti
hramrach has joined #ruby
leitz has joined #ruby
<hramrach> hello
kinduff has quit [Quit: Leaving]
<hramrach> if my ruby code locks up is there good way to debug?
<ellcs1> gdb attach to the process
<ellcs1> and print the ruby stacktrace
<hramrach> does gdb understand ruby code?
<ellcs1> ruby is written in c :)
<hramrach> looks interesting, thanks
<ellcs1> you can call c functions
burningserenity has joined #ruby
schne1der has quit [Quit: schne1der]
<hramrach> I know it's written in C but showing only the C part of the stacktrace is not going to be very useful
<ellcs1> yes, don't simply call gdbs bt
<leitz> hramrach, are you sure it's the C part, and not something in Ruby?
<havenwood> fun gem, on the subject: https://github.com/david942j/gdb-ruby
<ellcs1> (gdb) call rb_backtrace()
<ellcs1> ^ calls the ruby backtrace
<hramrach> I will try, thanks
burningserenity has quit [Read error: Connection reset by peer]
fphilipe has joined #ruby
hiroaki has joined #ruby
burningserenity has joined #ruby
gheegh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<hramrach> what is the rb_stacktrace supposed to do?
burningserenity has quit [Read error: Connection reset by peer]
SuperL4g has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.7]
burningserenity has joined #ruby
<hramrach> call (void) rb_backtrace() outputs stacktrace to stderr which I have redirected
<hramrach> and it's actually looping so that should not be that bad to figure out
gheegh has joined #ruby
gheegh has quit [Client Quit]
SuperLag has quit [Ping timeout: 265 seconds]
gheegh has joined #ruby
burningserenity has quit [Ping timeout: 260 seconds]
ur5us has joined #ruby
markopasha has joined #ruby
<ellcs1> i didn't see rb_stacktrace ¯\_(ツ)_/¯
wald0 has joined #ruby
mikecmpbll has quit [Ping timeout: 240 seconds]
<wald0> if i want to revert a series of commits, what is the correct order? from the older one to the new one?
<wald0> oops, wrong channel
wald0 has quit [Read error: Connection reset by peer]
jenrzzz has joined #ruby
wald0 has joined #ruby
wald0 has quit [Client Quit]
burningserenity has joined #ruby
chalkmonster has joined #ruby
<al2o3-cr> shame sprintf doesn't support `'` flag
minall has joined #ruby
<minall> Hello Ruby community!
<minall> I'm studying about ruby's modules, and in one example, They create a module named Trig, and a method called: Trig.sin(x). This is understandable, they are creating a method for Trig that takes a parameter
<minall> My question is, couldn't the method just be created as sin(x) instead of Trig.sin(x)?... I could just refer to Trig.sin(2) or something like that after all
bvdw has quit [Read error: Connection reset by peer]
<minall> What's the difference between naming it Trig.sin(x) and just sin(x) since they two can be called as Trig.sin(5) or something like that?
bvdw has joined #ruby
<adam12> minall: Defining sin(x) inside Trig would be in a different scope. You wouldn't be able to call Trig.sin(x) since that expects sin(x) to live on the Trig eigenclass or singleton class. The only way to do that is to reopen the singleton class by asking Ruby to (ie. Calling `Trig` explicitely, using `self` when self is the singleton class, class << self when self is the singleton class, etc.)
TCZ has joined #ruby
<adam12> minall: The only way to make it work would be to use the module_function method, which copies a method from the scope of the module into the scope of the singleton class.
mossplix has joined #ruby
<minall> Thanks adam12, so they are different... I'm reading about instance methods vs class methods
<adam12> havenwood: great example
<minall> Thanks havenwood !, that makes more sense
leah2 has quit [Remote host closed the connection]
Tuor has joined #ruby
code_zombie has joined #ruby
leah2 has joined #ruby
<Tuor> Hi, I would like to be able to use ruby2.7 on Ubuntu 19.10. I installed the snap but when I enter ruby -v it still prints 2.5.5. How can I use the ruby which comes with the snap package?
mossplix has quit [Remote host closed the connection]
<minall> Ok, thanks for the example of havenwood, I understood that class methods can't be called from a new variable created but referencing the class
<minall> And instance methods can't be used referencing the class but by creating a new variable
<minall> I'm thinking on an example of a real world usage on this, but I can't think anything
<havenwood> Tuor: Check: which -a ruby
chalkmonster has quit [Ping timeout: 258 seconds]
<Tuor> there is /snap/bin/ruby
<havenwood> Tuor: You can probably just move /bin/snap in front of your PATH.
<havenwood> Tuor: export PATH="/bin/snap:$PATH"
<Tuor> :) thx
<havenwood> minall: If you have no internal state, then you can use a module instead of a class. Modules are great for functions that don't rely on any state associated with the receiver module. If you have a single instance of state, there's a special Singleton class. Or if you have multiple instances of state, just use a regular class.
chalkmonster has joined #ruby
<havenwood> minall: Sec, I'll make an example.
mossplix has joined #ruby
<minall> Thanks!
pupsikov has joined #ruby
<havenwood> minall: That ^ shows a module with a function, so no state - all info comes from parameters to the functions.
<havenwood> minall: And a singleton class, where there's just a single instance ever.
<havenwood> minall: And then a regular class, where you can have a bunch of different versions, each with internal state.
leah2 has quit [Remote host closed the connection]
mossplix has quit [Remote host closed the connection]
<minall> Thanks for the great example havenwood !
<minall> I think I'm not asking for the think I'm looking for... A better question will be:
<havenwood> minall: No prob! You'll note on the `singleton_instance` one you can do `SingleInstanceOfState.instance` and it's the same as that variable.
<minall> Yes!
leah2 has joined #ruby
<minall> I'm actually looking for... Why is that you can't call class methods on instance objects and instance methods on class objects?
<minall> Or I'll find the answer by clearing questions about OOP?
<havenwood> minall: Ruby is flexible, so you *can* do all sorts of things.
<havenwood> &>> minall = 'minall'; def minall.hola; :hi end; minall.hola
<rubydoc> # => :hi (https://carc.in/#/r/8lne)
<minall> Of course, I could also return an instanece variable
<havenwood> minall: For example, there ^ I defined a singleton method on a single string. ¯\_(ツ)_/¯
<havenwood> You can do the same for the class itself.
<havenwood> minall: I think you'll find that if you follow simplest-thing-that-works you'll only occasionally be using some of these features.
<minall> Lol that's amazing
nofxx_ has joined #ruby
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
nofxx has quit [Ping timeout: 255 seconds]
burningserenity has quit [Quit: Leaving.]
<minall> I'm realizing that it depends on the approach, why I want to declare an instance methods and why and the same with class methods
<minall> I understand it now... Thanks havenwood !
<havenwood> minall: You're welcome!
<minall> But as the good apprentice, I have to keep asking questions
mossplix has joined #ruby
<minall> I'm reading about namespaces, one of the example of using them is: there are times when you want to group things together that don't naturally form a class.
<minall> I can't think of an example when I want to group things that don't form a class. If a class is methods
<minall> *can have methods
<minall> I mean, if I create a method with some classes an include it in some classes, isn't the same as creating classes and creating more classes inside of that clasS? or inheriting the class?
<phaul> stdlib has Math
<phaul> Math.cos, sin, exp etc
<phaul> but there is no math instance. debatable if the desing where these are instance methods on a Numeric is better or worse
<phaul> so instead 2.3.sin, but it reads somewhat unnatural
<phaul> Math.sin(2.3) is more the human way
<minall> Cool!, and I see that namespaces can be used to reference modules variables!
<havenwood> &>> class Integer; include Math; def sin; super self end end; 666.sin
<rubydoc> # => -0.01764164581327013 (https://carc.in/#/r/8lno)
<havenwood> minall: That's ^ taking advantage of the mixin style, just to show how you might use it.
<minall> Lol!
<havenwood> minall: #super there calls the mixed in #sin
<minall> That's cool, I'm making some experiments, I can say: class About < Neo::Koan will make a new About class that will inherit everything from the class Koan inside the module neo... Trying to understand this was also why I was reading about instances and such
<minall> I'm amazed of ruby lol.
<havenwood> minall: I think this is a fun look at the object model: https://go.gliffy.com/go/publish/5152080
<havenwood> minall: The red lines are those inheriting classes.
<havenwood> minall: The blue lines are these mixins.
<minall> What is this gem (pun intended) you gave me havenwood
<dreamreal> havenwood: what IDE do you use?
<dreamreal> if any, I guess
<havenwood> dreamreal: I currently have VS Code open. It depends!
<dreamreal> *nod* support projects well, I guess?
<havenwood> dreamreal: I'm currently using it with solargraph, which works well. I look forward to Steep support.
<havenwood> dreamreal: Stay tuned for Soutaro's keynote at RubyKaigi! :)
<havenwood> dreamreal: He has been working on Ruby::Signature: https://github.com/ruby/ruby-signature
<havenwood> dreamreal: This is Steep: https://github.com/soutaro/steep
<dreamreal> havenwood: also, and probably a total and complete surprise to you: chruby works better than rvm
<havenwood> dreamreal: It does one thing, and does it well.
hoijui has quit [Ping timeout: 240 seconds]
<havenwood> dreamreal: RVM does all sorts of things that chruby doesn't, but it's over 10,000 lines of code versus chruby's ~200 lines. It makes chruby much easier to maintain. You just sit back and watch it *just work*.
<havenwood> Version switchers are a thorn patch, generally.
<dreamreal> yeah
Ai9zO5AP has quit [Quit: WeeChat 2.7]
bsdbandit-01 has quit [Ping timeout: 258 seconds]
bsdband97 has joined #ruby
jmcgnh has quit [Read error: Connection reset by peer]
sagax has quit [Ping timeout: 272 seconds]
Nathan2276 has quit [Remote host closed the connection]
jmcgnh has joined #ruby
Ai9zO5AP has joined #ruby
minall has quit [Remote host closed the connection]
fphilipe has quit [Ping timeout: 272 seconds]
dostoyevsky has quit [Ping timeout: 240 seconds]
gheegh has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gheegh has joined #ruby
chalkmonster has quit [Quit: WeeChat 2.7]
citizentwo has quit [Remote host closed the connection]
bsdband97 has quit [Ping timeout: 255 seconds]
citizentwo has joined #ruby
ellcs1 has quit [Ping timeout: 240 seconds]
bsdbandit-01 has joined #ruby
zapata has quit [Ping timeout: 245 seconds]
citizentwo has quit [Remote host closed the connection]
zapata has joined #ruby
fphilipe has joined #ruby
dostoyevsky has joined #ruby
Esa has quit []
alfiemax has joined #ruby
pupsikov has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jcalla has quit [Ping timeout: 265 seconds]
alfiemax has quit [Ping timeout: 258 seconds]
TinderFX has quit [Ping timeout: 240 seconds]
LinuxKnight has quit [Ping timeout: 272 seconds]
jcalla has joined #ruby
Fernando-Basso has quit [Quit: Leaving]
ewanchic has joined #ruby
Fusl has quit [Quit: K-Lined]
jenrzzz_ has joined #ruby
jintseng has quit [Ping timeout: 240 seconds]
jenrzzz has quit [Ping timeout: 240 seconds]
Fusl has joined #ruby
mossplix has quit [Remote host closed the connection]
DaRock has joined #ruby
pwnd_nsfw has joined #ruby
lxsameer has quit [Quit: WeeChat 2.6]
hiroaki has quit [Ping timeout: 272 seconds]
lucasb has quit [Quit: Connection closed for inactivity]
<simonfromspace> in rspec, how do I expect a method that's inside a module, inside a class
<phaul> is it a public instance method of the class?
<simonfromspace> yes
coderhs has quit [Ping timeout: 248 seconds]
<simonfromspace> yes
<phaul> module M; class X; def foo; 13; end; end; end; Rspec.describe M::X do subject { described_class.new } ; it 'is 13' { expect(subject.foo).to eq 13 }; end
<phaul> I haven't tried the syntax just giving you idea
<TCZ> how to add 2 arrays -> [1,2,3] + [4,5,6] = [5,7,9], is there a class for this purpose like vector or smthing
<phaul> &ri Array#zip, TCZ
coderhs has joined #ruby
<simonfromspace> okay thanks I'll try
ur5us_ has joined #ruby
<phaul> or more succint context '#foo' do subject {described_class.new.foo } ; it { is_expected.to eq 13 } ; end inside the describe block
ur5us has quit [Ping timeout: 248 seconds]
<phaul> I made a few rspec best practice violations in these suggestions. that context prly should be describe, and we should name our subject if it expects on subject.some_message. But these are stylistic questions
xco has joined #ruby
<TCZ> &>> [1,2,3].zip([4,5,6]).map {|a| a[0]+a[1]}
<rubydoc> # => [5, 7, 9] (https://carc.in/#/r/8log)
<TCZ> &>> Vector[1,2,3] + Vector[4,5,6]
<rubydoc> stderr: -e:4:in `<main>': uninitialized constant Vector (NameError)... check link for more (https://carc.in/#/r/8loh)
<phaul> TCZ that works but zip itself can aso take a block
<TCZ> ah
<phaul> &>> [1,2,3].zip([4,5,6]) { |a, b| a + b }
<rubydoc> # => nil (https://carc.in/#/r/8loi)
<phaul> ah well.
<phaul> then you need a map :( but you can still splat the sub arrays into the bock arguments
<phaul> &>> [1,2,3].zip([4,5,6]).map { |a, b| a + b }
<rubydoc> # => [5, 7, 9] (https://carc.in/#/r/8lon)