havenwood changed the topic of #ruby to: Rules: https://ruby-community.com | Ruby 3.1.0, 3.0.3, 2.7.5: https://www.ruby-lang.org | Paste 4+ lines to: https://gist.github.com | Books: https://goo.gl/wpGhoQ
bobdobbs` has joined #ruby
<ccooke> nakilon: Technically, I suspect that it would have been by way of perl. Ruby picks up a lot of inspiration from perl, after all.
<ccooke> (of course, perl did not originate them, but there's a chain of inheritance here :-)
hellstabber has quit [Remote host closed the connection]
<weaksauce> I think perl had them because of awk and awk probably started the chain
<weaksauce> i imagine awk started it at least since it makes the most sense for that program
graywolf has joined #ruby
<ccooke> I believe they predate awk
<wnd> there's algol with BEGIN and END
<ccooke> yeah
<ccooke> I was just trying to check if algol had them, but it is late and my searching is clearly bad)
<ccooke> (If I'm reading correclty, Algol has a compile time block delimited by BEGIN...END. It does not have a BEGIN and END block that execute before or after the rest of the code respectively
<ccooke> If I'm reading this correctly, of course)
<ccooke> (well, looks like perl definitely got BEGIN/END from awk; awk had them pre perl 1.0, perl 1.0 has them and explicitly is announced as a replacemrnt for sed/awk/shell)
<ccooke> (... I should go sleep and stop nerdsniping myself)
<weaksauce> oh yeah i meant them in the way ruby uses them not the way other programming languages use them
<weaksauce> begin end is in many languages to denote a block
graywolf has quit [Quit: WeeChat 3.3]
<John_Ivan> weaksauce, does ruby support macro redefinition?
<John_Ivan> e.g something similar to "#define keyword my_own"
<weaksauce> it supports a lot of metaprogramming
<weaksauce> it's... very flexible
<John_Ivan> I like the sound of that :>
<weaksauce> method_missing, const_missing, open classes
<weaksauce> dynamic dispatch
<weaksauce> method definition on the fly
<weaksauce> alias is a keyword you can use to redefine methods
<John_Ivan> weaksauce, fucking sweet!
<weaksauce> alias_method is another with slightly similar semantics
<weaksauce> if you just want to overwrite a method you can just redefine it
<weaksauce> class String; def to_s "hello"; end; end
<John_Ivan> weaksauce, so what would be a way for me to, say, introduce { } on if statements, methods, etc instead of "end"?
<John_Ivan> e.g if (), while (), def mymethod() {}, etc.
<John_Ivan> uh
<John_Ivan> if {}** while {}**
<weaksauce> that's probably one of the few things that is not possible
<weaksauce> you can pass {} to methods
<John_Ivan> awh. pity.
<weaksauce> and it is a block
<weaksauce> that you can call inside it
<weaksauce> like each {|x| puts x }
<weaksauce> that's basically just an anonymous function that gets passed into the function either explicitly or implicitly depending
<John_Ivan> hm
<John_Ivan> yeah. gotcha
<John_Ivan> I mean
<weaksauce> def each(&theblock) theblock.call() end
<John_Ivan> I don't mind the end. I'm actually relieved it's there. in python there's NOTHING
<John_Ivan> but between having something there and nothing, I prefer braces
<John_Ivan> :P
<weaksauce> or def each; yield(something); end
<weaksauce> that is the difference
<weaksauce> yeah since blocks are so common in ruby the do end and { } syntax is all over the place and you can't really use it for control flow like you want
<John_Ivan> weaksauce, no worries.
geewiz has joined #ruby
<John_Ivan> weaksauce, do you use anything other than IRC? discord for example?
<gr33n7007h> John_Ivan: you could do something like this: def iff(cond, &b) b.call if cond end; iff ( 1 == 1 ) { puts :yay }
Pipip has joined #ruby
infernix has quit [Quit: ZNC - http://znc.sourceforge.net]
geewiz has quit [Ping timeout: 256 seconds]
John_Ivan has quit [Ping timeout: 256 seconds]
arkantos has joined #ruby
Rounin has quit [Ping timeout: 256 seconds]
Pipip has quit [Quit: Ex-Chat]
infernix has joined #ruby
oxfuxxx has joined #ruby
szkl has quit [Quit: Connection closed for inactivity]
arkantos has quit [Quit: Connection closed for inactivity]
hololeap has joined #ruby
kapil has joined #ruby
edrx has joined #ruby
<edrx> ppl, how do I get a REPL for ruby without the fancy colors of irb?
<edrx> irb works well in the way of using Ruby from Emacs described in these slides - http://angg.twu.net/LATEX/2021emacsconf.pdf - _on recent versions of Emacs_, but its terminal control sequences confuse older versions of Emacs...
<edrx> on Emacs25 I get this: https://i.ibb.co/yyDxFXK/sshot.png
oxfuxxx has quit [Quit: Raccoon's not another IRC transgenre wannabe who can't fap at the dead american dream, fhackerz]
<bobdobbs`> I'm trying to check if a directory exists. I get different results from Dir.exist? depending if I'm running it from a file or running it from irb. This is my file: http://pastie.org/p/0BHHZ3evaTr4jHzQAkJRRc
<bobdobbs`> If I pass in the name of a directory to the function Dir.exists? in that script, I get "false". But if I pass the exact same value into Dir.exist? in irb, I get 'true'.
<bobdobbs`> Also in irb, the following line returns true: b = Dir.exist?('[pathname]')
perrierjouet has quit [Quit: WeeChat 3.3]
edrx has left #ruby [Killed buffer]
perrierjouet has joined #ruby
perrierjouet has quit [Client Quit]
perrierjouet has joined #ruby
oxfuxxx has joined #ruby
teclator has joined #ruby
oxfuxxx has quit [Quit: Raccoon's not another IRC transgenre wannabe who can't fap at the dead american dream, fhackerz]
oxfuxxx has joined #ruby
oxfuxxx has quit [Remote host closed the connection]
oxfuxxx has joined #ruby
oxfuxxx has quit [Remote host closed the connection]
oxfuxxx has joined #ruby
oxfuxxx has quit [Client Quit]
<weaksauce> bobdobbs` probably the newline thing try chomp
<weaksauce> or you can use strip on the gets
oxfuxxx has joined #ruby
oxfuxxx has quit [Remote host closed the connection]
oxfuxxx has joined #ruby
oxfuxxx has quit [Quit: Raccoon's not another IRC transgenre wannabe who can't fap at the dead american dream, fhackerz]
oxfuxxx has joined #ruby
oxfuxxx has quit [Remote host closed the connection]
gproto23 has joined #ruby
_ht has joined #ruby
<gproto23> hey folks. i need a module for building complex pipelines in ruby
<gproto23> like a Luigi (https://github.com/spotify/luigi)
oxfuxxx has joined #ruby
oxfuxxx has quit [Read error: Connection reset by peer]
oxfuxxx has joined #ruby
geewiz has joined #ruby
oxfuxxx has quit [Ping timeout: 240 seconds]
gproto23_ has joined #ruby
gproto23_ has quit [Remote host closed the connection]
gproto23_ has joined #ruby
gproto23 has quit [Ping timeout: 240 seconds]
gproto23_ has quit [Ping timeout: 256 seconds]
tsujp has quit [Quit: Client closed]
tsujp has joined #ruby
graemefawcett has joined #ruby
devz3ro has quit [Ping timeout: 240 seconds]
devz3ro has joined #ruby
gproto23 has joined #ruby
Rounin has joined #ruby
gproto23 has quit [Read error: Connection reset by peer]
gr33n7007h has quit [Quit: WeeChat 3.4]
gr33n7007h has joined #ruby
gproto23 has joined #ruby
<gproto23> hey folks. i need a module for building complex pipelines in ruby
<havenwood> gproto23: Check out Rake or Bake
<havenwood> bobdobbs`: like weaksauce mentions, chomp, and you could also ensure you're chomping stdin: input = $stdin.gets(chomp: true)
<havenwood> gproto23: https://github.com/ruby/rake
<havenwood> gproto23: https://github.com/ioquatix/bake
<gproto23> thank you havenwood
infernix has quit [Quit: ZNC - http://znc.sourceforge.net]
John_Ivan has joined #ruby
infernix has joined #ruby
lim has joined #ruby
lim has quit [Remote host closed the connection]
robotmay has quit [Quit: No Ping reply in 180 seconds.]
robotmay has joined #ruby
<John_Ivan> gr33n7007h, I guess :)
<John_Ivan> weaksauce, morning.
<John_Ivan> I mean
<John_Ivan> 'top o' tha mornin' to yah me ol bud
lim has joined #ruby
lim has quit [Remote host closed the connection]
lim has joined #ruby
lim has quit [Remote host closed the connection]
lim has joined #ruby
lim has quit [Remote host closed the connection]
MeowcatWoofWoofF has quit [Quit: Client limit exceeded: 20000]
bit4bit has joined #ruby
casionaut has joined #ruby
infernix has quit [Ping timeout: 268 seconds]
michigan has joined #ruby
casionaut has quit [Quit: bye]
Guest7555 has joined #ruby
bit4bit has quit [Ping timeout: 256 seconds]
bluesh55 has joined #ruby
bluesh55 has left #ruby [WeeChat 3.3]
alain has joined #ruby
bluesh55 has joined #ruby
bluesh55 has left #ruby [WeeChat 3.3]
Guest7555 has left #ruby [#ruby]
catsh has joined #ruby
roadie has joined #ruby
catsh has quit [Quit: WeeChat 3.3]
catsh has joined #ruby
catsh has quit [Client Quit]
hellstabber has joined #ruby
roadie has quit [Ping timeout: 268 seconds]
roadie has joined #ruby
roadie has quit [Ping timeout: 240 seconds]
roadie has joined #ruby
roadie has quit [Remote host closed the connection]
roadie has joined #ruby
roadie has quit [Ping timeout: 245 seconds]
roadie has joined #ruby
timkaechele has joined #ruby
timkaechele1 has joined #ruby
timkaechele has quit [Ping timeout: 240 seconds]
bit4bit has joined #ruby
hellstabber has quit [Read error: Connection reset by peer]
graemefawcett has quit [Ping timeout: 268 seconds]
<bobdobbs`> In a command-line script, I want to present the user with a set of options. I then want to store the options selected by the user. I imagine the script presenting something like this to the user: http://pastie.org/p/0fyYIOhvhJzaCeCSsDQ0wR
MeowcatWoofWoofF has joined #ruby
<bobdobbs`> How can I do this?
ur5us_ has joined #ruby
graemefawcett has joined #ruby
gproto23 has quit [Remote host closed the connection]
<bobdobbs`> To illustrate what I'd like to do, this is how it's done in bash: https://tldp.org/LDP/Bash-Beginners-Guide/html/sect_09_06.html
<bobdobbs`> The difference is that I'd like users to be able to select multiple options instead of just one.
<bobdobbs`> I haven't been able to find anything on Google about how to do this with Ruby
ur5us_ has quit [Ping timeout: 268 seconds]
<michigan> bobdobbs`: I don't think Ruby is ideal for commandline scripts to be honest
<adam12> michigan: Why do you think that?
<bobdobbs`> michigan: ah, I see
<havenwood> michigan: What's ideal?
<bobdobbs`> adam12: thank you! I'll experiment with one or both of those
<adam12> bobdobbs`: I use tty-prompt in many projects. I think I've used tty-config in one? project. They both work well.
<leftylink> I think that in many instructional texts it is common to make a number guessing game to demonstrate interaction with the user... so perhaps a basic thing to search for might be "ruby guessing game"
<michigan> I remember wanting to rewrite all my Bash scripts in Ruby, but gave up when I saw how messy it al looked compared to regular Ruby scripts
<michigan> Ended up just rewriting them in Zsh instead (file renaming, find-and-replace etc.) -- a *lot* cleaner than Bash at least
_ht has quit [Remote host closed the connection]
<leftylink> what was that thing that went "never use X when Y can do the trick" "never use Y when Z can do it"
<leftylink> uhhhhh I guess it's https://linuxgazette.net/issue54/okopnik.html ??????
ur5us_ has joined #ruby
bit4bit has quit [Ping timeout: 260 seconds]
ur5us_ has quit [Ping timeout: 240 seconds]
teclator has quit [Remote host closed the connection]
<bobdobbs`> I'm building a script. I've got a kind of "master stub" in a parent directory and tests in a subdirectory. In the parent directory I've got a Gemfile that pulls in a couple of gems to the project. How can I make those gems accessible to my tests in the child directory?
ur5us_ has joined #ruby
<bobdobbs`> oh, actually I might have deeper problems. Even the script in the parent directory can't access the gems
TCZ has joined #ruby
aighearach_ has quit [Quit: Leaving]
aighearach has joined #ruby
<bobdobbs`> I'm trying to require the tty gem. At the moment I'm getting this error: http://pastie.org/p/35UYOyvISTg9y9ha39hUdd
<bobdobbs`> It seems to indicate a conflict between available version of a gem. So I deleted all the rubygems available to the version of ruby I'm using, and reinstalled the tty gem
<bobdobbs`> But when I created a script that does nothing else other than include the tty gem, I get the same error
alain has quit [Quit: WeeChat 3.2.1]
timkaechele has joined #ruby
timkaechele1 has quit [Ping timeout: 240 seconds]
TCZ has quit [Quit: Leaving]
TCZ has joined #ruby
TCZ has quit [Remote host closed the connection]
ur5us_ has quit [Remote host closed the connection]
ur5us_ has joined #ruby
<weaksauce> are you using a gemfile?
<weaksauce> can you gist that
<weaksauce> and the lock
<adam12> bobdobbs`: you also need to ensure bundler is being used. either via `bundle exec` or by requiring `bundler/setup`.
<adam12> I'd just use the `tty` gem
<adam12> and leave off `tty-prompt` from the Gemfile, since `tty` is a meta gem with all the deps.
<bobdobbs`> ok
<bobdobbs`> tbh, I'm not entirely clear what bundle does
<bobdobbs`> *bundler
<adam12> bobdobbs`: Specifies specific versions of gem dependencies, and sets up the correct loadpaths for them.
<bobdobbs`> ah, ok. I'm looking at bundler.io now
<adam12> bobdobbs`: So you can have 3 copies of tty installed (v1, v2, v3) and your Gemfile will say `tty v2`, which bundler will ensure you use (instead of v1 or v3 which may be incompatible)
<bobdobbs`> ah ok
<bobdobbs`> So I'm guessing that when I installed tty, Gem installed multiple versions of pastel. And when I run the 'require', ruby sees two different packages and doesn't know which one to use. Is that right?
<adam12> bobdobbs`: Right. It sounds like either tty-prompt was the issue, or you weren't using bundler (by the 2 methods I mentioned above).
<bobdobbs`> k. I'm looking at this documentation now: https://bundler.io/v2.2/guides/bundler_setup.html
<bobdobbs`> k, if I have a script that just has this line and nothing else: require 'bunder/setup'... then I get this: http://pastie.org/p/5GfT5vJ4tSe67GEN5EGq8v
<weaksauce> does it work with ruby 3?
<bobdobbs`> I'm using ruby 3.0.2
<weaksauce> yeah i mean is the gem compatible
<bobdobbs`> oh, good question
<bobdobbs`> I actually don't know. I'll try to find out
<bobdobbs`> I can't see anything their website or their main git page about compatibility
<weaksauce> it *should* be compatible but who knows
<bobdobbs`> well, at this point I can't figure out how to load it. So I'm googling for an alternative
<weaksauce> maybe check out the dry-rb project
<weaksauce> they might have something
<weaksauce> or google awesome ruby
<bobdobbs`> thanks. will check those out
<bobdobbs`> I couldn't see anything in those projects. But this looks promising: https://www.rubydoc.info/gems/cli-ui/CLI/UI/Prompt
geewiz has quit [Ping timeout: 260 seconds]