News for hackers. Stuff that matters.
Re:Ruby One-Liners by kbenson on Friday September 13, 2019 @09:17PM (#20968269)
A one liner does not mean "one line of source code in a file", it means "a single shell statement". That's why the Ruby command is prefixing them all. I routinely write 10-20 statement Perl one-liners at work for one off things.

For example, just yesterday it was to parse a log, grep for specific lines, pull out a time and a number per line, display name, number, and some number of characters afterwards as a quick abnd dirty graph of the magnitude to make it obvious if there were major outliers and to try to see trends over time. Still a one-liner.

Re:Ruby One-Liners by bdcravens on Friday September 13, 2019 @10:32PM (#20968570)
In theory, couldn’t you then compile a Rails app into a one-liner? (Seems the max line length varies, but is at least hundreds of thousands of characters in most OSes)
Re:Ruby One-Liners by kbenson on Saturday September 14, 2019 @12:17AM (#20968869)
You could, but it would be stupid to do so if it wasn't a trivial app, since nobody wants to support something like that, even if it's lifetime is measured in minutes or hours. It's a one-liner, just a pointless one.

That said, if rails has a super simple default startup that could serve a file, then it might be useful to start that as a one liner in select circumstances.

Re:Ruby One-Liners by vinceguidry on Saturday September 14, 2019 @07:58AM (#20970245)
Rails has generators for that. Invaluable for greenfielding projects in an iterative manner. Blow everything away and recreate with a single command.

https://guides.rubyonrails.org/generators.html

Re:Ruby One-Liners by vcavallo on Saturday September 14, 2019 @08:09AM (#20970288)
nobody wants to support weird looking one-liners either
Re:Ruby One-Liners by eyegor on Friday September 13, 2019 @11:38PM (#20968786)
Sure, but then you could refactor most programs into "one line" (similar to what another commenter pointed out). I was expecting more of a functional piping or chaining style as opposed to distinct statements and defining local variables.