[#390749] Why are there so many similar/identical methods in core classes — Kassym Dorsel <k.dorsel@...>

Let's look at the Array class and start with method aliases.

14 messages 2011/12/02

[#390755] Inverse Operation of Module#include — Su Zhang <su.comp.lang.ruby@...>

Hi list,

21 messages 2011/12/02
[#390759] Re: Inverse Operation of Module#include — Ryan Davis <ryand-ruby@...> 2011/12/02

[#390764] Re: Inverse Operation of Module#include — Isaac Sanders <isaacbfsanders@...> 2011/12/02

I would suggest an Adapter pattern use here. IF there is something that has

[#390795] Is there a better way to check this array? — Wayne Brissette <wbrisett@...>

I have an array which contains items that need to be renamed. Unfortunately the way things are changed are based on a comparison of if something else exists. For example in this simple array:

9 messages 2011/12/03

[#390876] black magical hash element vivification — Chad Perrin <code@...>

Ruby (1.9.3p0 to be precise, installed with RVM) is not behaving as I

12 messages 2011/12/05

[#390918] WEB SURVEY about Ruby Community — Intransition <transfire@...>

Did any one else get this survey request?

14 messages 2011/12/07

[#390972] Which is the best online document conversion site? — "Maria M." <mariamoore952@...>

Can anyone tell me that which is the best online document conversion

7 messages 2011/12/08

[#390976] Confusing results from string multiplication — Rob Marshall <robmarshall@...>

Hi,

19 messages 2011/12/08

[#391019] How can I do h["foo"] += "bar" if h["foo"] does not exist? — "Andrew S." <andrewinfosec@...>

Hi there,

13 messages 2011/12/09

[#391027] reading from file without end-of-lines — Janko Muzykant <umrzykus@...>

hi,

20 messages 2011/12/09
[#391028] Re: reading from file without end-of-lines — Gavin Sinclair <gsinclair@...> 2011/12/09

> i'm trying to read a few text values from single file:

[#391031] Re: reading from file without end-of-lines — Robert Klemme <shortcutter@...> 2011/12/09

On Fri, Dec 9, 2011 at 9:58 AM, Gavin Sinclair <gsinclair@gmail.com> wrote:

[#391042] Re: reading from file without end-of-lines — Gavin Sinclair <gsinclair@...> 2011/12/09

On Fri, Dec 9, 2011 at 8:18 PM, Robert Klemme

[#391135] I need advice on what to do next. — Nathan Kossaeth <system_freak_2004@...>

I am new to programming. I read the ebook "Learn to Program" by Chris

23 messages 2011/12/12

[#391216] perf optimization using profile results — Chuck Remes <cremes.devlist@...>

I need some help with optimizing a set of libraries that I use. They are ffi-rzmq, zmqmachine and rzmq_brokers (all up on github).

13 messages 2011/12/13
[#391218] Re: perf optimization using profile results — Chuck Remes <cremes.devlist@...> 2011/12/13

On Dec 13, 2011, at 9:57 AM, Chuck Remes wrote:

[#391234] Re: perf optimization using profile results — Charles Oliver Nutter <headius@...> 2011/12/14

A couple quick observations.

[#391238] Re: perf optimization using profile results — Chuck Remes <cremes.devlist@...> 2011/12/14

On Dec 13, 2011, at 7:03 PM, Charles Oliver Nutter wrote:

[#391324] ruby 1.9 threading performance goes non-linear — Joel VanderWerf <joelvanderwerf@...>

12 messages 2011/12/16
[#391325] Re: ruby 1.9 threading performance goes non-linear — Eric Wong <normalperson@...> 2011/12/16

Joel VanderWerf <joelvanderwerf@gmail.com> wrote:

[#391420] Accessing class instance variables from an instance? — "Shareef J." <shareef@...>

Hi there,

26 messages 2011/12/20
[#391454] Re: Accessing class instance variables from an instance? — Khat Harr <myphatproxy@...> 2011/12/21

Actually, now that I'm thinking about it the existing behavior sort of

[#391456] Re: Accessing class instance variables from an instance? — Josh Cheek <josh.cheek@...> 2011/12/21

On Tue, Dec 20, 2011 at 9:42 PM, Khat Harr <myphatproxy@hotmail.com> wrote:

[#391545] Kernel#exit raises an exception? — Khat Harr <myphatproxy@...>

While I was working on embedding an interpreter I wrote a function to

13 messages 2011/12/24

[#391618] rvmsh: An easy installer for RVM — Bryan Dunsmore <dunsmoreb@...>

I have recently begun work on a project called [rvmsh]

12 messages 2011/12/29

[#391783] Mailspam — Gunther Diemant <g.diemant@...>

Is there a way to stop this mailspam of Luca (Mail)?

12 messages 2011/12/29

[#391790] What’s the standard way of implementing #hash for value objects in Ruby? — Nikolai Weibull <now@...>

Hi!

23 messages 2011/12/29
[#391792] Re: What’s the standard way of implementing #hash for value objects in Ruby? — Gunther Diemant <g.diemant@...> 2011/12/29

I think you can't access instance variables from a class method, so

[#391793] Re: What’s the standard way of implementing #hash for value objects in Ruby? — Nikolai Weibull <now@...> 2011/12/29

On Thu, Dec 29, 2011 at 15:52, Gunther Diemant <g.diemant@gmx.net> wrote:

[#391811] Re: What’s the standard way of implementing #hash for value objects in Ruby? — Robert Klemme <shortcutter@...> 2011/12/29

On Thu, Dec 29, 2011 at 4:06 PM, Nikolai Weibull <now@bitwi.se> wrote:

[#391812] Re: What’s the standard way of implementing #hash for value objects in Ruby? — Nikolai Weibull <now@...> 2011/12/29

On Fri, Dec 30, 2011 at 00:26, Robert Klemme <shortcutter@googlemail.com> wrote:

[#391816] Re: What’s the standard way of implementing #hash for value objects in Ruby? — Josh Cheek <josh.cheek@...> 2011/12/30

On Thu, Dec 29, 2011 at 5:47 PM, Nikolai Weibull <now@bitwi.se> wrote:

[#391833] Re: What’s the standard way of implementing #hash for value objects in Ruby? — Robert Klemme <shortcutter@...> 2011/12/30

On Fri, Dec 30, 2011 at 12:47 AM, Nikolai Weibull <now@bitwi.se> wrote:

Re: rvmsh: An easy installer for RVM

From: Peter Vandenabeele <peter@...>
Date: 2011-12-29 09:42:04 UTC
List: ruby-talk #391772
On Thu, Dec 29, 2011 at 3:28 AM, Bryan Dunsmore <dunsmoreb@gmail.com> wrote:

> I have recently begun work on a project called [rvmsh]
> (https://github.com/dunsmoreb/rvmsh); an easy installer for RVM.
>
>
> What it does is:
>
>  + Install prerequisites
>  + Download RVM
>  + Load RVM
>  + Source ~/.bashrc
>  + Test for RVM
>  + Offer to install latest ruby
>
> I'm open to any suggestions and even encourage them.  I would also be
> happy if people would try it out on their systems and tell me if it
> works.
>

Thanks you for the work, interesting.

I was trying to use it for single user installation on Ubuntu (10.04) and
had
to make a few tweaks to make it work in single mode. Full code at
https://github.com/petervandenabeele/rvmsh

I'll explain what I changed.

diff --git a/ruby/latest b/ruby/latest
index d72af3d..67b8bc0 100644
--- a/ruby/latest
+++ b/ruby/latest
@@ -1 +1 @@
-ruby-1.9.3-head
+ruby-1.9.3

Assuming this script is intended for quick/easy installs of rvm for users,
I prefer to have the current stable version of ruby as the default install.

diff --git a/rvm b/rvm
index 3359a4c..2a507a4 100755
--- a/rvm
+++ b/rvm
@@ -29,7 +29,8 @@
 for app in bash awk sed grep which ls cp tar curl gunzip bunzip2 git svn;
do
  which $app &> /dev/null

  if [ "$?" = "1" ]; then
- sudo $installer install $app
+                echo The app $app is not installed
+                exit 1
  fi
 done

For a single user install and with a "new" script, I prefer not to give sudo
rights to the user. So, when a package is missing, I prefer to let me know,
and then I will go in manually and install it with sudo from my main
account.


@@ -41,11 +42,15 @@
 echo "$installer" | grep -P "(apt-get|apt)" &> /dev/null
 if [ "$?" = "0" ]; then
  for app in build-essential openssl libreadline6 libreadline6-dev zlib1g
zlib1g-dev \
            libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3
libxml2-dev \
-           libxslt-dev autoconf libc6-dev ncurses-dev automake libtool
bison; do
- which $app &> /dev/null
+           libxslt1-dev autoconf libc6-dev libncurses5-dev automake
libtool bison; do
+                # which $app &> /dev/null
+                # ONLY works on Debian derived distro's
+                # TODO similar for yum
+ dpkg -l $app | grep ^ii &> /dev/null

This seems a significant bug. I wonder how this passed your testing on
Debian/Ubuntu.

You use `which <command>` to see if a package is installed. But ... e.g.
for the package
'build-essential' there is no 'build-essential' command that is installed
(at least not on
Ubuntu 10.04).

My solution DEBIAN ONLY is to check with dpkl -l | grep ^ii

I did not test the yum side, maybe a similar fix is required there ?

Also, on a recent Ubuntu, the installed packages are installed as
alternatives,
so, 'ncurses-dev' becomes 'libncurses5-dev'. For better robustness, we need
to find a way that checks for either one of the packages (or use the dpkg
system to discover in a more fundamental way if the ncurses-dev dependencies
are met). Same for libxslt-dev.


  if [ "$?" = "1" ]; then
- sudo $installer install $app
+                        echo The app $app is not installed
+                        exit 1
  fi
  done
 fi


Same as above, for single-user installs, the script should work without
sudo.


@@ -99,8 +104,8 @@
 case "$mode" in
  touch ~/.bashrc
  fi

- echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"' >>
~/.bashrc
- source ~/.bashrc
+        # do the load here, since the return in top of bash made this fail
+ [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
  ;;


I presume(??), this is the tricky known issue where the line [ref A]

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

returns for non interactive shells and this fails to load rvm. So, as a
quick hack,
I simply ran the line straight from rvmsh.

Also, don't add that line yourself. Rvm already adds the line. And also,
when running
rvmsh multiple times, it added the line everytime again.

@@ -126,15 +131,16 @@ if [ "$mode" = "single" ]; then
 fi

 # Test if RVM is installed.
-which rvm &> /dev/null
+echo "rvm is installed here:"
+which rvm

I prefer to actually see where rvm is installed.

-if [ "$?" = "0" ]; then
+if [ "$?" = "1" ]; then
  echo "There was an error installing RVM!"
  exit
 fi

This seems like a hard bug. You want to bail out when the rvm _failed_, do
you,
and not when it succeeded ? I presume, it actually never passed in your
tests
(because the rvm loading never really happened because of the return in the
top of .bashrc, see [ref A] above). Bailing out on failure seems more
correct to
me, but I may be wrong.

 # Offer to install latest ruby.
-latest="https://raw.github.com/dunsmoreb/rvmsh/master/ruby/latest"
+latest="https://raw.github.com/petervandenabeele/rvmsh/master/ruby/latest"
 version=$(curl -s $latest)

I prefer the latest stable version. Rvm will automatically select the
latest stable
version (the one with the [-pxxx] at the end).

Still this method has a flow that we need to update manually when Ruby/rvm
upgrades
and eventually we will forget. An automatic method would be better ...
Maybe rvm has
a proper way to inform us of the latest stable MRI ruby (sorry I didn't
look it up now).

 read -n 1 -p "Would you like rvmsh to install the latest ruby ($version)
for you? (Y/n) " ans
@@ -157,3 +163,4 @@ fi

 # Done, congratulations.
 echo "Congratulations!  RVM was successfully installed."
+echo "run 'source ~/.bashrc' now to activate rvm"

Inside the script, rvm got loaded (with my hack of executing the load line
directly), but
outside of the script, rvm seems not be loaded yet. So, I add a message to
inform the
user about that.

My patches are certainly hackish, but it works and thanks again for this
useful script.

Peter

PS. A log from a successful single-user install

new_user@ASUS:~$ mkdir ruby
new_user@ASUS:~$ cd ruby/
new_user@ASUS:~/ruby$ git clone git://github.com/petervandenabeele/rvmsh.git
...
new_user@ASUS:~/ruby$ cd rvmsh/
new_user@ASUS:~/ruby/rvmsh$ ./rvm
rvm is installed here:
/home/new_user/.rvm/bin/rvm
Would you like rvmsh to install the latest ruby (ruby-1.9.3) for you? (Y/n)
y
Installing Ruby from source to: /home/new_user/.rvm/rubies/ruby-1.9.3-p0,
this may take a while depending on your cpu(s)...
...
Would you like rvmsh to set ruby-1.9.3 as the default ruby for you? (Y/n) y
Using /home/new_user/.rvm/gems/ruby-1.9.3-p0

Congratulations!  RVM was successfully installed.
run 'source ~/.bashrc' now to activate rvm
new_user@ASUS:~/ruby/rvmsh$ source ~/.bashrc
new_user@ASUS:~/ruby/rvmsh$ type rvm | head -1
rvm is a function

-- 
Peter Vandenabeele
http://twitter.com/peter_v
http://rails.vandenabeele.com

In This Thread