-
Notifications
You must be signed in to change notification settings - Fork 32
Description
Hi,
i'm a sysadmin working on a tool for doing my daily tasks on my server farm.
Due to the fact that i have around 70 hosts and also put them in logical groups together, i do initialize Rye:Boxes and Rye::Sets in Hashes and later work with them.
That leads to an behavior, i can not work with and also absolutely don't understand:
My ENV:
0 % ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0]
0 % gem list G rye
rye (0.9.11)
Example in irb:
> a = {}
=> {}
> hostname = 'localhost'
=> "localhost"
> a[hostname] = Rye::Box.new(host="#{hostname}", :safe => false)
=> #<Rye::Box:localhost name=localhost cwd= umask= env="" safe=false opts={:port=>nil, :keys=>["/Users/ts/.ssh/id_rsa"]} keys=["/Users/ts/.ssh/id_rsa"]>
now comes the (not so) funny part, this doesn't work:
> a.each_value {|v| v.uptime}
=> {"localhost"=>#<Rye::Box:localhost name=localhost cwd= umask= env="" safe=false opts={:port=>nil, :keys=>["/Users/ts/.ssh/id_rsa"], :user=>"ts"} keys=["/Users/ts/.ssh/id_rsa"]>}
but i'm working with an Rye::Box object with an existing method 'uptime'
> a.each_value {|v| puts v.class}
Rye::Box
> a.each_value {|v| puts v.public_methods.grep(/uptime/)}
uptime
but this works:
> a['localhost'].uptime
=> [17:59 up 13 days, 3:27, 2 users, load averages: 0.69 0.63 0.64, , 0, ]
I also create Rye::Sets in a Hash and populate them with the boxes out of another hash but this somehow leads to losing my ssh-key, so i get a password prompt... But i first want to understand this simple example above.
If you could help me out i would really appreciate that.
Best,
Torsten