[#402707] Require a ruby project to automatically include the modules in classes defined in the same .rb file — Marc Heiler <lists@...>

Hi.

11 messages 2013/01/03
[#402738] Re: Require a ruby project to automatically include the modules in classes defined in the same .rb file — Josh Cheek <josh.cheek@...> 2013/01/04

On Wed, Jan 2, 2013 at 9:58 PM, Marc Heiler <lists@ruby-forum.com> wrote:

[#402764] Best practice for &&, ||, and, or — sto.mar@...

Hi group,

33 messages 2013/01/05
[#402786] Re: Best practice for &&, ||, and, or — "Jan E." <lists@...> 2013/01/05

Hi,

[#402812] newbie question what am I doing wrong? — "Lee V." <lists@...>

I wrote this simple program but it won't work. What am I doing wrong?

13 messages 2013/01/07

[#402856] Ruby on Android - usb/serialport — Scott Macri <lists@...>

Hello,

12 messages 2013/01/07

[#402880] One liner for filenames — Peter Bailey <lists@...>

Hello,

18 messages 2013/01/08

[#402890] Pure Ruby Jobs — Brandon Weaver <keystonelemur@...>

One thing has been bugging me lately. I've been looking around for jobs in

15 messages 2013/01/09

[#402958] how to open pop up window table? — Arup Rakshit <lists@...>

There is `text label` on a webpage, and I am trying to click on that to

13 messages 2013/01/10

[#403015] How Ruby environment varibles work in realtime program? — Arup Rakshit <lists@...>

Hi,

11 messages 2013/01/11

[#403051] Array methods creating confusions as per their functionalities — Arup Rakshit <lists@...>

Can any one just elaborate how the below works in Ruby, by definition

10 messages 2013/01/12

[#403062] How to take information from a text file and add them to an array — Adam Kennedy <lists@...>

Hi Im trying to take a list of usernames from a text file then add them

13 messages 2013/01/12

[#403083] Can anyone tell me the computational logic of Unpack() method of string? — Arup Rakshit <lists@...>

Hi,

17 messages 2013/01/12

[#403116] Garbage Collection and Fibers — Na Na <lists@...>

Hi,

20 messages 2013/01/13

[#403127] Conversion of Ruby-code to c/c++ code :: URGENT Plz help — "Nilesh S." <lists@...>

Hi.. I urgent require to convert the following ruby-code to c/c++ code.

11 messages 2013/01/14

[#403139] Installation query — Ron Herrema <lists@...>

I'm new to Ruby and am enjoying it, but when I installed, I attempted to

19 messages 2013/01/14

[#403205] Escaped backslashes in input strings - newbie question — John Sampson <jrs.idx@...>

I am trying to find a way of removing escaped characters in input

13 messages 2013/01/16
[#403208] Re: Escaped backslashes in input strings - newbie question — Alexander McMillan <alexandermcmillan@...> 2013/01/16

[#403244] Adding file directory automatically — Adam Kennedy <lists@...>

I have a bit of code that will add an amount to an array and then print

23 messages 2013/01/17

[#403326] question about string concatenation — David Richards <lists@...>

I'm puzzled about why the following happens (I'm using v1.9.3):

11 messages 2013/01/20

[#403377] Getting error "getaddrinfo: No such host is known. (Socke tError)" with mechanize gem — Arup Rakshit <lists@...>

I tried the below code:

9 messages 2013/01/22
[#403379] Re: Getting error "getaddrinfo: No such host is known. (Socke tError)" with mechanize gem — Robert Klemme <shortcutter@...> 2013/01/22

On Tue, Jan 22, 2013 at 3:52 PM, Arup Rakshit <lists@ruby-forum.com> wrote:

[#403423] Reading and looping through Excel — cristian cristian <lists@...>

Hi all!

16 messages 2013/01/24

[#403456] Can we attach documents to excel columns using Ruby? — Arup Rakshit <lists@...>

Suppose I do have some folders in a directory. Now say directory name

12 messages 2013/01/24

[#403540] Please explain in English — jooma lavata <lists@...>

I'm learning Ruby and I'm reading some expression that I saw on the

20 messages 2013/01/28

[#403553] Learning Ruby and proving your knowledge — Nathaniel Sokoll-Ward <lists@...>

Hey all,

19 messages 2013/01/28

[#403581] newbie question.. — Zebulon Bowles <lists@...>

So I'm taking a class on Ruby and it seems as though the teacher has

12 messages 2013/01/29

[#403607] (Errno::EINVAL) occurs during the File::rename() execution — Arup Rakshit <lists@...>

Hi I wrote the below code to rename the file names. The logic is during

12 messages 2013/01/30

[#403642] How to copy the directory files only to another directory? — Arup Rakshit <lists@...>

Hi,

18 messages 2013/01/30

[#403656] Does Ruby has any default database with it? — Arup Rakshit <lists@...>

I will do webpage scraping using Ruby and required Gems. But looking for

28 messages 2013/01/30
[#403657] Re: Does Ruby has any default database with it? — Brandon Weaver <keystonelemur@...> 2013/01/30

Normally sqlite is the go to being that it's the default of rails. Check

[#403667] Re: Does Ruby has any default database with it? — Justin Collins <justincollins@...> 2013/01/30

On 01/30/2013 10:21 AM, Arup Rakshit wrote:

[#403671] Re: Does Ruby has any default database with it? — Tony Arcieri <tony.arcieri@...> 2013/01/30

On Wed, Jan 30, 2013 at 12:07 PM, Justin Collins <justincollins@ucla.edu>wrote:

[#403674] Re: Does Ruby has any default database with it? — Arup Rakshit <lists@...> 2013/01/30

Tony Arcieri wrote in post #1094436:

[#403678] Re: Does Ruby has any default database with it? — Justin Collins <justincollins@...> 2013/01/30

On 01/30/2013 12:27 PM, Arup Rakshit wrote:

[#403735] Re: Does Ruby has any default database with it? — tamouse mailing lists <tamouse.lists@...> 2013/02/01

I think the best course for a new project is to start simple, go with

[#403698] Select "columns" from multidimensional array? — Joel Pearson <lists@...>

There's probably a simpler answer to this than the ways I've come up

51 messages 2013/01/31

[#403718] Ruby Project Ideas to get someone hired... — Colby Callahan <colby.callahan@...>

I have started learning Ruby this past week and have down the basics of

15 messages 2013/01/31

Re: using shebang with rvm?

From: Stu <stu@...>
Date: 2013-01-02 08:00:25 UTC
List: ruby-talk #402689
Wes ~

That is what I was saying. Also this is correct if you deviate from
any posix syntax or use a third party language. So env would also be
used for bash or zsh where bashisms( i.e. shell extension) are used
but not ash.

example to use bash it's the same semantically for portability if one
requires bash or zsh specific syntax:

#!/usr/bin/env ksh
#!/usr/bin/env bash
#!/usr/bin/env zsh
#!/usr/bin/env fish


All bourne derived shells( i.e. not csh) are backward compatible with
posix sh which is a small mixture of original bourne syntax and korn
syntax.

The only time you would ever want to use a direct path is with a posix
sh script as so:

#!/bin/sh

or csh ... but don't use csh =)

#!/bin/csh -f

If your really curious on the spec you can be read here:
http://rubyprogrammer.net/~stu/posix/

You can set your path inside your interactive rc file with the $PATH
variable. It's delimited with a colon and is a first positive match
wins hash. If your writing a script that depends on knowing where your
binaries are you can use a variable to hold the direct path to the
executable or set the path variable directly inside the script.

Trivial example of embedded ruby embedded inside shell:

#!/bin/sh
r=/path/to/mri/ruby20
$r <<EOF
puts "Hello, world!"
RbConfig::CONFIG.each_pair { |k,v| puts k+':<=>:'+v }
s=RbConfig::CONFIG.values.grep /bin\/*sh/
puts <<EOR
Bye bye your current shell is #{s}
Your ruby is ${r}
EOR
EOF

Set the execute bit and run it through a pipe to less or tail -2 for
example. Have another ruby. Wanna glue one to the other? Create
benchmark results? Just some ideas. Maybe not the most practical
examples but provide you some insight on what may be useful with a
couple lines of shell code.

Bash is an okay shell for beginners. Consider zsh for interactive use
as it has a nice flow to development once you begin to customize it. I
have ash on FreeBSD which is very fast for shell scripts as it's <70kb
binary in contrast to bash being over a meg. I don't believe they
ported Almquist's shell to OSX. Maybe homebrew has it (sometimes under
the name dash in the gnu distros so I'm unsure what got ported on osx
as it's a mashup of FreeBSD kernel with BSD, next and gnu userland)...

My main toolset preference tends to be sh for system level automata,
primarily because that is my background... consider scripting a
network where ruby may or may not be present machine to machine , ruby
for larger stack oriented projects where oops, arrays may be needed,
zsh, vi, irb for my preferred development stack.

I also use rvm which is one of the few bash specific scripts, actually
I would call rvm a framework utility at this point, which it is obvious where
posix was considered but the need for the automation on directory
switching with rvmrc for developers whom needed various sandboxing
with minimal setup usurped avoiding the extended syntax of bash. The
need for arrays also is where bash becomes the dependency.

Take a look at Wayne's code. You will see some of the best shell code
by someone who takes such things seriously by studying rvm.

Other projects of the same vein such as chruby or rbenv make no effort
for portability outside of forcing user to install bash or run a
computer only capable of supporting homebrew .

I do find it ironic how the author of rbenv promoted it initially with
sort of a dunning kruger style marketing his way was the "one true
way" when it's far from a minimalist's alternative to rvm while
deviating from posix for no reason other than it's obvious the rbenv
developer is not a system administrator and knows of nothing other
than how to provide FUD with ad hominem bullet points like his lamers
statement that rvm is dangerous and error-prone. I guess this sort of
thing is how people get themselves noticed when either vying for some
corporate employment contract or simply to gain some sort of
superficial notoriety.

On a simpler level consider command env to work like how you
understand how the ruby interpreter yields results from it's block
iterators. /usr/bin/env ruby basically has ruby as an argument to the
command env which locates ruby in the path hash and yields the result
which in this case is the path located to the shell which instructs
the kernel to create a memory overlay to load ruby after env evaluates
the ruby location; From there ruby will be executed in place in order
to evaluate any of the code after which in turn yields each token to
the executable. The env will work with any command hashed from the
$PATH global environment variable.

Happy Hacking.

~Stu

On Tue, Jan 1, 2013 at 9:44 PM, Wesley Rishel <lists@ruby-forum.com> wrote:
> Stu wrote in post #1090776:
>> It's primarily for portability. Using env more or less defeats
>> portability issues as every box could have ruby installed somewhere
>> else.
>>
>> ...
>
> Thanks, Stu, the entire note was very helpful.
>
> I am not sure if you are suggesting that I should also be able to have a
> non-absolute path to env command.
>
> Using bash on OS 10.8 I find that a she-bang for Ruby just doesn't work
> unless it points to some absolute path.
>
> The most portable I can make a file is to say
>
>          #! /usr/bin/env ruby
>
> Anyway, that approach meets my needs.
>
> Regards,
>
> Wes
> ____
>
> "With consistency a great soul has simply nothing to do. Speak what you
> think today in hard words and tomorrow speak what tomorrow thinks in
> hard words again, though it contradict everything you said today. "
>
>                            Ralph Waldo Emerson
>
> ____
>
>
> --
> Posted via http://www.ruby-forum.com/.

In This Thread

Prev Next